http://www.youtube.com/watch?v=zGt3-fxOvug&feature=player_embedded
It's time to buy new shoes
My current New Balance 574's from 2003 are in really bad shape. I think it's time to replace them. These are the models that are in the running:



My current New Balance 574's from 2003 are in really bad shape. I think it's time to replace them. These are the models that are in the running:



Organizing an app for fast access to all it's features and information is so important, yet often overlooked or skipped. With Daypack, I want to make sure that it's easy to get from any one place to any other place - not just by limiting the number of taps, but also by avoiding any confusion.
Luckily, Basecamp is a well organized application.
This can even be seen in how ActiveRecord works with Rails (if you are familiar with it). Rails was definitely made to make Basecamp.
In Basecamp, there are a number of key objects to keep track of, all of which relate to each other in a number of ways. In database lingo, one might say that an Account has many Projects which in turn has many Messages. Thinking this way, one could arrive at a tree structure to show what belongs to what:
This is all very straight forward except for the fact that People show up twice. Since a Person can be related to more than one project, there is a list of all people across all projects and then just people in a certain project.
There is also the possibility of an overview or activity feed for the entire account as well as each project, which could be useful to see recent changes and posts and the like. Also, some users will actually be logging into multiple accounts, so it should be easy to switch from one account to another.
In the iOS SDK there are Navigation Controllers. These are simply just a way to represent a list of things that might link to another list of things - which sounds perfect for this type of problem.
This is actually the exact problem the iPhone solves beautifully: drilling down into content through a hierarchy.
Using our tree hierarchy from before, one could navigate to a specific message by:
Not bad and pretty straight forward. If, later, they wanted to see a message in a different project, it might go:
In a followup post, I will show some mockups and discuss data modeling in iOS.
HTML5 introduces a new, standard way to store data in your html source that is invisible to the end user. Here is an example:
<li><a href="#" data-id="1">One</a></li>
<li><a href="#" data-id="2">Two</a></li>
<li><a href="#" data-id="3">Three</a></li>
This is setup to link each list item with a record in a database, but you could create your own attribute for the max and min sizes of a cropped image, the username of the uploaded user, anything. It would just be <p data-user="nathan">Nathan Herald</p> and there you go.
It's easy to get to from Javascript and easy to write into the html for both a human and a computer. And it works in IE!
Please, use this now. No more abusing classes and id's to reference things that have nothing to do with the actual information's structure.
Reinventing the ATM.
For a while now I have wanted to make iPhone apps. I have actually already created two, but they will not be released. They are not up to my standards, mostly because of API limitations or speed concerns.
However, there is one app that I think could be a great challenge while also being something I would use daily. The idea: an app for Basecamp.
Daypack would be everything one needs to access and deal with Basecamp while away from the computer.
There are already plenty of Basecamp iPhone apps out there now and all of them suck. Most are slow, unorganized, and just don't make using Basecamp easier than the regular website.
The two areas that I want to focus on are: speed and IA. If those two problems ever got solved (to some definition of solved), then I would focus on search, but that might never happen.
As I work on this idea in what little spare time I have, I want to post all my ideas, sketches, comps, and anything else on this blog. If it ever materializes as a real app then I will release it for sale in the store.
Over the next few days I will try to detail my current progress with the IA and my ideas to make it hecka fast.
If you're interested in helping or have any feedback or even want to tell me what a bad idea this is: always feel free to contact me.
I needed a quick way to grab the path from the front most finder window.
alias cf=copy_finder_window_path
function copy_finder_window_path() {
osascript <<END
tell application "Finder"
set the_folder to (the target of the front window) as alias
set the_path to (get POSIX path of the_folder)
set the clipboard to the_path as text
end tell
END
}
alias gf="cf && cd \`pbpaste\` && clear && pwd"
A new typeface that is supposed to "fix" Helvetica and make it even better? I am interested.
After reviewing zoomed in specimens of the typeface, I don't like the character they added. The way the lowercase f and t curl a bit, the way the s seems more playful. And yet, they take away the uniqueness of the a and the R. Weird.
It actually seems further away from what I would want it to be.
(Note: the article body on the CR site is set in Helvetica Neue, the already improved Helvetica.)
I think I really need one of these. I might even be able to set it up to make my trackpad a really small tablet.
Making custom google map tiles from a master png:
convert -crop 160x160 full.png tile_%d.png
It numbers the tiles sequentially, so a tile at position 1,1 in a 2x2 grid will be tile_3.png (it starts numbering at zero).
Calculating the tile number is terribly easy:
(coord.y * 2^zoom) + coord.x
Where 2^zoom represents the maximum number of tiles across. (At zoom 1, there are a max of 2 tiles across.)
I love vim. It's pretty much awesome and can do pretty much whatever you can figure out how to tell it to do. While MacVIM solves most of my qualms with vim (making sure ⌘+S works, etc), I still have a few things that just don't feel right at all. If you know how to solve any of these issues, let me know.
# =>Since vim is so customizable, I am sure I could fix all of these things (and more), but I am currently stumped on these things. If/when I figure them out I will update my vim-config on github.

The A List Apart Article about Holy Grail Columns is still a great resource for building columns where the main content is first in the source, but everything lays out and remains flexible.
However, after reading about the Flexible Box Layout Module and looking through some examples I figured it would be easy to do the same without using floats and all that crap that was never intended for columns anyway. I was right.
It is terribly easy to setup.
First, just tell the wrapper div that it's to behave like a box and that it's children should layout horizontally:
#columns {
display: box;
box-orient: horizontal;
}
Note: I am not showing the -moz and -webkit prefixes, but they are included in the demo page's code.
Secondably, let's make sure my columns show up in the correct order:
#center { box-ordinal-group: 2; }
#left { box-ordinal-group: 1; }
#right { box-ordinal-group: 3; }
That's freaking simple. Thirdly, let's add some width's to the left and right:
#left { width: 200px }
#right { width: 150px }
And lastly, let's make the center column "flexible":
#center { box-flex: 1; }
And that's it. Take a look at the demo.
This assumes you have the Develop menu shown and know how the Inspector works.

