Unobtrusive onload Google Analytics with jQuery

Uncategorized 2 Comments »

Update: This post was live for about 5 minutes before Michael in the comments brought Google’s official asynchronous solution to my attention. That’s probably a much better way to go. I’ll leave the original post here as google bait though… ;)

I’ve gone ahead and moved the loading and execution of the GA javascript into an external file so as to speed up loading of the page and not delay firing of the onload event.

For every page you want tracked, make sure to include a div (or any element) with the id “ga-pageview-tracking” and include the javascript file shown below.

It’s fairly simple, and I’ve extracted the core of it into a single javascript file. I thought about uploading it to github, but it’s just so tiny.

(function($){
  var GA_ID = "PUT-YOUR-GA-ID-HERE";

  function gaTrackPageview() {
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    var src = gaJsHost + "google-analytics.com/ga.js";

    if($('#ga-pageview-tracking').length) {
      $.getScript(src, function(data, textStatus) {
        var tracker = _gat._getTracker(GA_ID);
        tracker._trackPageview();
      });
    }
  }

  $(document).ready(function() {
    gaTrackPageview();
  });
})(jQuery);

Web Entrepreneurship Presentation at KC Ruby

Uncategorized 2 Comments »

I had the privilege of speaking at the Kansas City Ruby User Group the night on the topic of Web Entrepreneurship. This is the second presentation along this subject. The first was an in-depth walk through how Jon Crawford went from a full time consultant to building his idea, finding his team, and putting his full effort into Storenvy. You can view his post regarding his presentation here: http://joncrawford.com/entries/web-entrepreneurship-presentation-at-kcrug.

Jon had many great points throughout his presentation and was to use those building blocks to discuss how follow entrepreneurs could build their online startup while keeping there day job. As I mention in the presentation, I love the experience that consulting provides, and given my already limited sleep schedule I find building my own startup during nights and weekends satisfies my hunger while also allowing me to keep the lights on. I definitely wanted to layout all the advantages, disadvantages, and discipline that a 60+ hour work week requires.

Web Entrepreneurship – While Keeping Your Day Job – Part 1


Web Entrepreneurship -- Ryan Felton -- Part 1 from Steven Chau on Vimeo.

Web Entrepreneurship – While Keeping Your Day Job – Part 2


Web Entrepreneurship -- Ryan Felton -- Part 2 from Steven Chau on Vimeo.

Slides

Update

Seth Godin gave a presentation today for Jelly Groups saying your going to burn out quickly. That freelancers are different then entrepreneurs. He mentioned that your goal should be to work like crazy freelancing to build up enough to live off when you quit your freelancing and switch to an entrepreneur. The major aspect issue with this (as mentioned in the presentation) is healthcare. Also, I recommend if you are going to take this approach prepare yourself to live as an full-time entrepreneur for 13 months as that tends to be the make or break period.

Rails, Textile, and javascript WYSIWYG roundup – part 2

Uncategorized 1 Comment »

In part 1, I examined a few of the editors and tried to give some plusses/minuses of each one. At the end, I mentioned markItUp! as a possible editor, but couldn’t make a recommendation due to lack of experience with it.

Now that I’ve used it, I can say definitively that it’s amazing! To be fair, it’s not a true “wysiwyg” editor and is instead a set of buttons and aides for editing some sort of markup language. However, if you are only looking for something that will make editing easier on your users, markItUp is perfect.

Skip the others and go straight to markItUp. You’ll be glad you did.

Tweet Less, Blog More

Uncategorized 6 Comments »

Goodbye Twitter

After playing with Twitter for a couple months now, I’ve decided that it’s really not all that useful as a way to express my thoughts and feelings. I spend a lot of time trying to come up with witty zingers, but nothing I say ever generates any real commentary. My gut feeling is that very few people actually read what I tweet, which is a little humbling and disappointing. More and more it feels like I’m screaming into an ever-more-crowded room filled with people screaming. We’re all trying to out-scoop or out-zing each other, in 140 characters or less.

