Hey everyone, please go check out the beta of Ben’s Gigs and reserve yourself a beta spot.

 

Ever wondered if you can use gmail’s web UI to send emails using Ruby? The answer is YES!

Why use their web UI instead of SMTP, you may ask? Normally I would say don’t. I would tell you to skip gmail entirely and use a service like AuthSMTP to send your emails reliably. However, there are some cases where punching through email filters takes a little extra juice. In those cases, gmail’s web UI can be just the remedy. For privacy reasons, gmail’s web interface masks the sending IP address. All the recipient can see is that the message originated from gmail. If your sending IP address has been used for spam in the past, this approach can help with email delivery. This technique is indistinguishable from using gmail’s web UI in a browser.

Gmail’s modern web UI requires a JavaScript engine, which makes it a non-starter for WWW::Mechanize scripting. But gmail also offers a fallback ‘HTML-only’ mode works for our purposes.

Here is a Ruby script using WWW::Mechanize that will send emails programmatically through gmail’s web interface.

agent = Mechanize.new
agent.user_agent_alias = 'Linux Mozilla'
page = agent.get 'http://www.gmail.com'

# #log into gmail
form = page.forms.first
form.Email = 'my_address@gmail.com'
form.Passwd = 'password'
page = agent.submit(form, form.buttons.first)

page = agent.click page.links.find { |l| l.text =~ /basic HTML/i }
page = agent.click page.links.find { |l| l.text =~ /compose/i }

form = page.forms[1]

form.to = 'example@example.com'

form.subject = 'test subject'

form.body = < "Hi,

I would like to email you.

"
EOF
page = agent.submit(form, form.buttons.first)

 

Here is a code sample to do just that.

But keep in mind, this filters the title in maybe all places the title shows up, including the admin.


add_filter('the_title', 'hide_click_title',10,2);
function hide_click_title($t, $id)
{
	$post = &get_post($id);
	if($post->post_type!='page' || $post->post_name!='my_specific_post_slug') return $t;
	return 'filtered title';
}

 

I posted an ad to sell my iPhone 3G with a cracked screen.

In the last 3 hours, I’ve received about 10 spam responses in broken English asking me to text or call a local number.

There is no way 10 people are interested in an iPhone 3G with a cracked screen. Whazup??

 

Stephen King’s book, On Writing is great. In it, he talks about how he can spend months writing a book only to see the story hit a dead end. He throws the whole book out.

I feel that way about some recent work I’ve been doing on Click. Sometimes you take a path and find out it doesn’t lead anywhere. Part of being a programmer. When you’re a beginner, you want to keep everything. When you’re intermediate, you throw out other peoples’ work. When you’re advanced, you throw out most of your own work! :)

I always know when it’s happening too. I get this sick feeling inside me that I’m going the wrong direction. I ignore it and forge ahead until I absolutely hit the brick wall at full speed. And that seems to be the lesson I keep repeating.

 

I’ll just go ahead and proclaim myself the King of Craigslist until somebody else steps forward. I finally finished my 2010 taxes, and I made over $400K. It all came from Craigslist. 2010 was a weak year. I went through a loving “marriage dissolution”, relocation, lots of emotions, marketing troubles, and a general lethargy/apathy. And still made a ridiculous living. (By the way, freelance programmers, you too came make a ridiculous living using Ben’s Gigs – shameless plug!).

This article is about how to find good help with your project.

We all know that 99% of the posts on Criagslist are crap, if they’re even real. My business is about you: that 1% of real entrepreneurs with real ideas and real budgets. But I see a lot of you fall by the wayside and never launch your web sites or bring your dreams to reality. Why is that? I call it The Craigslist Effect, even though it’s not really Craigslist’s fault.

Here’s what happens: you pick someone, you send them a good faith deposit, and they start working. It’s going great. As the site develops, you begin to see farther into the process. Without consciously realizing it, your expectations begin to shift. With the benefit of hindsight and a little experimentation, you can see better paths. At the same time, the programmer is feeling this too. Plus he’s losing interest because your deposit is running low. Once he passes that inflection point, he realizes that he didn’t bid your project right. He feels his hourly average approaching minimum wage. Finally, one day he just doesn’t show up. You try to call. You try to email. But the guy is gone.