Right click on a part of the text and choose Inspect Element.

Click on a div with the class="page".

Find the CSS rule for .page and uncheck the text-align: justify; rule.
Tomorrow: make an extension to do this automatically.
My goal is to create products that people love.
I think I just realized this fully today. There are things that are not alive, not people, and may not even really change my life so much and I love them. Sometimes the word adore may even apply.
This is why I want to create content management systems, ecommerce platforms, reusable tools, and other internet related things. I also catch myself wanting to design clothing, bags, storage solutions, and other things that I interact with often. If I can't find something I love then I want to make it. I, apparently, desire to desire something.
Not that Shopify or Expression Engine are bad, but I just don't love them like I do my iPhone or my hat. I actually really enjoy using both of these products, it's just not a full affair type thing. Tons of products are in this "like but not love" category, physical and virtual.
I remember loving my old 3rd gen iPod I used in college. Everywhere I went it went with me; it put me to sleep, woke me up, went for walks with me, and kept me focused when working on school work. So many other examples exist in my past: old laptops, shoes, shirts, etc.
I know everyone can think of a product that they miss or still have a deep affection for. A toy or computer or clothing item or something that they really loved.
A consistent thread running through the objects that I seem to fall in love with is a combination of beauty and utilitarian design. A balance between being terribly useful and practical while being awesomely intuitive and usable and pleasing to the eye seems to be very important to me. I see examples of this everywhere in my house: iPhone, Puma shoes, white fitted hat, front pocket wallet, G2 .5mm pens, moleskins, and many more.
The newest item that I have fallen for is my new Soto OD-1R burner. The little dude performed awesome for boiling water (< 2 minutes for a small kettle) and cooking. The way the supports fall into a locking position, the auto regulation of the fuel to maintain a consistent flame, and light weight really make my appreciate how well it works even more.
Not that this is new or anything, but going forward, I want to only make things that cultivate a love and affection from the people that use or consume them. I see this everywhere when people wear Expression Engine t-shirts, have Apple stickers on their car, and are willing at any time to sell their friends on the awesomeness of things.
My desires may be selfish. Not so much to make money, but more to have a sense of impacting other people in the world.
I want to make love more than make money.
(Hmmm, I think I'll just leave that last sentence as is.)
Honestly, I don't know why my site was down. Dreamhost must have changed something, because I haven't touched the files in months.
Either way, I added a require 'yaml' line and that fixed it. Maybe they upgraded some gem or something and it doesn't include yaml. I'm sure a Gemfile and bundler would fix this sort of thing, but man that would require me to do something.
Expression Engine template html snippet:
<body class="{if segment_1}{segment_1}{if:else}home{/if}">
Very useful to namespace each url and for showing parts of the nav as "current."
Did you know you can use a scanner wirelessly?
If you are involved in the web industry in the least bit, then you must read this.
Trying to help a friend.
It's been a while since I did any video stuff. We'll see if this works out alright.
In the next few years, consumers will decided if mobile devices should be more like a Playstation or more like a Windows "regular computer."
Apple is betting on the Playstation model. You buy it, you plug it in, you use it how they say you can. If you want your own little button to show up on the screen, you gotta deal with them. You can only do what it was made to do.
Google is betting on the regular computer model. You can install anything and manage processes and run compilers and build toolsets and everything right on the device. You can do whatever you want.
Neither approach is "correct," it's just two ways to try to solve the same problem.
Apparently geeks hate Playstations.
I don't think Apple is doing the "right thing" by saying developers have to use Objective C as the starting point for every app; however, did anyone make a big stink when only HTML+CSS+JS could be used to make Palm Web OS apps?
Sometimes companies try to decide what is best for their platform. This will all work itself out by watching demand and supply for iPhone apps over the next year.
Microsoft Word for Mac has a feature like this where it will record while you type and even replay your notes back to you. I used that all through college to record lectures and such.
This app looks even better.
For a few months now I've been teaching different classes about web design and/or development. In preparation for those classes, I have found myself spending a lot of time inside Keynote as well as setting up my notes on a wiki using Hickey.
Keynote is a joy to use. However, I don't like the normal style of having lots of various master slide types. After finding a set of thick, thin, serif, and italic fonts or font variations, I like to have one giant text box on my slide - something that can show 6 lines or so.
I'm a sucker for pretty letters just sitting on a gradient.
Duplicating slides is the most common thing that I do. Even though I have removed all but one master slide, most of my slides are a progression. One thought, then another, then a final thought.

So far, I have not found a good way to build in those thoughts other than duplicating a slide and then adding the next thought. This is not a big deal, but it would be nice if I could make one slide and then have more control over how it builds in.
It seems that it might be possible to use an iPad to create (and possibly even present) my slides for my class. That is pretty interesting to me.
I agree completely.
I love things on my Mac and iPhone, but this looks better than either of those.
So I don't have an iPad yet. I'm not one to jump out and buy something on the first day. However, I do think one could improve my workflow a bit.
Checking email, managing my todo lists, working in Basecamp, looking up documentation, and other internet related tasks could be a lot less painful for me with an iPad. Diagraming site-maps, preparing Keynotes, and editing my teaching notes could all be done with very little effort on the thing.
I think it could make my laptop become the "Real Computer" that I use for work while the iPad could be what I use for project management and communication. And that is appealing to me.
I'm just not sure if it's $499 appealing. Yet.
Stallone drives a fast car, shoots guns, and gets the girl.
I really like this idea.
Jaw dropping, yet so simple under the covers.
Interesting collection of reactions to all the health care brouhaha...
Not cool.
Assuming that you have a div with id "switcher" and each panel of the accordian has the class of "switch" and that your accordion headers are h2's with a's in them, then:
$("#switcher .switch").hide();
$("#switcher .switch:first").show();
// wire up sidebar switcher
$("#switcher h2 a").click(function() {
var id = $(this).attr("href");
$("#sidebar .switch:not("+id+")").slideUp();
$(id).slideDown();
return false;
});
This is the matching html:
<div id="switcher">
<h2><a href="#one">One</a></h2>
<div class="switch" id="one">
<p>One</p>
</div>
<h2><a href="#two">Two</a></h2>
<div class="switch" id="two">
<p>Two</p>
</div>
<h2><a href="#three">Three</a></h2>
<div class="switch" id="three">
<p>Three</p>
</div>
</div>
This turned out to be way easier than I first thought.
This will come in handy soon.
So getting an old rails project up and running today was a bit of a problem. And it all ended up being something very simple.
If your on Snow Leopard you probably know that you have to install the mysql gem in a special way:
sudo env ARCHFLAGS="-arch x86_64" gem install mysql
-- -with-mysql-config=/usr/local/mysql/bin/mysql_config
This is all well and good, until you rake gems:unpack. That's when it all started today.
You see, those gems have to be built. And, just like when you install the gem into your system gems, it has to know the arch settings. That means you need to do:
env ARCHFLAGS="-arch x86_64" rake gems:build
So simple, yet an entire hour lost.
Can ruby gems not do this for me?
"Avoid conventions that demonstrate a lack of competence."
Yojimbo, Instapaper, and Delicious are three applications/services that I really like. However, I want my own version of them.
Things I want to be able to do that I cannot at this time:
Then it occurred to me: I don't need three applications, I really just need one good one.
Sometimes I add URLs to Yojimbo because I want an archive of the page. Sometimes I add things to Instapaper, but want to read it when I'm offline. Etc, etc...
So how hard would it be? Is it impossible to get an application/service that I can dump anything into for later and then get to that thing anyway I want?
Anyone got any recommendations?
I hope he's wrong, we need more innovation from everyone.
I remember how big a deal it was to me that I could undo multiple times.
There is no way Apple leaves out Flash from the iPhone and iPad because they want to limit people from watching video and playing games.
Why would they push HTML5 video then? Why would they work on Web GL so people can make 3D games in the browser with JS?
Why try to limit someone from doing something while inventing alternative technologies to let them circumvent your control?
Crazy.
I love flash.
Without flash, I would have never wanted to be a designer. Praystation and other sites where designers uploaded "experiments" drove me to learn and to hack and to code and to draw and to create.
But today: flash sucks.
(It kinda always has really.)
It uses too much cpu on a mac (this is known), AS3 is alienating designers (bread and butter user-base), and there are just some strange bugs (but that doesn't really matter as much).
I still love it. I still use it. And oh boy do I know about some weird bugs with large bitmaps and caching and writing your own bitmap caching and using listeners to make an event loop to register queues to process things so the UI never lags (cause it's going to lag) and on and on.
All just so I can draw things on the screen and maybe even move them every now and then.
That is what I want do. The internet allows anyone to create something beautiful and immediately share it with anyone else.
No.
Why would it? Plugins will exist as long as the content we want requires them.
If content creators make content that doesn't require plugins, fine, but what we want is the content.
Flash doesn't matter. Neither does HTML5. Neither does anything else. If people really want content that requires flash to consume, they will find a way to use flash.
People just want to create and share things. They will continue doing that.
I've been using this wiki enough now that I think I can recommend it to everyone. Hickey is a wiki I built in a few hours last week and have been updating regularly as I need things.
So far it does:
I really really like it so far. I am using it for my class I am teaching to post notes and it has also been setup as the Letters.app project wiki.
If you want to try it out yourself, it's pretty simple to get up and running. Right now you must have git and ruby installed (if your on a mac, it's already there). Eventually, I am going to make a GUI app that will work no matter if you have it installed or not.
You can find the steps to download and install hickey in the Readme at github.
Disappointed by the closed nature of the App Store being thrust upon such a beautiful device, I started wondering if it's even possible to take a full desktop OS (as they are seen today) and use it for a multitouch only experience.
The more I think about it, the more I think the answer is: No.
Companies have tried many times over the past few years to craft something that people will use everyday with just their fingers, without a keyboard and mouse. And those companies have all failed.
Maybe a locked down, limited device is the only way to have a quality multitouch experience in a small portable form factor.
I sure hope I am wrong.
If Hulu were to move to using the video tag, what sorts of protection are available for them? How do they keep people from skipping the commercials?
Right now, I think they could:
I wonder if/when this sort of setup will happen?
I commented with my thoughts which are: I should be able to play whatever the crap I want.
http://www.youtube.com/watch?v=G5WarA5xnNE&feature=channel
If the network had come to me and they said: "Dave, we'd like you to have this show." And then a week later they said: "Dave, we don't want you to have the show." Then, you could be angry about that.
I am interested in making something like delicious.com, but that I would run on my own server. It needs to:
Open sourcing it and making it a cinch to run on Heroku would be great, so that anyone could run their own version of it.
Pretty soon, I'll be teaching at CDIA in Georgetown. This will be a life-long (oxymoron, being as I am quite young) dream of mine to head up a class about a topic I love.
Explaining the beginnings of things is what appeals to me. How to get started is so critical and so many people get introduced to the industry in the worst of ways.
I am very opinionated about the correct way certain things should be done and I don't mind that. Even some of the curriculum at CDIA doesn't agree with me, but I'm sure it will all work out <winkyface>. A tremendous amount of leeway is given to the teacher, which can be problematic as constraints help us focus. Luckily they have suggested teaching paths that are very solid.
It's amazing that a school is offering a course as progressive as the one I'll be teaching. A focus on learning standards, validation to help solve problems, and introducing designers to web programming are all right up my alley.
We'll see how it goes. Hopefully I don't screw up the student's educations too bad.
Hope everyone has a good holiday season this year.
The new Google Chrome OS is very exciting. For the first time, I can see an OS that might save Netbooks. Chrome OS feels like a browser running in kiosk mode and this is not a bad thing.
Apps (really, just fancy bookmarks) are accessible by clicking on the Chrome icon in the top left, which I suppose is like a start menu of sorts. You wouldn't know it at first, but you can actually open more than one window. The windows slide in from the right and are accessible by Alt+Tab to cycle (other shortcuts can be found in this Developer FAQ.
The scrollbars lack arrows at the top or bottom and are made entirely of the scroll thumb. I think this is a great advancement: who needs those arrows anyway?
There is a simple Task Manager that has a pretty funny link to get to the advanced settings:

You can even use the Webkit Inspector in its own window:

And I even wrote this post using Chrome OS:

I am really thrilled with what they have done so far. This is going to change how people thing about using a computer.
Some things that google needs to solve to make the OS better:
Any thoughts? Contact me and I'll try to append them here.
Change your default browser quickly or just have it always default to whichever one you are currently using. A must have app for anyone who uses Firefox, Chrome, Safari and more at the same time.
A neat little Mac app to help you stay focused. Not sure if I can do it, but it's a neat idea.
One of the best presentations on JavaScript I have ever seen. So much good content with real in-depth explanations.
Read now.
In the past, I have recommended Flash Video (flv) as the best way to get video content online and make it available to users. However, I think my opinions about this are starting to change. H.264 is such a good codec that can be played by so many devices that even Flash running in a browser and play it. It's that easy to play.
<video> is now on the scene and it is reinforcing the idea that we can have a positive video experience without all the buffering and stuttering and general flash slowness. Don't get me wrong, I love flash, I started making websites in flash, I still do a fair amount of AS3.
But flash is slow. It's slow how Ruby is slower than C. Ruby is still great to use and I use it for all my web applications now, but it's slowness is acceptable because of the level of abstraction and productivity gains. All technologies have tradeoffs. However, I am starting to think that flash's slowness is not a tradeoff that is good for consumers of video content.
Apple TV (which is made from piece of crap parts) can play 720p video just fine. Heck, even the original xbox using XBMC can play some HD content from what I hear. Yet give an SD flash video to either and watch them cower in fear. Web sites shouldn't require users to have beastly machines just to enjoy the content.
Flash is bad for video unless it can speed up and become transparent. For now, it's very visible that it is working too hard to perform a job that we already solved in much better ways.
<video>My issue with <video> is this: how do you interrupt the show for commercials?
I assume current flash players just use AS code to determine those sorts of things and possibly even load each segment as a different FLV. While most of this can be duplicated in JS, that would be far more hackable than AS from inside the browser. I could rid myself of commercials forever, but then the video hosting site would go out of business.
Has anyone tackled this problem? Is this something where commercials just have to be integrated into the stream?
Experimenting lately, I have been talking to my computer.
Every Mac includes something called Speakable Items. Essentially you can say things like "Get my mail" or "Switch to TextMate" and it will do it. In System Preference, Speech you can turn it on and look at the help to figure out how to use it.
Essentially: it sucks and I love it.
It sucks, because it's buggy and it doesn't know how to isolate a voice. I love it because it could keep me from typing as much as I do.
In the end, I don't think I can use it on a daily basis, but it has changed my mind about speech recognition's usefulness.
While I don't know if I could use dictation too much, I do like the idea of asking what the temperature, time, do I have new email, and other short questions or commands.
Is anyone working on something like this? Is there research to improve this?
I am very interested in speech commands now and I would love to see progress on this in the near future.
I'm not a hater or anything, really, but come on: Video of Microsoft Store Opening That is an Apple Store with non-Apple computers in it.
If Growl notifications are not working with Colloquy on Snow Leopard, it's because Colloquy is using a 32-bit library to communicate with Growl. It can be fixed by setting Colloquy to open in 32-bit mode.
This is the first application I have set to do that so far.
For Cocoa + Objective-C.
Turntables are complicated. I picked up a cheap turntable today that works, but I am sure it is destroying the records I am playing. Reading online it appears that you need to align your cartridges, oil your belts, and lots of other things that I will probably never do.
Looking at the little thing, it appears that it's arm is pretty shotty, the wiring or something is causing a nice buzz, and the records seems to bounce a bit on their way around. I'm not sure if all of that can be fixed or not.
Either way, it's nice to finally checkout the Eagles LP I got.
Apparently I jotted down a quote from my dream last night before I forgot it. I found this in my iPhone's Notes application:
I have some unilateral thoughts about what it means - and those have changed over time. You don't get that deep without seeing rockets everyday.
Yeah, it doesn't entirely make sense to me either. Must be poetry.
I compiled id3lib include /usr/local, then:
$ sudo -s
$ export CONFIGURE_ARGS="--with-opt-dir=/usr/local"
$ env ARCHFLAGS="-arch x86_64" gem install id3lib-ruby
$ exit
I love Yojimbo, but the new icon - worst. ever.
![]()
I've looked at MySQL, Postgres, Oracle, Couch, and many other database applications over the past few months.
I like Couch the best.
However, I have decided that Mongo DB is the best database to use for a web CMS. And this is for one reason: a query language.
Content is based on documents or content objects and this just cannot be modelled correctly in a traditional RDBMS like MySQL. Couch is great, but you gotta know what your content looks like up front (or write tons of code to create / drop indexes depending on content changes).
If I ever build the CMS that I would want to build - to allow users to create structured and unstructured content anywhere in the system - it would only work with Mongo.
OK, so they moved the genre browser to the left. Luckily you can change it back to top with View > Column Browser > Top.
The new interface is very white. All the progress bars look better than before, but I can't get over just how bright it is. The Movies section still won't do folders or anything, but I suppose that's what search is for.
The new store is easier to navigate and it's much easier to preview songs. It's actually a lot like the iPhone iTunes store.
I have been saying for a long time that there needs to be a file format that allows menus like a dvd with all the extra features, but still contained in one file. Finally, Apple has delivered this.
It will be interesting to look inside these files to see if something like Handbrake could ever be used to generate them from existing DVDs (the holy grail) and if open source players could ever support anything like this. This is the most exciting thing to me as now I can actually think about buying movies in iTunes. Why pay the same price as DVD and not get any special features?
A better description of the special features when browsing the store would be nice, but hey they're just getting started.
Finally someone chose to try to solve the problem of include special features with movies - all in one file.
Iron Man is for sale this way. I might have to try it out.
iPhoto has facial recognition now, but it still needs a tiny bit of improvement. Below are some of the real mistakes it made trying to recognize me:



Let's see if I can stick to this.
What would the world look like if people lived locally, yet were interconnected with the rest of the world?
Comment by Matt Parks:
What do you mean by living locally? Local to what? Not sure if I understand the question.
My reply:
Living locally, to me, means to live near where you work, buy things made near where you live, and form close relationships with those who are geographically similar. Sure, we all travel a bit, but planting ourselves into out community and working together to benefit it should be our long term goal.
Songs you have listened to greater than five times, but not within the last 6 months.
http://stream.btucker.org/post/173936916/widescreen-vs-pan-and-scan-via-kottke
Why do they even make full screen movies anymore?

After getting a new logic board put into my laptop, Time Machine seems to think this is a new computer and is making an entirely new set of backups for it. Strange.
It appears to be impossible to convince it that it's the computer that made all the old backups.
The Sound class in flash automatically parses ID3 tags into an id3 method on the sound object.
sound.id3.artist returns exactly what you would expect.
Using flash today wasn't total torment. It was actually kinda fun.

Over time I have had to implement calendars on sites over and over again. I used to try to use other people's plugins, but that never really gave me the flexibility I needed, but hey it was free and fast. However, recently I needed to implement a calendar in javascript and I found all the existing libraries to be lacking, so I wrote my own.
Then I ported it to Ruby and Rails so I could use it on the server side. It turned out to not be that difficult, so I wanted to document my thought process here for later. This applies to Rails 2.2.
We'll need some kinda of Event object to display on the calendar, so let's just create the Event model and EventsController.
script/generate resource event title:string start_at:datetime description:text
If you would like an end_at or a duration then feel free to add those in as well. I'm not going to cover building the data entry forms in this article, so the fields don't really matter other than start_at.
We will need to be able to pass in what month and year we want to see, so I add an extra route for that:
map.event_year_month "/events/:year/:month", :controller => "events", :action => "index"
map.resources :events
So we can CRUD events if we like and we can also see events for a given year and month. Also of note, since we put :year and :month in the url and not in the query string, it's much easier to cache later if we need to.
All the controller needs is an index action that figures out which year and month to display.
def index
@year = (params[:year] || Time.now.utc.year).to_i
@month = (params[:month] || Time.now.utc.month).to_i
end
Simple and concise. Also of note, I do (...).to_i since params[:year] will be an instance of String or NilClass and nil.to_i is not a method.
I'm not going to demonstrate how to implement the show action, you can handle that.
The model should always be where most of the heavy lifting goes. Luckily Rails has some fancy tricks to make searching and other tedious things pretty easy.
class Event < ActiveRecord::Base
default_scope :order => 'created_at DESC'
named_scope :future, lambda { { :conditions => ["start_at > ?", Time.now.utc] } }
named_scope :recent, lambda {
{ :conditions => ["start_at >= ? AND start_at <= ?", 2.weeks.ago, Time.now] }
}
named_scope :between, lambda { |b, e|
{ :conditions => ["start_at >= ? AND start_at <= ?", b, e] }
}
named_scope :near, lambda { |that|
{ :conditions => ["start_at >= ? AND start_at <= ?", that - 2.weeks, that + 2.weeks] }
}
def to_param
"#{id}-#{title.parameterize}"
end
def self.all_for_day(date)
between(date.beginning_of_day, date.end_of_day)
end
def happened?
start_at < Time.now
end
def future?
!happened?
end
end
I threw in a few extra useful methods, but the primary things we are interested in are Event.between and Event.for_day. Also of note, having to_param be "#{id}-#{title.parameterize}" (example url: /events/3-some-string) is a good thing, since Event.find("3-some-string") will really just be Event.find(3), so it's as if the title wasn't even appended when you go to lookup that specific event.
In events_helper.rb we just need to add a method to generate our calendar. This is the hard part and I am going to walk through the logic of it step by step.
def calendar(month, year)
end
All we need to generate a calendar is a month and a year. Something like 1, 2010.
def calendar(month, year)
beginning = Time.now.utc.change(:month => month, :year => year).beginning_of_month
days_in_this_month = Time::days_in_month(month, year)
end
Next, we need to figure out what the first day of the month passed in is and how many days are in that month. Now, we know how many days are in this month and we now have a variable pointing at the first day of this month, we need to think about what we want to do now.
If you think of (or look at a) calendar you will see that they list the prior and next months before and after the current month, to make each row have a complete seven day listing. This is obvious and second nature for us to recognize, but how to we produce that from the info we currently have.
We need to make an array of six weeks, each week being an array of seven days. The first array might show some of the prior month, so we need to backtrack to Sunday (let's assume our calendar starts on Sunday for now) before we start. Later, when we run out of days for the current month, we can just keep going until the array is full to show the next month's days. This is an example for August 2009:
[
[26, 27, 28, 29, 30, 31, 1],
[2, 3, 4, 5, 6, 7, 8],
[9, 10, 11, 12, 13, 14, 15],
[16, 17, 18, 19, 20, 21, 22],
[23, 24, 25, 26, 27, 28, 29],
[30, 31, 1, 2, 3, 4, 5]
]
For August, beginning would be pointing at the 1 on Saturday. We need to find out how many days we need to show of the previous month. This turns out to be really easy, since Ruby returns an integer for Time#wday with Sunday being 0. And it turns out, if the first day was on Sunday, we would want to show zero additional days before it. So if Saturday is 6 and our month ends on Monday which is 1, we need to show 5 additional days (6 - 1 = 5).
def calendar(month, year)
beginning = Time.now.utc.change(:month => month, :year => year).beginning_of_month
days_in_this_month = Time::days_in_month(month, year)
extra_days_at_beginning = beginning.wday
extra_days_at_end = 6 - beginning.end_of_month.wday
end
So if we add up the extra_days_at_beginning, extra_days_at_end, and days_in_this_month we should get 42 or 35 (some months are only five weeks).
def calendar(month, year)
beginning = Time.now.utc.change(:month => month, :year => year).beginning_of_month
days_in_this_month = Time::days_in_month(month, year)
extra_days_at_beginning = beginning.wday
extra_days_at_end = 6 - beginning.end_of_month.wday
total_days = extra_days_at_beginning + days_in_this_month + extra_days_at_end
number_of_weeks = total_days / 7
first_day = beginning - extra_days_at_beginning.days
calendar_array = []
number_of_weeks.times do |week|
end
calendar_array
end
Just calculating the total_days that the calendar will display (either 42 or 35) and then the number_of_weeks (either 6 or 7). We are going to use first_day as a starting point to increment from when building the actual array.
def calendar(month, year)
beginning = Time.now.utc.change(:month => month, :year => year).beginning_of_month
days_in_this_month = Time::days_in_month(month, year)
extra_days_at_beginning = beginning.wday
extra_days_at_end = 6 - beginning.end_of_month.wday
total_days = extra_days_at_beginning + days_in_this_month + extra_days_at_end
number_of_weeks = total_days / 7
first_day = beginning - extra_days_at_beginning.days
calendar_array = []
number_of_weeks.times do |week|
calendar_array[week] = []
7.times do |day|
position = day + (week * 7)
current_day = first_day + position.days
calendar_array[week][day] = {
:day => current_day,
:events => Event.all_for_day(current_day)
}
end
end
calendar_array.each { |week| yield(week) } if block_given?
calendar_array
end
position is the current position in the 7 x 6 grid, and it's gets added to the first day (position starts at zero) to find where we are in the loop. Also, there is a nice line that ends with block_given? that makes it quicker to do loops when using this method.
So now we can finally use this in our view (I am using haml):
.nav
= link_to "Previous Month", event_year_month_path(:year => @year, :month => @month-1)
= link_to "Next Month", event_year_month_path(:year => @year, :month => @month+1)
%h1= "#{Date::MONTHNAMES[@month]} #{@year}"
%table.events
%thead
%tr
- Date::DAYNAMES.each do |day_name|
%th= day_name
%tbody
- calendar(@month, @year) do |week|
%tr.week
- week.each do |day|
%td
%span.day= day[:day].day
- unless day[:events].blank?
%ul.events
- day[:events].each do |event|
%li= link_to event.title, event_path(event)
It's possible to start the calendar on a different day, always show six weeks no matter what, and all kinds of other stuff when you role your own calendar. Don't be afraid of taking an hour and working out your own solution instead of relying on code you didn't write. Or at least read over and understand the code you are using.
Yeah, this was way too long...
Everything fits together amazingly.
Beautiful wallpaper found at mulele.com
Software has come a long way in over 40 years. The first vector drawing program was apparently written in 1963! It's called Sketchpad:
This looks amazing, but the Macintosh is really what allowed programmers to create sophisticated applications that were also easy to use. The first (and still best) mac vector drawing application was Illustrator in 1987:
Illustrator progressed quite a lot in one year:
Illustrator had such a polish and finishedness about it. It was deliberate in it's design, catering to an industry with specific solutions. I feel that Illustrator CS4 (really all the CS's) has diluted some of that refinement in favor of more features and fancier marketing. Some tools I use everyday are buried in menus and pallets while others are placed right in the toolbox because they are new and listed on the box, no matter how many use them regularly.
I hope that the current Adobe will hearken back to their early years and focus on delivering quality, easy to use applications instead of new ways to bundle and market, synergy, blah blah blah. I love Illustrator, it is still the application I enjoy using the most, I just get tired of seeing the unexpectedly quit dialogue every day.
I found the videos via John Nack.
Jeff Howard:
I’m afraid service design is futile. We’re wasting our time.
Try this out and see which search engine you like best. So far, I have chosen each engine once. I am not sure what this means.

Some great quotes posted over on 37 signal's blog, like this one:
There are certain lessons…One of them is the importance of focus, the importance of saying no.
Wish you and your family well in Alabama.
Assiciation class names are now specified as :model => "User"
belongs_to :owner, :class_name => "User", :child_key => [:owner_id]
Belongs to associations have a :nullable => false by default, so you gotta do :nullable => true if you want that sort of thing
author.books.new instead of author.books.build (which makes more sense anyway)Has many through has changed and is better explained by example:
has n, :subscribers, :through => :subscriptions, :model => 'User', :via => :user
# :via => :user tells it to use the association named user
new? and not new_record?
original_attributes and not original_valuesdatabase.yml has changed a bit:
adapter: mysql
path: db_name
host: localhost
user: root
I have already used this twice today. Should be built into Mac OS X.
Happy birthday Jenny.
I need to be more effective with the tools that I use. Very rarely do I use my available toolset to it's fullest. Anyone got any tips? Here is a list of a few things I use all the time:
All of these things I love to use, but I feel that I use them at a fraction of their potential. I forget about todo's in highrise, I leave backpack pages out of date, I forget to twitter, I leave notes on my phone for months, and I really don't think I could ever use my macbook pro to it's fullest.
I mean it's great to have all this creative potential around me. Just need to make better use of everything.
A fantastic article by Zeldman about project management for design/web projects.
The Fios man just repaired the internets here at home. A power brick freaked out and had to be replaced - which is actually what I had deduced myself since the LED on the thing was blinking like crazy.
I should blame my lack of blog posts on the lack of internet access, but tethering was setup on my iPhone so it's really just me being lazy.
Good news though, the Fios man offered to change my router access from Coax to Ethernet! This may not seem exciting, but it allows me to use any router I want without having to hack the Verizon router's firmware to make it pass through.
Now I am using my Airport Express and the Verizon router is neatly boxed up in the corner. As it should be.
Best Fios tech ever.
Using curl:
$ curl -X POST http://localhost:5984/tickets/_all_docs \
-d '{ \
"keys":[ \
"06a1b6e367cd059362bc3a7921b64b45", \
"b6e6ee95a42e10f4b884b024e10fec2b"] \
}'
> {
"total_rows":3,
"offset":0,
"rows":[
{
"id":"06a1b6e367cd059362bc3a7921b64b45",
"key":"06a1b6e367cd059362bc3a7921b64b45",
"value":{"rev":"5-2613703449"}
},
{
"id":"b6e6ee95a42e10f4b884b024e10fec2b",
"key":"b6e6ee95a42e10f4b884b024e10fec2b",
"value":{"rev":"4-3074023027"}
}
]
}
Just a random thought.
A lot of people who use rails do a object.save, then check if it's true or not to determine what to do next in a controller. I find that to be verbose and hides the actual save command inside an if statement.
def update
if @page.update_attributes params[:page]
redirect_to admin_pages_path
else
render :edit
end
end
I prefer stuff like this:
def update
@page.update_attributes! params[:page]
redirect_to admin_pages_path
rescue ActiveRecord::RecordInvalid
render :edit
end
I think it's more clear that to render :edit is an exception and should not be the norm.
I have been in Louisiana for the past week helping out with Habitat for Humanity in New Orleans and HPC in Baton Rouge. Worked on some houses, mowed some lawns, painted some doors, and sweated a lot. It's hot there. Like really really hot.
Had a great time helping, what little I could, and glad to be home and back to normal.
Paul Arden
Do not covet your ideas. Give away everything you know, and more will come back to you.
Found via Joshua Blankenship
I just setup God to monitor 4 mongrels and ar_sendmail and post to twitter about it. Need to tweek God's settings a bit, but really cool thus far.
Google chrome on mac is pretty cool. Doesn't work with Flash and can't do http authentication yet, but it's already a really really good browser.
You can find builds for every revision.
I don't know if anyone has noticed, but Safari on the iPhone is capable of 3D transforms and smooth animation thanks to CSS Animations. Checkout this example (free account required).
It's hard to tell that it's a webpage. I have got to do something with this.
Much time has been wasted recently getting Flash to do anything well.
This might be some of the coolest animated gifs I have come across in a very long time.
Used to be, I would only use a strict XHTML doctype on any webpage I authored. I looked down on people using html4 or transitional even, thinking it was pretty worthless (which it is ;).
HTML 5 actually provides all the positives of XHTML without any of the cons. It's parsing rules are declared fully, anyone can make a parser and validation will be much more useful. HTML 5 will also define XHTML 5, which will be essentially the same but with XML compatibility, so XSLT is still an option. And strictness is still possible, but doesn't derail the entire thing.
You also get new form inputs, section, nav, header, footer, and other cool tags. You get data- attributes on elements, you get DOM parity with the parsing model, you get SQL storage in the browser, the ability to run apps offline, etc. You really get all the ideas we all already agree on.
Any really, why should HTML have it's own spec and be it's own language? Why do we have to use XML for everything? I already use JSON for almost all of my inter-application communication when I write webapps. Not because it works natively in javascript (I'm not even using it there much), because it works everywhere. There are not attributes or namespaces or anything, just data. It beats the pants off XML for most everything I do. And parsing JSON is dead simple, anyone can write a parser (sound familiar).
And really, the main reason HTML5 is the best to me is because the author of and contributors to the spec care about what works now. They are not hesitating to push things forward, but they are not blindly blazing a trail that no one is going to follow.
Is there anything that is in XHTML 2 that (X)HTML 5 will not have that matters? Contact me and I will amend any comments if valuable.
Also, here is a google search in case you care.
Update: Probly the best overview at immike.net. A quote:
Both working groups have embraced the coming Semantic Web by allowing developers to embed richer metadata in their documents. As with forms, the XHTML2 working group has embraced a more sophisticated technology, while the HTML working group has kept things simple.
The complex looks nice sometimes, but usually the simple wins in the end.
Update 2: An article disagreeing with me.
Update 3: Some more links:
Website. A french bistro and steak house. Good steak, good wine, and good desert. Profiteroles are the bomb.
This post's rating is 3.2333. Just testing to make sure the star images work ok even with weird numbers like that.
Review posts now show their ratings as stars.
Ratings are stored as floats, so they can have very strange precision like 4.5 or 4.3567. Since I wanted to show the amount of stars as accurately as possible, I decided to make something that can reflect any float value (basically).
Essentially, I laid 5 stars out (15px wide each) with 4px between them. I saved out two versions, one with all stars in the off/disabled state and one with all stars in the on/enabled state. I use these as backgrounds of div's, with the "on stars" on top of the "off stars." I show the current rating with the "on stars" by clipping the image's width. See below:

So, I essentially clip the "on stars" to whatever width they need to be to represent the rating.
How does one calculate the width? Well, it's simply (star_width * rating_amount) + (space_width * floor(rating)). floor() means to always round down, even when the decimal is .5 or more. Example math:
Rating: 1
Width: (15px 1) + (4px 1) = 19px (only shows the first star)
Rating: 4.5
Width: (15px 4.5) + (4px 4) = 83.5px
Since we can't have 0.5 pixels technically, I just round the amount off to the nearest integer.
So, not very hard. Actually, it took me longer to write this post than to make the stars.
A full review will have to come later (after some reflection), but I will say that it is a very enjoyable movie. You should see it.
Background applications on the iPhone are not important to me. I understand the issues and have never liked the idea of having tons of little processes eating away at battery, even when I had a palm.
But there is one inconsistency on the iPhone that has been driving me mad the past two weeks. Mail runs in the background.
I know it does.
The fact that I know that it does is actually the problem. I type an email, hit send, then I immediately hit the Home button and open another app. When the email is actually sent, you hear the woooosh – while in the other app.
Which is great.
It's a time saver and I don't have to watch the little spinny thing waiting for the mail to be sent. However, Tweetie does not run in the background. At least 10 times I have typed a tweet, hit home, then discovered later (upon reopening Tweetie) that it didn't make it. Pretty much, I cancelled sending it by shutting down the app.
Which sucks.
I think Apple could use a facility they already have built in. When memory is tight, they kill your app. Shutting an app down could be moved to a two stage process: closing the window, then real shutdown (dealloc and all that other stuff). There could even be a windowDidClose method so that app makers could dealloc all the UI stuff, but leave any syncing or any critical processes running as long as possible.
Now this could lead to battery draining type apps, so it will probly never happen. And I get that. I just wonder if there weren't a way for it all to work somehow.
As the speakers provide files, they are added here.
I have been feeling pretty much the same way about CSS animations recently.
Will be making use of this in the next few days.
Sorry to not have posted for a few days, I broke the site. Well, actually, I just made it incredibly difficult to post new posts, but that's pretty much the same. My text engine (turbine) is what actually was "broke." Let me explain:
When I post text to this blog, turbine attempts to figure out what type of object I actually posted. Well, it does take some instruction to get it going at first. It was my instruction that pretty much killed it. See this commit for the simple fix.
It's really interesting writing your own publishing software. When it breaks it's usually your fault, which is mostly bad. But when it works, it's also your fault, which is always good :)
I don't know what to think of this yet.
For Remindo, I wanted to use the same view for both add and edit. I want the edit version to slide in from the right (navController style) and the new version to slide up from the bottom (modal style).
The edit UI actually has different levels of screens for editing (for specificity of date/time), so it needed to be it's own UINavController, which it turns out is very difficult to push onto an existing navController.
I am working on a full tutorial on how to do this, but until then this link is how my IB files are setup to allow this to work.
I think the new Honda Insight is a failure. Why? Because it gets the same gas mileage as my >5 year old Honda Civic Hybrid. I mean in 5 years it doesn't get over 42 miles per gallon?
Various videos about basic Ruby concepts.
A very good twitter client for the mac that is definitely my current favorite.
I may need this in the next few days for debugging.
I picked this up a couple weeks ago and I couldn't be more pleased. The main selling point to me is that it's water proof. Being able to do a quick trim while in the shower is fantastic.
This could be used to cut my hair as well, but we already have a set of Wahl clippers for that. I can say it does function well to clean up the details of a hair cut.
Picked it up at Target for ≈30-40 $'s.
I've commited changes to show admin controls when I am logged in. Fancy.
This is my bash script to install everything I need for ImageMagick. I am going to try to keep it up to date as versions of things change. Feel free to fork and add new versions or libraries that might help.
I really like nginx and use passenger with apache, so I might switch to this for a current project.
Well, it seems that a simple Gem.clear_paths is all that I needed. Or at least it appears to have helped out.
I found this out on the phusion blog.
You can see my dreamhost specific ruby code on github
I am going to try this for a while:
module Gem
def self.default_path
[AppConfig[:production_gems_path], default_dir]
end
end
Hopefully that will work.
OK, so passenger is randomly complaining that it cannot find my gems. It's purely random. I cannot isolate it. ENV['GEM_PATH'] = AppConfig[:production_gems_path] doesn't seem to work 100% of the time (95% maybe).
Weird.
So, I look this morning and nathanherald.com is down, passenger is complaining that it couldn't find the sinatra gem. This is all very strange, since it was running last night.
A simple touch restart.txt fixed it, which is even more weird since one would think that it wouldn't just randomly forget where my ruby files are. My current hypothesis is that when passenger killed my sinatra process for being idle, it did something weird and forgot where my gems were when it needed to bring it back up.
I have setup a cron job to touch restart.txt every 4 hours. That should keep passenger in the loop while I research this issue.
So, this is my new website. I finally got something up here that I don't think is absolutely terrible. I will be migrating the content from all my past sites to this one slowly, so sorry for everything to disappear all of a sudden.
I wrote this blog in sinatra and you can see it here in a github repo. It's running on dreamhost (which isn't that bad for sinatra apps).
There are a few things that do not work at the moment.
Any feedback? Please, fill out the contact form.