Why I <3 DreamHost

So, I host my website (and my uncle’s photography site, http://timdanielsphotography.com) at DreamHost, under their wonderful shared hosting plan.  I’ve been noticing lately that my sites have been running a bit on the slow side, but didn’t think much of it.  Last night (Saturday night), I was poking through the control panel and discovered that the MySQL servers were hosted on the East Coast, and the web servers on the West Coast.  Hmm, that might explain it.

I submitted a quick, low-priority ticket to DreamHost support asking if they could move the web and MySQL servers into the same data center.  Keep in mind this was late on a Saturday night.

I woke up this morning (Sunday) to an email from a DreamHost tech, saying that he’d moved my web server to live on the East Coast in the same data center as the MySQL.  I was blown away.  Not only did they respond within 12 hours to a low-priority request, they did so on a weekend, overnight.

AND!  The sites are noticeably faster.  Thanks, DreamHost!

Programming Tip: Equality Checks

I don’t know about you, but I’ve gotten weird errors on occasion when I’m trying to write code like “if (i == 0)” and I inadvertently miss the double equals.  Then, you have a double whammy because the if statement will probably always execute, and then i is set to 0.  Bad Thing.

There’s a really easy way to avoid this, though!  Reverse the check: “if (0 == i)”.  The equality check is bidirectional, but you can’t assign a value to a numerical constant.  So, if you happen to miss the double equals, the compiler will throw an error instead of pretending you knew what you meant.

It’s hard to break years of habits, but it’s a darn good idea to retrain yourself.

Note that in Python, this is irrelevant because the Python interpreter won’t let you have an assignment in an if statement (it throws a SyntaxError).

The Stages of Writing a Program

“Oh, I have to write a robot that solves a maze?  Sweet, sounds like a great time to get inventive!  I’ll just create an artificially intelligent robot, no big deal.”

“Hmm, okay, maybe I can use Dijkstra’s algorithm.”

“Crap.  Well, I’ll just implement the right-hand rule.  That shouldn’t be so bad.”

“I guess I’ll just have it move randomly.  Gotta get this done!”


Interesting Technology of the Week – Chocolatey

So, there’s a package manager for windows that’s actually really well done.  By default it’s only got a command line interface but you can install a GUI through it if you want.

It’s called Chocolatey, and the selection of packages is pretty impressive.  For example, `choco install android-sdk` installs all those fun tools automatically and adds them to your $PATH.  Or `choco install 7zip` installs it and before you know it it’s ready to use.  There’s packages for most anything – JRE, Flash, VLC, Adobe Reader, countless development tools…it’s really handy.  And, of course, you can update what you have installed with it by `choco update`.

@powershell -NoProfile -ExecutionPolicy `
unrestricted -Command “iex ((new-object `
net.webclient).DownloadString `
(‘https://chocolatey.org/install.ps1′))” `
&& SET PATH=%PATH%;%systemdrive%\chocolatey\bin

installs it.

It’s a lot like Homebrew for Mac or apt-get (or whatever your favorite package manager is: yum, yast, pacman, emerge…) for Linux.

Definitely worth a shot! I use it a ton.

IDEs and Programming Environments

After programming for 3 years exclusively in Eclipse and its brethren (Pydev, CDT, etc.), I’ve made a switch that I’m really happy about.

Don’t get me wrong, Eclipse is not a bad IDE, it’s just sometimes too bloated and cluttered and not quite powerful enough.  I really like that it has a plugin for everything under the sun and you can do all your development, in any language, in one program.  But it was time.

I tried many different IDEs, ranging from Apple’s Xcode, Microsoft’s Visual Studio, and many more.  I even tried going the text editor route, using both vim and Sublime, both of which are good at what they do, just not for developing code.

I found perhaps a bit of an underdog in IntelliJ IDEA and its brother PyCharm.  They come in two varieties – one open source, without some advanced features (e.g. Django development with PyCharm), or a more hefty version, with a hefty price tag.  For me, the so-called “Community Edition” works great.

You get all the cross-platform goodness and raw power of Eclipse, combined with the sleekness and elegance of Xcode, along with the code analysis toolbelt of Visual Studio.  It’s the best of all the worlds, I think.  And I’m happy with my move.

Interesting Technology of the Week – BitTorrent Sync

I’ve discovered a cool thing called BitTorrent Sync.  It’s basically Dropbox on steroids, using BT technology.  I’m always glad to see BT used for good, not evil.

You pick any number of folders to sync, and it provides you a secret for each which you can enter in on another computer – perhaps another computer of yours, a mobile device, or even a friend or family member’s computer.  It then syncs anything in those folders between the devices (and you can choose manually on the phone, where space is limited), just like Dropbox.  But it’s like having multiple Dropboxes, with no size limitations…that you can share with your friends completely if you want.  The only catch is, and it’s both a positive and a negative, is because BT is peer-to-peer, it can only sync if another device is on and connected.  That’s good because your data doesn’t go in the cloud, but bad if you have a handful of mobile devices but nothing that’s usually on.

Yes, it’s the BitTorrent protocol, which has some negative connotations.  Security-wise, everything is 256-bit AES and the most an attacker could figure out is the IP addresses of the devices you use.  As far as the app itself, it’s not currently open source, so it may not be for the paranoid, but for the average joe it should be fine.

You can also use it from the mobile app to backup a folder – say you don’t want to use Google+ or Dropbox, or you’ve run out of space on them.  You can have it sync your pictures to your desktop, or anything else you might think of (app backups, rom image “just in case”, etc.)