Posted by & filed under GIT.

With an installation of GIT on a new machine, the push/pull behavior I was used to has changed. I prefer that a push and pull only affects the current branch, not all of them.

To set this behavior, globally, run the following commands:

git config --global pull.default current
git config --global push.default current

Now you won’t have anymore surprise pushes of your not-quite-ready code from another branch.

Posted by & filed under Linux.

I recently purchased a Lenovo ThinkPad Carbon X1, which has been an absolutely stellar laptop so far, after immediately replacing Windows with Linux (specifically, Mint).

One of the unfortunate things about Linux Mint is that it chooses to fallback DNS resolution to OpenDNS, which in the world of DNS is a sort of spyware. If the user requests a domain which doesn’t exist, instead of getting an error back, OpenDNS will display one of their webpages. This has the benefit (for OpenDNS) of getting more eyes on their websites, and if I had to guess, Mint might make some sort of cut as well. The side effect is that this breaks the internet, and any scripts you may be running to check for nonexistent domains will fail.

The configuration for OpenDNS servers is stored in the following file:

/etc/resolvconf/resolv.conf.d/tail

You have two options. The first is to delete the file entirely, and no fallback DNS servers will be used. Another option is to replace the two IP addresses in the file with the DNS server of another service. I chose to do the latter, and use the Google DNS settings of 8.8.8.8 and 8.8.4.4, and now I bask in the glory of an error screen when I mistype a domain name, instead of the shitty OpenDNS service.

Posted by & filed under Linux.

By running these commands, you will download the necessary fonts required to render Emoji on your Linux machine.

mkdir ~/.fonts && cd ~/.fonts
wget http://download.damieng.com/fonts/redistributed/DroidFamily.zip
unzip DroidFamily.zip && rm DroidFamily.zip
wget http://users.teilar.gr/~g1951d/Symbola.ttf

Interestingly enough, I didn’t even have to restart my apps. Pidgin, for example, immediately displayed the new font. It seems the OS is smart enough to find the fonts, see that they display the missing symbols, and re-render the text.

Please note, these will not be the full-color bitmapped images like on OS X, but will instead be colored vectors like the rest of the font glyphs.

Emoji on Linux

Emoji on Linux

Posted by & filed under Personal.

I’ve been having a bad few days. Work just isn’t as fun as it used to be. I find myself throwing coworkers under the bus left and right; something I never used to do. Yesterday I sent an email to a third party that sounded a bit snarky (unintentional, but still). These are all classic signs of the burned out developer.

I’ve been on an exercise kick recently. Just a few days ago I ran a Half Marathon distance for fun. Today, I went ice skating with some coworkers (they talked me into buying a season pass). I stepped out onto the ice, made a few passes, and then realized everyone had switched directions, and so I attempted to do a 180 and go with the flow.

Well, my attempt seemed to fail. I ended up slamming my hand into the railing which surrounds the court. Apparently they intend only gloved-hockey-players to use this rink, because my pinky came into contact with a sharp corner of exposed aluminum, which runs around the entire perimeter of the rink. My finger instantly began bleeding all over the place.

Sliced Finger

Come to find out, the cut was very deep, slicing not only through flesh but also through fingernail. Judging from the depth of the cut and my amateur knowledge of human anatomy, I’d wager my finger stopped moving once the aluminum came into contact with bone.

I wrapped it up in a bandaid, and finished the open-skate session. But something magical happened once I sliced my finger open; I stopped giving a fuck.

About what you ask? Everything, I suppose. I knew at that point I really wasn’t going to be getting much done at work for the next day or two, so I sent out an email that I was taking the rest of the day off and probably the next as well. I talked with my friends/coworkers who were skating with me, and told them that I needed to just get away.

And here I am, blogging away at a coffee shop in Toronto, Ontario, Canada.

I’ve never done this before. I’ve never taken a road trip just for the hell of it. Truth be told, I was afrad of travel for many years. Especially when it came to traveling alone. This year, however, has involved a lot of progress for me. I took a trip out to California to visit family. I took a trip (flew alone!) to the TechCrunch Disrupt New York conference for work. I even flew to Ireland for a week with a friend (another coworker) just to see the country.

This time, I literally made my decision, and two hours later was on the road.

Unfortunately, this situation is not something the Border Patrol is used to hearing.

Being male, mid twenties, driving alone, to a part of another country you’ve never been to before, while not knowing anybody in said country, looks really suspicious to the border patrol. The conversation went down a lot like you’d expect.

“What are you here for?
Oh, just a mini vacation.
When’s the last time you were here?
About a year ago, just to Windsor though.
Why did you come here then?
Well, my ex had friends here, and we were visiting.
Are you visiting them today?
No.
Where do you work?
I work at a networking company in Michigan.
Are you here for work?
No.
I’m going to place this sheet of paper under your windshield wiper. Please pull ahead to customs.”

At this point, it becomes obvious that I’m going to be here a while. I pull up, get out of my vehicle, and wait for someone to come assist me. A border patrol worker comes and begins going through my car, making sure to check every nook and cranny of the center console, my laptop bag, my suitcase and dopp bags, you name it.

“What are you here for, sir?
Just visiting.
Whose car is this?
Mine.
What is the license plate number?
31337
Are you here visiting anyone?
Nope.
Is this your laptop?
Yes.
Are you here for work?
No.
Why are you here, sir?
Just on a mini vacation.
I see you only have one nights worth of clothing. Why are you here for only one night?
Well, I just wanted to get away.
Why did you choose Canada?
Well, Toronto is a big town that isn’t too far, and I reallly didn’t like Chicago.
Can you give me your phone, sir?
Uhh… Sure.
Can you unlock your phone sir?”

