My .gitconfig

Here’s my current .gitconfig file. It’s very simple, but it makes using git so much better. git s is a simplified git status, and git l is a log that shows one-line commit messages and a tree that shows where branches and merges were made.

[color] 
   ui = true 
[alias] 
   s = status -su 
   l = log --graph --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset'

I also highly recommend you check out the table below, which I’ve copied from the bottom of the 10 things I hate about git post. It helps make sense of some common commands that I thought were useless as well. Adding the switches Steve Bennett recommends clears things up a bit.

Base commandUseless functionalityUseful commandUseful functionality
git branch fooCreates a branch but does nothing with itgit checkout -b fooCreates branch and switches to it
git remoteShows names of remotesgit remote -vShows names and URLs of remotes
git stashStores modifications to tracked files, then rolls them backgit stash -uAlso does the same to untracked files
git branchLists names of local branchesgit branch -rvLists local and remote tracking branches; shows latest commit message
git rebaseDestroy history blindfoldedgit rebase -iLets you rewrite the upstream history of a branch, choosing which commits to keep, squash, or ditch.
git reset fooUnstages filesgit reset –hard
git reset –soft
Discards local modifications
Returns to another commit, but doesn’t touch working directory.
git addNothing – prints warninggit add .
git add -A
Stages all local modifications/additions
Stages all local modifications/additions/deletions

Swype beta on a Google Nexus 7

I’m writing this post using the Swype beta on my new Google Nexus 7 tablet. At this point, I am completely spoiled. I’ll never be able to go back to using a normal keyboard on a tablet device. I got used to Swype on my Droid 2, but this beta is even better than the version on that device. The speed at which you can enter text is simply amazing, and the suggestions it gives are really good. I really love the way it automatically gives you the ability to split words if you make a mistake by just tapping them.

Test IE virtual machines made easy

I just have to take a minute and thank @xdissent et al. for the amazing work done on ievms. I was able to install IE 6,7,8 and 9 virtual machines without hardly any work on my part.

I am running Ubuntu 12.04, and after uninstalling the virtualbox package found in the standard repository and installing the one found here, I simply ran the command in the readme, went to bed, and in the morning I was greeted with this in my VirtualBox window.

So far, each of them has worked without issue.

Comment on “There’s a hungry digital tiger waiting for us all . . .”

http://rebeccasnotepad.wordpress.com/2012/05/01/theres-a-hungry-digital-tiger-waiting-for-us-all/

Interesting read. Being in technology, I see this problem too. I call it “code rot”. If a program we’ve written sits on the shelf unused, it slowly becomes incompatible with the inevitable upgrades to our systems.

Open source software seems to be an exception to this. As Linus Torvalds, the creator of the Linux operating system once said, “Only wimps use tape backup: real men just upload their important stuff on ftp, and let the rest of the world mirror it ;)”

Unfortunately, solutions to the problem are hard to find. Popular things are saved, because they are useful, entertaining or valuable to people. Copyright and DRM (digital rights management) also get in the way of successful archiving as well. If someone is willing to save something digitally, or convert it into another format, many times it is actually illegal for them to do so.

Compile this into that

UPDATE: I made a mistake in thinking that RubyMotion compiled Ruby into Objective C. That was incorrect and is corrected in the comments below.

There’s a new trend I find very interesting. It goes like this; take some code in one language, and compile it into another.

Sometimes it’s a completely new language, like CoffeeScript, or Clojure. Other times it’s an existing language like changing Ruby into Objective C with RubyMotion, or Emscripten, which changes C++ into Javascript.

My initial reaction was that programmers are inherently lazy. We want our syntactic sugar. Those are the things that make languages easy to work with. There is nothing bad about this. Making things easy on ourselves is a good thing. We get more done, and the world is better for it.

Also, I lied before when I said this was a new trend. It’s actually been around a long time. No one writes assembly code anymore. C was a better way of expressing code, so we moved to that, and let the compiler do the work of assembling things into machine code. Compile-this-into-that; C into machine code.

But machine code is inflexible. Write once, run once. So, Java comes along and promises to fix all that with bytecode, and a virtual environment. Compile-this-into-that; Java into bytecode. Interpret with a JVM.