Conversely, this blog has always felt like a calm, collected place where I can express my thoughts and interact with a small group of interested readers. The majority of my posts generate little traffic and zero comments, but I know they’re read by my close friends. However, I’ve had several blog posts that have generated a great deal of commentary. I provided some thoughtful analysis, and people felt compelled to comment (often after some baiting on Hacker News or Twitter). The readers learned from my experiences, and they added their thoughts. The postings remain visible and can be easily found via Google. Finally, many of the posts still generate traffic and comments even months or years after the original posting. Try getting response to a tweet even 6 hours after the original posting.

For these reasons, I’ve decided that I’m going to reduce my time spent on Twitter and instead try to collect my thoughts into real, thoughtful writing. If I feel the itch to go tweet about something shiny, I’m going to ask myself if it’s something that I really think people care about, or am I just acting under the same impulse as the people who write “First!” in comments on Youtube. I’ll still succumb every now and then, but I think I’m over Twitter.

Update: I’ve also found that going on a massive un-follow campaign can vastly improve your Twitter experience. Clear out all the cruft: celebrities, brands, logos, and especially the chatty egoists who never shut up. Once you pare it down to just friends and a handful of personalities, Twitter is much more enjoyable.

My New Year’s Resolution: Don’t be a douche

Uncategorized 3 Comments »

So the time for reflection and has come once again, and I’d like to make a simple resolution: Be less of a jerk on this blog and be more constructive.

Reading back through some old posts, I see that I’ve become prematurely curmudgeonly. I also tend to judge too quickly, and am then forced to recant and eat crow. Since I’m not a fan of the taste of crow, perhaps I should hold my tongue for a bit and try to come up with something useful to say, rather than trying to be snarky and clever.

So, here it is:

I, Micah, will be less of a douche.*

* Offer only applies as it pertains to this blog. Author will continue to commit douchebaggery in his real life, especially while riding his bike because that makes him better than you.

git the fsck out

Uncategorized 27 Comments »

Update: (later that day…) A full stomach changes everything. Getting some breakfast lessened my git hatred quite a bit. Still, it manages to irk me on a daily basis, and I hate people who make their ill-thought-out blog posts disappear, so I will leave my hate-filled rant for posterity and a warning to myself not to post before I eat breakfast.

Update 2: (Feb 2010) I’ve been meaning to update this for a long time. I’m a 100% convert to git now. I’ve had my religious epiphany. I couldn’t understand how great it was at first, but over the past year I’ve finally wrapped my head around it. So, to all you haterz out there like me, just keep persevering. The light is there at the end of the tunnel. Now, back to the original rant…

Ok, I’m angry, so I’ll go ahead and make a ranty, heretical statement:

I hate git!

But wait! Micah, aren’t you the ultimate Rails fanboy? Don’t you jump on the bandwagon for everything the rest of the Rails lemmings do? RESTful routing? .html.erb instead of .rhtml?

Yes, in general, I do follow all the other Rails conventions and try to stay on the bleeding edge. I hate to feel like I’m falling behind, and that’s an easy feeling to get in the Rails community. So, I try to follow all the trends and at least educate myself on what it means and how it works. In most cases, like being RESTful, I eventually come to understand the underlying concept and appreciate the change. Learning new things often involves suppressing your own skepticism and the urge to stick to the known path.

So how is git different? Well, I’ve been using it for a few months, and the list of cons just keeps growing, while the list of pros stays nice and small. Sure, it’s fast, merging is dead simple, and I can scoff at all my friends still using subversion. But, every single time I want to do something, I have to look up a whole slew of commands. Why can’t I just memorize them? Because they’re horribly arcane and obtuse.

