Archive for the ‘Geek’ Category

Posting Code Examples Using Gist

Thursday, January 8th, 2009

The folks over at Github have been making quite a stir in the open source world. A lot of major projects, including Ruby on Rails have moved to it, and with good reason. Git is a very powerful source code management tool, especially for open source projects. Github has helped git grow in popularity by leaps and bounds by giving people a place to host projects simply, without having to learn the intricacies of hosting a git repository. On top of that, they’ve provided many tools to aid in collaboration and history viewing.

But github isn’t what I want to talk about today. Today, I’m going to talk about gist. Gist is a new pasting service from the good folks at Github. For those of you unfamiliar with what that means, a pasting service is a tool for posting snippets of code or plain text quickly and easily online for sharing. I use this service regularly for sending someone an example of how to do something that would be too cumbersome to type into my chat client. It’s also extremely useful for posting snippets of code up when asking for help on a message board or IRC channel.

What makes gist special over many of the other pasting services I’ve used before - aside from its clever name - is that it’s based on git. Each gist(pasting) is actually a mini git repository that you can clone(checkout) and make changes to, etc. It’s a very clever idea, and quite useful.

Another really sweet feature of gist is that the site provides javascript based embedable tags that you can drop into your own websites that will display the code snippets, properly formatted and with syntax highlighting. Getting sample source code to look good on this site has been something I’ve struggled with since I first started blogging. I’ve used all kinds of formatting plugins, used features in TextMate that produce a nice result but use an insanely unmanageable amount of markup. I’ve even just posting links to other pasting services before.

This is so much easier:

Freshbooks for iPhone

Thursday, October 23rd, 2008

A while back, I posted some screenshots of an iPhone app I was working on for logging time to Freshbooks. Things kinda fell silent for a while and the app never released. The reason for that was that the app was picked up by Freshbooks. We jazzed up the UI and added the offline submission support. I’m proud to announce that it’s available now from the iTunes store for FREE.

Product Page
App Store

Scrollbox.js now on Github

Friday, September 26th, 2008

In order to make it simpler for others to use and modify this library, I’ve decided host this library on github. I’ll still be keeping an info page up here, but future work will be done on github. The reason I chose github is because git makes it easy to track forks of a codebase. If you use my library and want to make changes to it, you can simply fork from within the website. The fork will reference back to the original project and you can even submit changes to be incorporated into the original codebase (with my approval).

If you like this library, but find that it doesn’t quite do what you need, please feel free to fork and modify. I’ll be happy to incorporate any additions that others will find useful.

Checkout Scrolbox.js on github

It’s Time to Touch

Thursday, July 24th, 2008

Yesterday, I caught myself poking at my laptop screen three times. With the addition of NetNewsWire and OmniFocus, I find myself using my iPhone more and more even when I’m at my computer. One of the unexpected side effects is that not being able to touch my screen suddenly seems rather strange. This is especially true when moving between the iPhone and my Mac. All those delicious little app icons in my doc are just begging to be touched. The little exposed corner of my iChat window under Safari begs me to poke it.

I don’t think touch computing is going to replace the mouse just yet, and we’re certainly not ready to give up our keyboards, but hasn’t the time come for us to be able to touch our screens. If you can find somebody who’s never used or observed a computer before, sit them down in front of your machine. Ask them to click on something or move a window. I’ll bet you they don’t reach for the mouse. The most natural way to interact with the spacial metaphor of windows is to touch them.

It doesn’t matter if you’re sporting dual thirties or a svelte thirteen point three, chances are, you’re using all of the real estate and more. Far too much time is spent moving panels around to get what you want in front of you. The mouse is just not the right tool for the job. It’s too limited. You have to find the point you want to drag, find your pointer, move your pointer to the point you want to drag, then move the window. The problem is even worse for drag/resize maneuvers. Studies have shown that there is a marked productivity increase associated with having a larger display. This is because it reduces the amount of time you have to spend organizing your windows.