It’s at this point I give the man a look of incredulousness.

“If you do not unlock your phone sir, I will have our IT guys unlock it for me.”

I punch in the code to the phone. He disappears around the back of the car, and him and another guy begin going through my phone. The sort of things they checked included call history, text messages, facebook chat history, and going through my photos. I knew this because the apps were now higher up in the run history, and were scrolled back a surprising distance. The last screen opened when I got the phone back was half way through my Ireland vacation photos (a couple thousand in).

“Sir, can you please help me out here. I’m just trying to put your story together. You came here, on a whim, just to spend a day, in a place you don’t know, with nobody you know, in the middle of the week when you should be at work?”

I did my best to explain. I doubt they believed a word of my story, but seeing as there was in fact no drugs in my car, and I kept telling them that I wasn’t here to work, and they didn’t have anything to pin on me, they finally checked off a box on the sheet of paper and allowed me to enter a nearby building.

In here, the woman behind the counter was a little bit nicer. She asked me the same sets of questions I had heard several times again. This time though, she asked me something I thought was pretty funny.

“Are you here to gamble online?
Uhh, no.
Are you sure?
I’m positive.
Everybody gambles online!
It’s just not for me.
Well, what is this laptop for then? Are you here to work? If so, we have forms you can fill out.
No, I just like to have my laptop.”

I’m not sure if that was an attempt at entrapment or what. I have no idea why someone would want to drive 5 hours into another country, just to whip out their laptop and gamble online. Surely, there are better ways to gamble, such as going to a casino, or playing cards in a basement with friends. Of course, this isn’t even mentioning the concept of using a server in another country as a proxy to get around the regional restrictions that online gambling websites undoubtedly have. (There’s no way I would have said that though; to these people, knowledge is an admittance of guilt).

Posted by & filed under JavaScript.

A friend linked to this game the other day:

Cookie Clicker

It’s really simple. You click something over and over, and you buy upgrades, and then some automated processes happen in the background.

Open your console, and paste in the following commands. They will allow you to play the game automatically. Notice the $$; this uses MooTools, not jQuery.

// Automatically purchase new products (e.g. Grandmas) each second as they become available
setInterval(function() { $$('.product.enabled')[0].click(); }, 1000);

// Automatically click the big cookie 10 times per second
setInterval(function() {$('#bigCookie').click();}, 100);

// Automatically purchase upgrades each second as they become available
setInterval(function() { $$('.upgrade.enabled')[0].click(); }, 1000);

These simple commands don’t play the game as efficiently as possible. One could graph out the best way to play the game, which would involve saving up for better options instead of always spending money.

For Cookie Clicker to prevent this easy way of cheating the game, they’d probably want to not load MooTools as a global object, and randomize the names of DOM elements each time the game is loaded. Those wouldn’t prevent these cheats 100%, but it would make them harder to perform.

Posted by & filed under OS X.

I’m trying to make use of the latest version of ApacheBench (2.4.3) to perform some benchmarking against my local server. Unfortunately, it seems to be broke as hell.

$ ab -n 100000 http://localhost:3000/analytics
This is ApacheBench, Version 2.3 <$Revision: 1373084 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
apr_socket_recv: Connection refused (61)

Interestingly, the output of the command tells me that I’m using ab 2.3, when the HomeBrew build version is 2.4.3:

brew info ab
ab: stable 2.4.3

I find that ApacheBench generally doesn’t work very well, especially under OS X. There’s all sorts of quirks (If benchmarking the root of a site, a slash must be added or ab will error out). The most annoying part is that OS X doesn’t have a good way to allow more open ports from a single process.

Does anyone know how to get this tool working again? Or, does anyone know of a better alternative?

Posted by & filed under Personal.

It would be illegal to tell the users of your web service that you have been subpoena’d by the NSA and forced to give access to private customer data.

However, would it be illegal to create a blog post every single day saying that the service has never received a subpoena, then stop creating new posts once it has happened?

Posted by & filed under Linux, OS X.

I use the following command to recursively download a bunch of files from a website to my local machine. It is great for working with open directories of files, e.g. those made available from the Apache web server.

The following can be added to your .bash_profile or .bashrc script, depending on which your OS/distro recommends:

function download-web() {
    wget -r -nH --no-parent --reject='index.html*' "$@" ;
}

To invoke the command, you run it like so:

download-web http://www.example.com/path/to/files

It will then download everything linked from the first page, checking each child path, to the current directory. It will not download anything above that directory, and will not keep a local copy of those index.html files (or index.html?blah=blah which get pretty annoying).

This isn’t a simple alias, but is a bash function, so that you can add a URL after the command. It should work fine in both OS X and Linux. If you are using OS X, you can follow my guide for Installing WGET on OS X.

Posted by & filed under Personal.

So, yeah, I wrote this book:

Instant Backbone.js Application Development

The process took a couple months, despite the relatively short length of the book. You wouldn’t believe how many times the book has to go back and forth between the publisher and the writer! I’ll have to write about my experiences in more depth in the future, for those of you interested in publishing works yourself.

The book is currently only available as a digital download, I think it’ll take a few weeks for the copies to get printed before we’ll see physical copies for sale.

The book itself is intended for people who know some JavaScript, and who don’t really know Backbone.js, and are looking to build Single Page Applications. If you like my writing style, and are interested in learning Backbone.js, by all means grab yourself a copy!