Want an example? Try deleting a remote branch. This seems like something one would do often, after merging a feature branch into the master. However, rather than using something simple, like “delete the remote branch”, you have to cast some arcane spell. For me, deleting a remote branch involves Google, every goddamn time.

The spark that set me off today was my attempt to connect to multiple repos on Unfuddle. For organizational reasons, I need to have multiple user accounts. Juggling usernames and passwords is bad enough. Luckily, they’ll allow me to use the same OpenID for both accounts. Still, when I tried to add my public ssh key, it complained that you cannot use the same public key for two accounts. Apparently, Github has the same policy.

Well, that was two hours ago, and I’m still trying to figure out how to get git to use my shiny new ssh key that is not named id_rsa. A little stumbling around got me some instructions on Github, but right at the top it says that it’s not an ideal solution and should only be attempted by advanced users. Hmm, using multiple different keypairs for different source control repositories does not exactly sound like an advanced feature. Do they recommend we use the same password for all our websites as well? Seems like a pretty basic concept to me.

Update: I was called “borderline retarded” in the comments for blaming git for the policies of github and unfuddle. Harsh, but true. I conflated git with hosts who provide git, and that’s not fair. So, github and unfuddle, my anger shifts to you!

Further, the recommended solution requires editing configuration files for ssh. So, I have to be an experienced ssh user to use git effectively? That’s ridiculous. Seriously, how many developers ever modify their ssh settings? I’ll muck around in git config files without worrying too much. Change settings in ssh without extensive research? Forget about it. Mess that up and you’ll lock yourself out of your machine, or worse, open it up wide to script kiddies who know more about ssh than you.

From a usability perspective, git sucks, and that’s that. If anyone feels compelled to defend git, please do so in the comments. However, don’t tell me how to do the things I’ve bitched about here. Tell me why it has to be so goddamn hard. To make an analogy, it reminds me of the Rails vs Java mentality. Java web apps are horribly convoluted. Sure, you can write tons of arcane XML and eventually maybe get your WAR deployed into Tomcat correctly. But why? Why waste time on this crap when it can be so much easier? Why spend minutes and hours trying to understand the obscurities of git when subversion, the ugly stepchild that it is, is still easier to use?

Subversion has its problems, but dear God why did the Rails fanboys have to jump to a worse solution? Now, in order to keep my certified fanboy card, I need to spend my precious development time tinkering with git, and then writing blog posts about how much I hate it.

You’re asking the wrong question

Uncategorized 6 Comments »

I had lunch with a friend the other day, and he pitched me an idea he had for an iPhone/Android/whatever app. When he was done, he asked, “What do you think?” Without thinking, I answered with, “Hmm, sounds neat. Cool idea.” He told me that’s what everyone said. It was then that I realized he had asked the wrong question. Instead of asking, “What do you think?”, phrase it like this:

“Tell me why this idea sucks and will never work.”

Friendly Optimism

If you’re asking friends (or even just generally polite people) about your idea, they won’t want to hurt your feelings. They can tell you’ve got a lot of enthusiasm and excitement tied up in your idea, and it would be a real jerk move to throw cold water on that. So, they answer, “Cool idea!” or perhaps “That’s neat. You know what else you could do?” Very few will give you real, jarring, critical feedback. Instead, they’ll try to be good friends and cheer you on. Unfortunately, you need a reality check, not a cheering section.

Ask to be bruised

If you make it clear that your goal is to get real, unbiased feedback, you pave the way for someone to be honest without seeming rude. In addition, if you explicitly ask them for negative feedback, they will be pressed to come up with specific criticisms, instead of vague encouragements.

Once the truth starts flowing, take some notes and ask for more. Resist the urge to get defensive and just let your reviewer express their opinions. Once they realize that you’re truly appreciative for the beating they’re giving, they’ll really start to build up steam. Thirty minutes of this can generate some truly exceptional insights. You may think you know what sucks about your idea, but others may be able to poke holes in it you never imagined.

React and Adapt