Styluses suck. We don’t need them. They’re not the answer. We need sexy glass surfaces that respond to our fingers in the most natural way possible. Apple has already taught us several multi-touch gestures with the iPhone. There’s no reason they can’t translate directly to the OS X windowing system. Touch and drag to move windows. Pinch to resize. Tap to click. That’s all we need to start with. From there, you can expose the stuff to the application and let apps do clever things or do nothing.

The world is ready. We have the technology. Let us have it.

New Xbox Interface

Wednesday, July 16th, 2008

Yesterday, at Microsoft’s E3 media briefing, they announced a completely new interface for the XBox 360. It’s a bit disappointing to me, actually. It seems a whole lot like the kind of unoriginal, “me too” crap I’d come to expect from Microsoft, but not Microsoft Games division. First of all, they’ve dropped the “blades” interface which I rather liked. They’ve also dropped the gamer image in favor of an “avatar.” The first thing that comes to mind is “what happens to the skins and gamer pictures that users have payed real money for?”

The new “avatars” feature sure seems a whole lot like Nintendo’s Mii functionality. The major difference is that Microsoft’s version seems to be much less flexible. It looks like you’ll be buying new outfits to customize your characters. So, the gamer pictures you just purchased are now unusable, but Microsoft is generously providing new worthless content for you to buy. I never actually spent money on this content, but it’s very upsetting to see Microsoft just nuke paid content without providing the user with any options.

The one feature I’m happy to see as part of the new update is integration with Netflix. It will be nice to have an easy way to use the Netflix streaming functionality on my TV.

Backing up with S3

Sunday, July 6th, 2008

Last night, I threw together a little script for backing up content from my web server to Amazon S3. It’s not really feature complete, but it is good enough for what I need for now. It provides a very simple DSL for specifying what content should be backed up.

Download it here.

To specify content:

backup :foo do
  folder '/path/to/stuff'
  folders ['/path/to/things', '/path/to/blah']
  file '/path/to/allyourbase.rb'
end

Will produce this in S3:

-{date stamp}
  -foo
    -stuff
      -..content of stuff
    -things
      -..content of things
    -blah
      -..content of blah
    -allyourbase.rb

The idea is that you could have one backup block for each site (notice how the symbol passed to the block becomes the root folder). You could backup all the different parts of the application under one umbrella without having to worry about any collisions with other apps.

You’ll need the ‘aws-s3′ gem. To deploy this on your server, just put the files somewhere on your server, modify the configuration in the run_backup.rb script and point a cron task at it.

Proper DSLs

Friday, July 4th, 2008

Dave Thomas wrote a great article describing a troubling fad in Ruby development. Specifically, he addresses DSLs - Domain Specific Languages - that try too hard to look like English rather than trying to cleanly describe a problem domain. I’ve always had a distaste for things like RSpec and AppleScript, but had a hard time describing exactly why.

Ruby makes it easy to create a domain specific language and many of the existing ones make the language particularly compelling. Rails migrations are beautiful in their elegance and descriptiveness. Rake is a joy to use compared to most build systems. XMLBuilder is a very sexy way to build XML files. The things that I feel many new rubyists fail to grasp is that these DSLs are not trying to be English. They are trying to create a simple and clear way to solve a specific problem while adding as little unnecessary cruft as possible. Most importantly, they all remember the difference between code and human language. A good DSL is unapologetically code.

Search Wikipedia from Google

Friday, June 27th, 2008

I often use google to search wikipedia with keywords like “wikipedia little endian.” I discovered on accident this morning that if you just type wikipedia, Google actually supplies a search box for wikipedia within their result set. Pretty cool. Is this new? Is it just for wikipedia? Is there an API for defining this?

Why You’re not too Smart to Switch to Mac

Thursday, June 26th, 2008

Somebody over at Gizmodo published an article on why he still uses Windows. He begins by saying that he’s “too smart for Macs” (emphasis his). No, dude. You’re not. Let’s go through your arguments one at a time and see what’s really what.

