Mar 9 2010 by Andrew Brown
I spent 1.5 hours searching the Internet and the JQuery docs to figure out how to perform sub or gsub on a string with a regular expression. I had to use a crazy mix of keywords to find the answer. Hopefully this blog post gets index on Google so the next person looking to do regular expressions in JQuery doesn’t have to waste so much time looking for the sub or gsub equivalent because the JQuery people can’t stick to programming conventions that makes sense and are already known by most programmers. This is a case of unnecessary naming cleverness. Give me back my time JQuery, you time vampire.
Oh, let us not forget the solution:
"This is a test".replace(/test/,'an explosion')
Mar 5 2010 by Andrew Brown
I’ve spent hours in the past crafting my resume, portfolio and website but everytime I’ve been hired, the didn’t look at my resume, they never saw my portfolio, and they didn’t even visit my website. I had always offered sample work for free out of selflessness and not expecting anything from it, and they all turned around offering long lasting work.
You want to get hired as web-developer? Don’t show a paper that suggest results, give them something to chew, if it tastes good, they’ll want more.
Mar 2 2010 by Andrew Brown
Look around on your desk and pickup the closest thing near you.

I picked up my Swingline red stapler. Why did I buy it?, how often do I use it and why do I need it? I am never stapling and I’m not going to staple anything in the next year.
I have a pile of papers on my desk that I’m holding onto because I need to do my taxes. The pile looks daunting, but if I were to throw out the junk in that pile, doing my taxes would seem much easier.
I need to frequently travel, and I have a pile of clothes. I don’t wear half of them but when it comes to packing, the pile looks daunting, if I were to throw out the clothes I don’t wear my packing would seem much easier.
I have a iMac that only gets used to play my itunes music, a Nikon D80 I take photos with but I don’t take the photos off the camera until three months later.
I don’t need these things but Its hard to part with them. I know I can justify keeping them because myself as an irrational human being wants to keep them, but I want you to listen to your robot mind.
Stop holding on to shit you don’t need and remove the visual clutter that is blocking your end goal.
I’m getting rid of my red stapler today and I want you to question what you picked up, and if you can come up with one reason to justify on how its distracting you from your end goal then throw it out now.
Your end goal awaits you.
Feb 22 2010 by Andrew Brown
To be a professional Ruby on Rails developer you need to properly commit your changes to the git repos without making a big mess. Compare the two git trees below.

The problem is when your working with multiple people on a git repos you can’t work in master otherwise when you pull changes, you’ll have a messy merge and when you push you’ll make a bunch of messy lines in your git tree, and you’ll get yelled at for making those messy lines.
I want to go through the steps with you to get your git tree to look like one straight line. Look at the model below to understand what you need to do.

Lets go through the step of adding a new feature:
Make sure we’re on master
Make sure our master is up-to-date
Create a new branch called new_feature
git checkout -b new_feature
Make changes and commit as much as you want
1. Now we’re ready to push our changes so lets make sure our
master is up-to-date
git checkout master
git pull
2. Lets rebase (If everything was up-to-date skip this step)
git checkout new_feature
git rebase master
3. Merge new_feature into your master
git checkout master
git merge new_feature
4. Push changes
That’s all there is to it! Single clean line, nobody is yelling at you, and you can make fun of your coding friends who have never rebased before.
Jul 20 2009 by Andrew Brown
I wanted to be able to group my posts by months in my wordpress template. I couldn’t find a quick copy and paste online so I wrote my own snippet of code to achieve that result. I had to endure writing php. Since I’ve been a Rails Developer I think I’ve gotten lazier or php is archaic.

<div class="archives">
<?php
$months = $wpdb->get_results("SELECT DISTINCT MONTH(post_date) AS month , YEAR(post_date) AS year FROM $wpdb->posts WHERE post_status = 'publish' and post_date <= now( ) and post_type = 'post' GROUP BY month, year ORDER BY post_date DESC");
$posts = $wpdb->get_results("SELECT id, post_title, MONTH(post_date) AS month , YEAR(post_date) AS year FROM $wpdb->posts WHERE post_status = 'publish' and post_type = 'post' ORDER BY post_date DESC");
foreach($months as $this_month){ ?>
<div class="month">
<h2><?php echo date("F", mktime(0, 0, 0, $this_month->month, 1, $this_month->year)); ?> <?php echo $this_month->year; ?></h2>
<?php for ($i = 0; $i <= count($posts); $i++){?>
<?php if(($this_month->year == $posts[$i]->year)&&($this_month->month == $posts[$i]->month)){?>
<p><a href="<?php echo get_permalink($posts[$i]->id); ?>"><?php echo $posts[$i]->post_title; ?></a></p>
<?php } ?>
<?php } ?>
</div><!-- month -->
<?php } ?>
</div><!-- archives -->