You might have some code from him, but it’s probably worthless. And now you have 50-80% of the budget you started with. Time to start over with another Craigslist post for another developer to pick up where the last guy bailed out. And lose another chunk of your budget as the cycle repeats.

At some point, I see your post and respond. You hear about the benefits of the Agile process. I tell you about the fixed-price sprints I do, and how it helps to contain your project and budget. I also tell you the cold truth about how custom software takes a life of its own and that you need a trusted partner to navigate the waters with you. But, it’s probably too late for you. By the time we find each other, your budget might only be 50% of where you started.

Your budget gets eroded slowly as you search for a good provider. Craigslist makes it easy to find bad providers, which accelerates that erosion. But there is a mystery here. You understand all this, so why does a smart person like you get caught in such an obvious trap? I think I know.

1. Illusion of Knowledge

Let’s admit it: you are wearing “invention goggles”. You have been thinking and dreaming about this idea for so long that it feels really solid. Your confidence is high because you know exactly what you need, what you know, and what you don’t know. You have solved for most of the variables. But you know that’s not true. The invention goggles obscure important considerations that would be obvious to an onlooker. The more you think about a problem, the more likely you are to overlook big problems. Then you hop on Craigslist and actually CHOOSE somebody to help you build your massive oversights into reality. How’s that for an illusion?

2. Illusion of Choice

Second, you have an illusion of choice working against you. When you post to Craigslist, you get too many choices. In a recent test post, I got over 75 responses. Who the hell has the time or knowledge to evaluate all that! At night, most of the responses come from overseas. In the day, the responses are split about evenly between US-based contractors and people pretending to be US-based. Because I’ve been doing this for so long, I’ve become very accurate in assessing who is a real programmer and who is not.

Let’s say 10% of the responses are real people who might actually be able to do the work. If you have them flagged in your inbox, you’ve already gotten farther than most. But now you, someone who knows very little about how to launch a stellar web site, has to try to evaluate skills you don’t really have.

Naturally, you turn to portfolios and references. That way you can compare the work objectively, talk to other people, and make an educated choice. You’ll hire the most qualified person for the job.

Or will you? You can probably guess by now that the answer is no, or I wouldn’t be writing this article. Craigslist is a strange vortex where logic and traditional approaches yield very bad results. Let’s think about this. Who is on Craigslist with a stellar portfolio and references? By its very nature, Craigslist tends to attract both buyers and sellers who have no alternatives. It’s the Hail Mary of contracting. Either you don’t know someone to hire, or the people who know you would not hire you. A match made in heaven!

The person on Craigslist with great references and a portfolio is usually a well-disguised middle man. I’ve even seen middle men post their own ads for ads originally posted by a real buyer and to which I responded days earlier. Middle men post ads for business they don’t even have yet. Did that make sense? In other words, they post an ad for a programmer so they can get a quote to turn around and send back to the original customer (who also posted to Craigslist a few days earlier) in hopes of winning the business. It’s bad out there my friends, it’s bad out there. The middle man is the only person who has the time to market to you. The real people are actually programming web sites and are less than impressed with your request for samples and references. It shows that you don’t know a thing about Craigslist or how to select a good web developer. How’s that for a weird illusion? Your very responsible efforts to find the best candidates just turned off the best candidates!

3. Illusion of Thresholds

I talked about pricing a little earlier, but I want to dig into it a little more, because there is another illusion. I’m sure your mother told you that you get what you pay for. It’s true enough, but the hard part is deciding how much to pay. You will get bids from $10/hr to $150/hr. Are the programmers really that different? Maybe in the real world, yes. But on Craigslist, no. There is nobody pulling $150/hr who finds work on Craigslist. And the $10/hr guy is going to find a way to charge you a lot more, so you can’t believe him either.

So it’s an illusion of thresholds. Science tells us to find threshold tests so that we can group choices into categories. We think it’s especially useful to separate the extremes from the middle. But on Craigslist, the extremes are both false and the vast middle leaves you with still too many choices and no easy way to tell them apart. The more you try to evaluate candidates based on reported statistics, the further you get from the truth. How’s that for an illusion?