The first argument, “I’m a monster on Windows” has merit. If you’d expanded on this a little and let that be it, I’d have left you alone. If you’re comfortable and really productive on an OS, there’s really no reason for you to make the switch. You might find that you’re more productive on another OS once you get over the learning curve, but I’ll give you this one.

The next section describes how Macs used to be utter garbage. This is a statement I agree with. Mac OS and even OS X wasn’t always as awesome as it is today. But it is awesome today. Who cares about what it used to be. Windows used to be better. It’s not today. Welcome to the present.

The next section tries to make several points, most of which, are utterly misinformed. PCs are better for games. Agreed. “Windows is an OS that feels structured and it makes sense just because I’m used to them.”(sic) There’s always a period of getting used to something new. This is the same as the first point. Macs feel dumbed down. You can’t tinker or access low level system stuffs. Mac OS X is based on BSD Unix. I would argue that it’s more flexible/tweakable, though, fewer changes are necessary to get acceptable performance. There aren’t as many apps. True. But it’s not like it used to be. There may not be as many, but there are plenty, and they’re usually better. Limited hardware choices. The Mac Pro is very expandable. If you really want to build your own machine, and that’s more important than actually using the machine, I have nothing more to say to you. Nowadays, most people buy laptops, and nobody is really making laptops designed to be taken apart.

Next up, we have a section about the founders of the companies. This is irrelevant. It’s worth mentioning, however, that even Bill Gates thinks Windows sucks. This is followed up by a section about how Macs are too cool. This is another irrational decision that has nothing to do with the actual platform itself.

The last section is a gold mine. “The main reason I still use Windows is this: I’m stubborn and lazy.” Not too smart, too stubborn and too lazy. I believe that. “I don’t want to switch because it will amount to admitting that I’ve been wrong for the last 15 years or so.” First of all, so fucking what. I thought you didn’t care what people thought? What happened to “My computer is not a fashion statement”? Second, you don’t really have to admit anything. Windows used to be better. Now Mac is. You weren’t really wrong. I got razzed a little bit when I made the switch, but I’m still glad I did. There’s some more stuff about not wanting to learn something new. It takes about two weeks to get acclimated to the Mac. Ask your pals over there at Gizmodo for a few app suggestions to replace your Windows tools.

Get yourself a review MacBook Pro and use it for a month or so. You won’t want to give it back.

It doesn’t bother me so much that this guy uses Windows. If he’s comfortable, productive, and happy with it, there’s no reason to switch to something else. The thing that bothers me about this article is how ignorant most of his arguments are. In 2001, I would never have imagined myself using a Mac. The people over there have made some amazing achievements since then. I’m irritated when people compare today’s Windows with 1998 Macs and say they’re better. We should be looking at today’s realities and tomorrow’s prospects.

Smooth Scrolling with ScrollBox.js

Thursday, June 26th, 2008

Somebody wrote an email asking for a good way to do smooth scrolling with my scrollbox library. If you have some code that will do smooth scrolling on a div, you can use it. The scrollbox will watch what’s going on and automatically update the handle as well as its internal state. If you’re looking for a good solution, here’s a simple one that uses scriptaculous.

	Effect.SmoothScroll = Class.create(Effect.Base, {
		initialize: function(scrollbox, options){
			this.scrollbox = scrollbox;
			this.options = Object.extend({
				to: scrollbox.scroll_pos,
				from: scrollbox.scroll_pos,
				duration: 0.5
			}, options || {});
			this.start(this.options);
		},
		update: function(position){
			this.scrollbox.scrollTo(Math.round(position));
		}
	});

If you have already created a scrollbox like this, var sb = new ScrollBox($('somebox'), {auto_hide: true});, you could trigger a smooth scroll like this:

	//scroll to the top over half a second (the default duration)
	new Effect.SmoothScroll(sb, {to: 0}); 

	// or

	// scroll from top to bottom over 5 seconds
	new Effect.SmoothScroll(sb, {from: 0, to: sb.scroll_max, duration: 5});

You can embellish this with any of the other scriptaculous goodness you see fit. I noticed when testing this that it automatically applied a nice ease in/out effect to the timing of the scroll. Pretty sweet.