No idea is perfect, and your job as an entrepreneur is to overcome and adapt to the imperfections in your idea. If you can’t recognize and counter your own weaknesses, then your success will be severely limited. It’s nice to get a pat on the back every now and then, but it’s absolutely necessary to get raw, unfiltered criticism. Very few will give this freely, so it’s up to you to drag it out of them.

Atlanta Startup Weekend 2 – Better, but I still quit

Uncategorized 6 Comments »

I attended ASW2 this Friday, and while I enjoyed it much more than last time, I still decided not to return on Saturday and Sunday. Consider it a mixture of laziness and desire to work on other stuff.

Update: Just to be 100% clear: I think ASW2 was a good time, I just had a lot on my plate. The main reason I quit is because weekends are the only times I can work on my own startup stuff, and it’s a big investment for me to spend that time on other pursuits. I’m glad I went on Friday, and if I had more free time I might have stuck it out. But, all things equal, the TODO stack for Obsidian Portal doesn’t shrink on its own.

My Pitch: Get Me A Date


Atlanta Startup Weekend – Get Me A Date!

Using Amazon Mechanical Turk, do human reviews of dating website profiles to help people look their best.

Charge a flat fee of $10 for a review. This gets farmed out to two MTurk workers for a rate of $3 each, leaving a profit of $4 for the service. The MTurk workers review the person’s profile and give specific, personal criticism of their photo and bio.

Each review is 100% satisfaction guaranteed. If the customer is dissatisfied, they get their money back…and the MTurk worker doesn’t get paid! Over time, MTurk workers get better, to the point that they can churn through the reviews and make $30-$40/hr, all the while earning money for us!

Essentially, it’s an excuse to play with MTurk. I think MTurk is a fascinating idea, and there are some really cool things that could be done with it, assuming the workforce is steady and high enough quality can be ensured.

Get Me A Date made it to the top 5 (out of about 30 ideas), but when the time came to pledge support for a project, only my new friend John stood up. So, we disbanded and moved to Giving Time.

I spent a little time with the GivingTi.me team, but eventually decided to quit. I liked the idea and the opportunity to work with some new people, but there was one person on the team who really rubbed me the wrong way. Chris wanted to run all the conversations, and seemed to think very highly of himself due to being a CTO of a local startup and having an MS in Software Engineering from Tech. Well, I’m also the CTO of a startup (I give myself titles for AisleTen whenever it’s convenient) and have an MS in Artificial Intelligence from Tech, but I don’t think that’s really all that relevant at Startup Weekend. Skills and personality are important, not titles.

When I was asked if I would be there Saturday morning, and I said no, Chris asked, “Is it because of me?” Rather than play it down and be nice, I was blunt and said yes. If I’m going to spend a weekend hacking away on a never-make-money project, it had better be with people I like and respect. Why spend your free time getting bossed around and talked down to? At the time, I declined to elaborate, since there were about a dozen people in the room, but I am proud of myself for being straightforward and honest.

Ultimately, I didn’t find any of the ideas all that compelling. Plus, I’ve been tweaking some stuff on ObsidianPortal, so that’s where my heart is at the moment. It’s hard to concentrate on something when you wish you were somewhere else.

Anyways, I wish everyone the best, and I hope some good stuff comes from the weekend. I know I’ll be working on Obsidian Portal most of the time, so it’s still a startup weekend for me. :)

Micah’s Mad Skillz at Photoshop

Uncategorized 2 Comments »

I’ve never pretended to be good (or even decent) at Photoshop. I just don’t have the eye or the patience for it. All the fonts look the same to me, the only colors I understand are ROYGBIV, and things just never seem to line up.

That being said, I’ve always wanted to get better. Lack of design skill is a major hole in my web developer skillset. So, whenever I get the chance, I try to grit my teeth and force myself to learn something new.

Behold, my latest creation:

Disgusting, huh? Check out my new campaign, and follow along with these morally impure creatures.