There’s also PHP and Ruby. It’s not strictly the same, but the concept is similar. No compile step, but you simply write the code, and then run through an interpreter, much like you do with Java. The interpreters are written in C. So, it’s not compile-this-into-that, but rather, interpret-this-with-that.

So, if this has been going on for a long time, why am I even bother to write about it? Well, the new trend is adding more and more steps, and I find it slightly disturbing. Compile-this-into-that-and-interpret-with-another. Like I said before if it makes us more productive, I’m all for it.

However, I think we may be writing compilers because it’s easier than evolving the systems we use. Examine that statement for a minute. Writing a *compiler* is easier? Why would that be?

My opinion is that it’s because standards are controlled by committee. Compilers are something one person, or a single group of people acting in concert can do. It’s kind of obvious, but I had to write it all down to get my head around it. We’re writing compilers because we can’t get our systems to evolve fast enough to keep up with our needs. We can’t get systems to evolve fast enough because our systems are bogged down by bureaucracy. Here are two lists companies that work on javascript. Ordinary Members, Associate Members. Many of those companies have competing interests, so progress is slow.

But, for now, it’s what we have. It lets us write in our favorite and most comfortable environment and get the benefit of making that code available in many places. And as long as the compilers write better code in the destination language than we do, why not? Anyone have opinions that differ? Let me know in the comments below, or on Twitter or Google Plus.

 

 

 

How to load test your web site or application with siege

Trebuchet
Time to storm the castle!

Your mileage may vary, but this worked well for me. I wanted to test one of our sites under load. Our sites generally get a lot of traffic, so when we move from staging to production we have to keep in mind that we’re about to go from 1 or 2 developers hitting the pages to thousands of people.

I’ve previously used Apache Benchmark (ab) to load test, but it’s fairly limited. It can only test one page. I did a bit of digging and found siege. It was perfect for what I wanted to do. I wanted to submit my site to a heavy load, over a long period of time, and see what happened. I also wanted semi-realistic traffic, and with a few well-typed commands, I was able to create a file that siege can read that contained *exactly* the traffic from our site.

I used this to read the last 1000 hits from our apache logs:

tail -1000 /var/log/apache2/access.log | awk '{print "http://mysite.com" $8}' > /tmp/siege-urls.txt

It’s pretty simple, but I’ll break it down. The following gives me the last 1000 lines from the log. Your log might be in a different location, or named something else. If you want fewer lines, or more lines, change the 1000 to something else.

tail -1000 /var/log/apache2/access.log

Then, pipe the output of the above to awk and print out the url. In our apache logs, the url was in the eighth position. I also appended the site’s domain to the output, since the apache log does not contain that information (at least not in the format I wanted).

| awk '{print "http://mysite.com" $8}'

Lastly, save it to a file for later use.

> /tmp/siege-urls.txt

Next, I used this file to place the site under load. In the example below, I used -i for “internet” mode, where siege randomly reads a line from the file and requests it from the server. I also used only 4 concurrent users or worker threads. If you ramp up the concurrency, you can really put a lot of strain on the server.

siege -i -c 4 -f /tmp/siege-urls.txt

When the siege is underway, you’ll get output that looks like this:

HTTP/1.1 200   0.53 secs:    6926 bytes ==> /some/url?some=params
HTTP/1.1 200   0.54 secs:    7132 bytes ==> /some/other/url?other=params
HTTP/1.1 500   0.13 secs:     521 bytes ==> /some/url?some=params
HTTP/1.1 200   0.64 secs:    7133 bytes ==> /some/other/url?other=params
HTTP/1.1 500   0.13 secs:     521 bytes ==> /some/other/url?other=params
HTTP/1.1 404   0.09 secs:     431 bytes ==> /some/url?some=params

I paid close attention to the 404s and the 500 errors. They indicated that I was getting requests that were erroring out for some reason. Sometimes, those errors are simply bots that grab a hold of old urls and continue to request them. Sometimes, they are cause for concern.

Hitting Control-C ends the siege and you then get output like below.

