20 Mar 2012

Sample Cakefile

Cake is the build tool for CoffeeScript. It's nifty, but the documentation is a little sparse. Here's an example Cakefile that does everything you need for a basic Coffee project:

 

Project Structure

In this example, I'm using a project structure something like this:

Coffee_structure

That's all inside a "static" directory in a Django project, but it shouldn't matter what kind of server you're using. Coffee files are in src/, Jasmine specs are in spec/, and compiled JavaScript goes into bin/.

 

Dependencies

To run everything, you'll need Node (which you should have already if you're using CoffeeScript) and a few other things installed via npm:

  • stitch
  • uglifyjs
  • jasmine-node

You can run npm install -g <NAME> to intall each of these system-wide.

 

Cake Tasks

Cakefiles are composed of tasks, which are defined at the top of the Cakefile like this: 

Each of these tasks calls a function that performs the correct action. For example, the "compile" task calls this function:

The reason I break the tasks out into functions like this is to make it easy to chain them together. Because Node runs processes asynchronously, I use callbacks in the functions instead of simply calling a sequence of tasks. If I just used "invoke", the full build would happen even if a Jasmine spec fails. Also, I just really like the way the full build task looks:

 

Developing with Cake

Running cake with no arguments yields a list of tasks defined in the Cakefile.

Cake_tasks

Each step of the build has its own task, but I really only use three of them on a regular basis:

  • While coding, cake test lets me easily run Jasmine specs without waiting for compilation of CoffeeScript.
  • While testing small UI tweaks, cake develop lets me package things quickly for running in the browser without waiting for Uglify or Jasmine. 
  • When I'm ready to deploy, cake build runs all the steps.
11 Feb 2012

twitter.com UI fix

Twitter keeps making their UI worse. Fortunately, there is DotJS. Here’s one quick little improvement in the UI:

Step 1. Install DotJS

Step 2. Copy and paste this code into a file called “twitter.com.js” in your DotJS folder:

Now you can easily see what your last read tweet is when you click the button to load recent ones.

UPDATE: seems like this only works some of the time, but it’s at least better than nothing.

UPDATE 2: Got it working more often. Also, highlight tweets by you or mentioning you.

22 May 2011

Moving stuff from old blog

I've been meaning to move the worthwhile posts from my old blog over to this one for a while now, and I finally got started. It turns out that there was really only one worthwhile post over there. I'm pretty happy with this tutorial for screen, although I want to rework it a little bit to publish it here.

Here's the original post, hopefully soon to be revamped and over here.

3 Apr 2011

Discovery

For a geek, there's nothing quite like that moment when you find a practical application for something you learned just because it seemed cool.
19 Mar 2011

Scene from the Lyric Opera

Old lady: Ugh, it's just such a shame.

Old man: I know what you mean. Going to the opera used to mean something.

Old lady: People would wear blacks and evening dresses. There was class. People had manners.

Old man: Yes, manners. Whatever happened to those?

Old lady: I'm not sure. Oh, it looks like the orchestra is finishing the overture.

12 Feb 2011

Buy me this now

"The Gamerator" — combinator keg and arcade cabinet.

 

http://www.joystiq.com/2011/02/12/the-gamerator-an-arcade-cabinet-with-a-buil...

 

3 Sep 2010

The First Two Weeks Back at School After Like Three Years of Not Being Anywhere Near as Busy as You Are During School and Mostly Forgetting How to Deal With It (i.e., Being Busy): A Retrospective

Thank God for Labor Day weekend.

28 Jul 2010

Minecraft

This evening I've been messing around with Minecraft. It's hard to describe succinctly, but it seems to be the ultimate sandbox-style game. Here are some videos of what some people have done with it:

You can get the game here. It's $13 and worth way more than that if you have even a little bit of imagination or curiosity. There are helpful information sites here and here.

26 Jul 2010

StarCraft 2 comes out tomorrow

If you're (like me) too crappy to make it past the fourth Zerg mission of the original, read this synopsis instead to get all caught up.

22 Jul 2010

Chipophone

Someone please get one of these for me.

Casey Brant's Space

musician, gamer, geek.
my website

Contributors

Casey Brant