Yeah, so what’s the answer?

You need to approach the problem completely differently. You need something that cuts through all the noise. It turns out, getting back to basics helps a lot. Forget the spreadsheet skill matrix. Forget the skills/portfolio/references/pricing.

Instead, look for a real person. Someone with a name, a family, and ambitions in life. Those people are responding to your ads, but they won’t pop based on any statistical measurement. Instead of a traditional portfolio, look for love. Look for the person who has contributed code to the open source community, donated his time, maintains personal projects, and generally shows a true love of what he does.

That’s the person you want. That’s who I am. Ouch! Sorry, I couldn’t resist :)

 

Looks like Facebook is phasing out FBML. Too bad that I wrote a bunch of FBML code, but good for everyone else. iFrame is the way to go.

The Click framework makes easy work out of iFrame development for Facebook. Maybe I’ll put together a demo app – if I can bring myself to re-activate my Facebook account. I’ve been really enjoying being off the grid. So much easier to date girls!

 

Alost every WordPress theme includes a 404.php theme file for those unfortunate cases where WordPress cannot find the URL path requested.

There are also plugins that customize the 404 experience, and nearly all of them require that you modify the theme’s 404.php file to call a custom function provided by the plugin.

My particular problem wasn’t 404 page customization. WordPress forwards to the 404 page for any URL that isn’t recognized. That’s exactly what I want Click to intercept for rendering custom pages with full URL support. So in effect, a 404 from WordPress means that Click needs to wake up and potentially render some output.

I could have done what everyone else did and modify the 404.php theme file so that it calls Click. Instead, this seemed to me to be a perfect opportunity for a WordPress filter. apply_filters() to the rescue.

The change I made to iFeature is just a little slice of genius making use of apply_filters(). It creates its default markup (the 404 message), and then it calls apply_filters(). If Click is listening, Click will replace that markup with its own content. Bingo: custom pages and dynamic URLs in WordPress.

I think every plugin author should adopt this approach. You still want the template, but you want the ability to customize content.

 

Today I was working on a stand-alone web site that was very poorly designed. I took it as an opportunity to introduce Click into the system so I could get some ActiverRecord support instead of doing raw mysql queries.

This lead to some refactoring. The upshot is that Click now lives in a core that is capable of being embedded in many different types of systems.

I have examples of embedding Click in WordPress as a plugin, and embedding Click in an existing site.

Not too far off is embedding Click in a stand-alone version.

Each of these Click configurations is its own github repo. So click-core is the main repo, and then wp-click is the WordPress plugin that integrates Click (allowing you to write other WP plugins that depend upon Click). There will eventually be a standalone-click and a website-click (?) having Click configurations and including relevant submodules that are commonly needed for stand-alone and existing-site integrations.

For example, an existing site probably doesn’t need HAML or any of the management modules. But including ActiveRecord is very handy. A stand-alone site would certainly want things like user authentication, but an existing site would not need that. In essence, each integration vertical will require its own ‘template’ of the Click core plus some number of submodules.

All that and more on github now.

 

There is a lot of confusion online about how to use a private SSH key with coda. Here’s how on OS X:

I’ll assume you know how to install a private key in your ~/.ssh folder and that you can connect normally like this:


$ ssh -i ~/.ssh/my_rsa username@somehost.com

1. Add a host shortcut and test. If it’s working you should be able to SSH using just the shortcut name.


$ nano ~/.ssh/config

Now add your version of this:

Host my_shortcut
HostName somehost.com
IdentityFile ~/.ssh/my_rsa
User username
IdentitiesOnly yes

Now both of these should work without specifying the keyfile:


$ ssh username@somehost.com
$ ssh my_shortcut

2. Launch Coda and configure a new site.

3. Use the my_shortcut name for the ‘server’ in both the SFTP and Terminal areas.

4. Use your username specified in the SSH config.

5. Leave passwords blank

That’s it. You should be able to connect now.

© 2011 Ben Allfree :: Painless Programming Suffusion theme by Sayontan Sinha