Lifting the server siege...      done.
Transactions:		         125 hits
Availability:		       88.03 %
Elapsed time:		       29.18 secs
Data transferred:	        1.18 MB
Response time:		        0.41 secs
Transaction rate:	        4.28 trans/sec
Throughput:		        0.04 MB/sec
Concurrency:		        1.77
Successful transactions:         101
Failed transactions:	          17
Longest transaction:	        3.13
Shortest transaction:	        0.08

I also found it useful to look at top and a few other tools on the server while the siege was underway. In our case, I was interested in passenger’s memory consumption, so I used passenger-memory-status and passenger-status.

Photo Credit: Martin AddisonDemonstrating the Trebuchet

I want… iOS vs. Android revisited

I wrote this post about my wishlist for iOS and Android over a year ago, and it’s due for a refresh.

iOS

  • Swype – it’s still missing. The keyboard on iOS is still much the same. The split keyboard showed up in iOS 5, but really nothing for my iPod touch. There is a
    hidden auto-complete suggestion feature as well, but it requires some crazy hackery to get it working.
  • Flash – ditto here. Although I’ve noticed the problem less and less. Sites seem to be more aware of iOS and it is driving them to use less flash. And honestly, that is a good thing.
  • Google Reader App – While there still is no native reader app for iOS, I don’t care anymore. The Google Reader mobile web experience has greatly improved over the last year.
  • Sync over Wifi – This one was a long time coming, but iOS 5 added it and I have no complaints. It works as advertised.

Android

  • Netflix – The Netflix app finally made it to my Droid 2 late last year. Again, it works as advertised and I have no complaints. One thing it did make me notice was the difference in quality of the screen. My iPod Touch’s screen is brighter and provides a more vivid colors.
  • Experience – I received an upgrade to Gingerbread late last year, and nearly all the experience issues have disappeared. On a rare occasion, the UI will seize, but at this point, my iPod does so as well, so it’s a draw.


Developing on the fly

If you see any weirdness for the next few days, please excuse it. I’m trying out MTV and doing some theme development without testing. The best way to learn something new is to use it for something, so why not make my own personal blog the guinea pig? If my experiment fails, I’ll just revert back to the theme I was using before.

UPDATE

I got it working. I had to make one modification to the core, as I am on shared hosting, and I have an open_basedir restriction. The code uses a folder in /tmp, and on my system, I have no access to it. I worked around it by placing the temporary files inside the plugin directory. Not ideal, but it worked.

There were a few problems with the example themes as well. The simple theme worked ok, but the twentyeleven theme was broken. I made some modifications and submitted them back through github.

Anyway, not everything works, but I’m calling it close enough for now. There’s no commenting (sorry), and search doesn’t work either. I did make the category and tag pages work. Before my changes, they were giving 404 errors.

WordPress as a framework

Found on builtwith.com

I use wordpress for this blog. I also use it at work. WordPress is a wonderful solution when you need a website or a blog and you need it *right now*. That is reflected in the fact that as of now (Oct 22, 2011), it runs 1/2 of the top 10,000 sites on the internet. That blew me away the first time I heard it.

In the last year or so, especially with the addition of custom post types, it has become quite flexible as well. It is fairly easy to pull together a quick plugin to add a new type of content to wordpress. At work, we’ve used custom post types to create things like candidate profiles and video galleries. However, wordpress starts to falter a bit when what you are trying to add doesn’t bear at least a small resemblance to a post.

I’ve heard it said that WordPress is a CMS that is trying to be a framework, so I’m always interested when I hear of projects that attempt to make it even more framework-like. MTV is one of those projects. Some developers at the News Apps Blog Chicago Tribune have recently released a plugin that makes WordPress act more like a true framework.

My main question at this point is the same one they themselves ask in their documentation. “Why?” I can understand it if you are limited to PHP hosting. I can also see it as a way to introduce framework-based programming to developers who are not familiar with frameworks like Ruby on Rails and Django. MVC frameworks can be intimidating, and this could be a way to introduce those concepts in a more familiar environment.

At any rate, it’s intriguing and is worth a longer look, which I will try to do in the coming weeks.