Amazon EC2 further thoughts

Uncategorized 2 Comments »

It took longer than I’d hoped, but I finally got map tiling moved over to EC2. For a celebration, I thought I’d write a follow-up to my EC2 first thoughts.

The Problem of Persistence

I knew that EC2 instances did not maintain state after being shut down, but I didn’t think it would be a big deal. Shows what I know.

Dealing with a machine that forgets itself every time it spins down is very difficult. Want to add a new apt package? Install a gem? All is good until you flip the power switch and then it’s gone. The obvious and recommended solution is to persist your data in S3. In my case, I chose to do this by re-bundling the image every time I made a change. I had to do this probably 4 times, and while not difficult, it sure was tedious.

Trying to plan ahead, I even added an svn update to our tiler script startup, so as to get the latest code from subversion each time the instance spun up. A few days later we decided to move to git, meaning I’ll have to add git-core to our image and then re-bundle it to S3. Again, more tedium.

The other option is to keep a base image, and re-install all your packages and add-ons on each startup. This is the philosophy of ec2onrails. Each time your instance spins up, you install any number of apt packages and gems via remote ssh script.

Ultimately, I decided against this option for our map tiling. Considering that I expected each instance to be up for an hour only, and that users were waiting for their maps, I wanted to minimize startup time. So, it’s bundle, add something I forgot, and re-bundle.

Keeping track of it all

If you’re planning on lots of starts and stops, you’re going to need a way to handle it automatically. The grempe-amazon-ec2 gem makes the actual commands fairly painless, but you’ll need to store and track the instances you’re running.

One option is to directly use the EC2 gem. While fairly easy to use, dealing with the resulting XML each time gets to be a pain. So, I went ahead and created an ec2_instances table and tracked our instances in the database. We store the private key, instance id, startup time, current state, and a little extra info as well. Using all this (and updating it periodically) allows us to track and manage our instances, making sure that we’re shutting down each one we spin up. Our nightmare scenario was a runaway startup loop that ends us with 1000s of idle instances, but it looks like I programmed it pretty well. If I’m wrong, I’ll have to sell a kidney when our EC2 bill arrives.

Who’s in Charge?

So once you get your instances spinning up, it’s time to decide who’s in charge of starting the work. In our case we had a tiler daemon we wanted to run. The obvious choice is to put a script in /etc/init.d and set it to run automatically on startup.

However, since I like to make things hard, I decided to use a script that would ssh in and start the tiler from there. It gave me a chance to play with the ruby net-ssh library and learn a little about public key authentication.

Theoretically, since we create a private key for each instance we spin up, we should be able to ssh in using this key. If I use OpenSSH from the command line, everything works great. Unfortunately, there’s a bug in net-ssh that requires you have the public key in addition to the private key, making it useless for my purposes. So, I gave up and went back to using password authentication.

Anyways, we had to decide who would be in charge of determining when to spin down an instance. Originally, I intended for the tiler daemon to handle this itself. but I got a little spooked. If the daemon crashed out, the instance would never shut down, and we’d be dropping $2.40 a day for an idle machine.

To combat this, I added a cron job on our main web server that manages the EC2 instances. Every 5 minutes it checks if we have a tiler instance running, and shuts it down if it’s idle and our hour is almost up. It turned out to be a good choice, although the tiler daemon has yet to error out, so either way would have worked well.

Estimate, Multiply by 2

My overall impression of EC2 is very positive. It’s much more complicated that S3, and even FPS, but I suppose that’s to be expected. Considering the incredible flexibility, a little complexity is unavoidable.

When determining how much time it’s going to take you to do something new with S3, estimate and multiply by 2. There are lots of little steps and new things to learn, and tying all the pieces together ended up taking much more time than I expected. Still, I’ve come out with a good understanding of EC2, and now I’m itching to find a project that would allow me to leverage the true power of on-demand cloud computing.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in