Friday, August 31, 2007

Barcelona Food Girl



Barcelona Food Girl is a very cool blog about food, love and Barcelona.



Tasty ocotopus cookery.


Tuesday, August 28, 2007

subqueries in rails




Sometimes Rails just drives me absolutely batty with it's "magic stuffing". I'm all for terse and beautiful syntax, but sometimes it just seems to be randomly put together, and almost impossible to Google for.

My latest in this was that I had a model that belongs_to another model, which in turn belongs_to another model. Something like this:



class GroceryBinItem < ActiveRecord::Base
belongs_to :bin
end

class Bin < ActiveRecord::Base
belongs_to :delivery_date
end

class DeliveryDate < ActiveRecord::Base
end



The DeliveryDate model contains a "date" field.

I wanted to find all the GroceryBinItems that were added after a certain date. Simple, yes? Well, I would have thought so as well, and in the end, it was some simple code that did it, but finding that information was practically impossible, and is not well documented.

Here's what I needed to do:


def self.added_to_bins_since_last_inventory(grocery_item_id)
inventory_update = InventoryUpdate.current
current = find(:all,
:conditions => [ "grocery_item_id = ? AND delivery_dates.date > ?" ,
grocery_item_id, inventory_update.date ],
:include => [{:bin => :delivery_date}]
)
end


The magic bit is the


:include => [{:bin => :delivery_date}]


And what this does is to do a normal :include LEFT JOIN, like you would go ":include [:bin]", but then also include the :delivery_date model as well.

Yes, that is a hash inside of an array.

Way too much magic. It should be more verbose and easier to actually search for. How many times am I going to need to do this? Probably not very much, and if I don't need to do it all the time, the amount of time that I spend searching for the right magic words is going to vastly outweigh the amount of time it takes to type something a bit longer and more verbose.

But then again, this is the whole problem with the Rails community, it's a little too DRY, and a little too magic.

And this concludes the rant for today. :)




rails testing




Rails Testing - Not just for the paranoid. A good article about writing your tests for Rails first, and then devleoping the code second.

For this latest Ruby on Rails project that I'm doing, I'm trying to do TDD, or rather, BDD, since I'm using specifications and not tests.

However, I found that for the first rough sketch of the application, I needed to just sketch things out with my Models and Views first, just to kind of get an idea of where I was going.

Now, for the second round of features, with GroceryItems and Suppliers, I'm doing BDD, and it's really interesting, it makes you think in a whole different way.

Still, it's hard to make that leap back to the browser, you get writing all those tests and it's hard to remember where exactly you were going, so now I'm going to start writing some more views, but trying to do these views with BDD. Wish me luck.




Monday, August 27, 2007

designing interfaces




oooh, this is so sweet, a new book from O'Reilly, Designing Interfaces has just an out of control interface for their website, has tons of awesome information. I'm having lots of fun reading it.



n



Sunday, August 26, 2007

multiple nested includes in rails




A blog post about multiple nested includes in Rails, which references this dzone post which provides more information.



Saturday, August 25, 2007

upc




UPC codes at wikipedia. For a project that I'm working on, the new website for Sunshine Organics, I'm redoing their Microsoft Access/PHP solution in Rails.



javascript




a reintroduction to javascript - Now that I have the big Javascript rhino book, this URL is less used.



tips for rails



liveapi



quickcam express with linux




Sweet, got my Logitech QuickCam Express working with Linux. The magic
was to install qce-ga from:

http://qce-ga.sourceforge.net/

Then play the video, with instructions from:

http://gentoo-wiki.com/HOWTO_Install_a_webcam

Just go:


mplayer tv:// -tv driver=v4l:width=360:height=296:outfmt=rgb24:device=/dev/video0:noaudio -flip






conchords









head




holding a program in your head, an article by Paul Graham.

One application of this is in doing testing, especially functional testing. When I write my Ruby on Rails tests, I think of things in terms of a story "Alice orders 3 extra nectaries, Betty orders those nectarines from the story, Charlene packs and delivers the nectaries".

This is because the human brain is uniquely suited to remember stories, we can keep huge storylines in our head, multiple interweaving storylines, because we evolved as social beings. So, it's a really great hack to use stories as ways to remember how our programs work, because our brains naturally work that way.

I'm going to try to think of more ways that we naturally think, and apply them to how we program.



Friday, August 24, 2007

lily




Lily, JavaScript Patching

Lily JavaScript development environment, Beat box

lilyapp.org

mmm, sweet!


Now, I just gotta hook this into marsyas!



Babaji photo story







This is a video that I just put together with After Effects for a Babaji friend. It's a slideshow of some rare photographs of Babaji. Enjoy.


Thursday, August 23, 2007

youtube upload




A hilarious, and informative, video about the right format to upload video to YouTube:

* MPEG4 (Divx, Xvid) format
* 320x240 resolution
* MP3 audio
* 30 frames per second




sweet slideshows in after effects




Wow, a really fantastic tutorial how to make a slideshow in Adobe After Effects. Serious power.



Wednesday, August 22, 2007

OSC




OpenSoundControl - A really neat way to control a whole bunch of applications through a standard interface. There's a Ruby library for it.

What I want to do is to hook up Mark Fiala's excellent ARTag system to OSC with Ruby, then use the ARTags to control Ableton Live through the LiveAPI module. Mmmmm, sweet.



osc for ruby




The original download site for OpenSoundControl for Ruby appears to be broken, but here's a mirror, with code at version 0.1.3.

osc for ruby



yaml




YAML fixtures in Rails.

Mmmm, YAML...



ableton live



simple



10th dimension




A video about how to visualize the 10th dimension. It's interesting, and well done, but not how I would explain it, it's more talking about time as the extra dimensions, and I find it more interesting to think of more dimensions as actual spatial dimensions.

Plus, thinking about it in actual spatial dimensions will blow your mind even more.



vertical centering




Vertical Centering with a Floated Shim - Sweet, this looks like a neat solution to vertically centering a web page.





graphic life coaching






An interesting site makemark.com about graphic life coaching.

I'm a big fan of drawing out my strategies, flowcharts and database relations, and this looks like it has some neat ideas.


Tuesday, August 21, 2007

gm midi drum map




General MIDI Percussion Key Map - Very neat, I should be adjusting my SPD-11 to these settings, to make things more standard when I'm doing my recording into Ableton Live.



find slow actions in rails




From DZone snippets:


# Show a list of actions sorted by time taken. Useful for finding slow actions.
cat log/development.log | awk '/Completed/ { print "[" $3 "] - " $0 }' | sort -nr




svn add




I wanted to "svn add" all the files in a directory tree that hadn't already been added, and used the following bit of UNIX goodness:


svn status | grep \? | cut -d ' ' -f 7 | xargs svn add




red








writing plugins for rails




A taxonomy of Rails plugins doesn't give us a taxonomy, rather, it shows us how to write rails plugins. Really well written.

However, it's not a taxonomy, a taxonomy would be some way to classify Rails plugins, but that's just the science nerd in me that gets very particular about concepts such as Taxonomy.



Sunday, August 19, 2007

linus




An awesome interview with Linus Torvalds. Linus just rocks. So down to earth, a true hacker.



Saturday, August 18, 2007

new hdrs for linux




A good article about new HDRs and DAWs for Linux.

Linux Home Recording Studio

Linux MIDI, a brief history parts 1, 2 and 3.



joy of tech - macintosh witnesses




My favorite internet comic of all time is Joy of Tech, and today it's soooo funny! It's funny because it's true.





Friday, August 17, 2007

maudio uno




drivers for my Uno.



ccrma and fedora 7




For some reason, the link to the Fedora 7 repository isn't on the main CCRMA page:

http://ccrma.stanford.edu/planetccrma/mirror/fedora/linux/planetccrma/7/i386/



ccrma + madwifi




A while ago I had tried to install CCRMA on my laptop, but had problems with getting my madwifi card to work on Fedora Core 7.

I just figured it out, it wasn't too bad at all:


1) Install the CCRMA yum repo RPM:

rpm -Uvh http://ccrma.stanford.edu/planetccrma/mirror/fedora/linux/planetccrma/7/i386/planetccrma-repo-1.0-3.fc7.ccrma.noarch.rpm


2) Install the CCRMA core packages

yum install planetccrma-core


3) Install the source code for the CCRMA realtime kernel

yum install kernel-rt-devel


4) Download the madwifi source at:

http://sourceforge.net/project/showfiles.php?group_id=82936


5) Untar the madwifi source

tar xvzf madwifi-0.9.3.2.tgz


6) Build and install the madwifi modules


make install KERNELPATH=/usr/src/kernels/2.6.21-0182.rt21.2.fc7.ccrma-rt-i686


7) Reboot with the CCRMA kernel and you're done!





Wednesday, August 15, 2007

bytes and biology




the bytes behind biology. I remember working inthe CAVE doing biology simulations. I wonder how much things have progressed in the last 10 years, it sounds impressive, but back in 1997, we were doing some pretty far out stuff.



mira






Mira, when viewed in ultraviolet, has a huge tail that looks like a comet. Mira means "wonderful", and has been observed since 1596, but the tail has never been seen until now.


jemplate




jemplate - Javascript templating neatness. Surfed by ingy.net.



yaml.el




yaml.el is a YAML mode for Emacs.





virtual domains




I'm learning how to setup virtual mail domains in postfix. This is for the manzanita.ca website that I did last week.



Tuesday, August 14, 2007

thingdb




tdb - thingdb is another new concept for databases.



wikidbase





wikidbase, or wicked-base, combines the functions of a wiki and a database. so neat.



Monday, August 13, 2007

Sunday, August 12, 2007

Saturday, August 11, 2007

perseids






Be on the watch for Perseids this weekend, look for the constellation Casseopia which looks like a W, just beside the Big Dipper.



range of cedar




I was wondering about the range of the Yellow Cedar in BC, and found this great resource from the Department of Forestry at UBC.



the power of netcat




Some very useful netcat tips and tricks. Sweet, I had no idea how powerful netcat was.



8 ways




8 easy things you can do to lose fat. A great little article, and right on the money.

Losing weight is a matter of taking in less calories than you burn. It's super simple, just not that easy.

It's great that he mentions about the importance of exercise as well, it's very important. One thing that really keeps me away from the potato chips is to think "ok, this one bag of chips will take me 2 hours to burn off at the gym. Is it worth it?"





Friday, August 10, 2007

keyboard as keyboard





I just noticed, there are 12 semitones in an Octave, and there are 12 keys in a grid from "y" at the top left, and "." at the bottom right.

How about making a computer keyboard map the linear notes of a piano onto an XY grid like that?

Only, don't just assign them "y=a", "u=a#", but assign the keys ergonomically, to be the easiest to play.

And then the various function key modifiers will change the octave up or down.

And map all those funky keys all over the keyboard.




shred algorithm




A paper talking about the disk wiping algorithm in shred. Wow.



wipe it #2




Darik's Boot and Nuke is another solution for wiping disks.



shred a hard drive




Make sure to shred your hard drive before selling it. shred is a great program on linux that writes random data at each location on your hard disk, making sure that it gets wiped completely. sweet.



writing a compiler




How difficult is it to write a compiler?

As I learn more computer languages, it's striking how similar they are to each other, especially procedural programming languages. I've been spending some time learning functional languages like Lisp as well, and those certainly are a different beast, but underneath all languages is a similar core.

I'm really interested what programming languages in 100 years are going to be like. We've had such development in the last 70 years, where is going to go?



Thursday, August 09, 2007

Manzanita!




I just created a website for the Manzanita restaurant, here in Powell River. It's got great food, check them out when you're in town.



Wednesday, August 08, 2007

tx-0 journey







I took a little Google and Wikipedia journey about the TX-0, and it led to Emacs:

TX-0
TX-0 at the computer museum
TX-2
TECO
Emacs Lisp
GNU Emacs




Tuesday, August 07, 2007

datavisualization




Modern approaches to data visualization.



beautiful code




I disagree with the disagreement about beautiful code is indeed code that is straightforward and easy for other people to understand and modify. I guess we all just have differnent ideas of beauty.



google cheat sheet




Sweet, a big PDF google cheatsheet.



Monday, August 06, 2007

rweb




A blog post about RWEB, literate programming for Ruby, based on the WEB concept by the mighty mighty Donald Knuth.

Very interesting. I like the idea of WEB, but it just didn't look pretty enough for me. I write tons of comments in my code, I sometimes turn code into a little novel, I think it's the only way to write code, I love seeing what the developer meant when she was writing code, to see where he wanted the code to go, to see what she was thinking, and comments are awesome for communicating between coders. Some people, like Linus, disagree with me, but I'm not an engineer, I'm an artist who likes the medium of code.



Sunday, August 05, 2007

making a dvd from avis




How to make a DVD from AVIs on Linux:

cat 1.avi 2.avi | mencoder -noidx -ovc copy -oac copy -o finalmovie.avi -
ffmpeg -i finalmovie.avi -y -target ntsc-dvd -sameq -aspect 16:9 finalmovie.mpg
dvdauthor --title -o dvd -f finalmovie.mpg
dvdauthor -o dvd -T
growisofs -dvd-compat -dvd-video -speed=4 -Z /dev/dvd ./dvd/*


Also,another article, about writing DVDs, using mplayer instead of ffmpeg.


making a dvd from avis




How to make a DVD from AVIs on Linux:

cat 1.avi 2.avi | mencoder -noidx -ovc copy -oac copy -o finalmovie.avi -
ffmpeg -i finalmovie.avi -y -target ntsc-dvd -sameq -aspect 16:9 finalmovie.mpg
dvdauthor --title -o dvd -f finalmovie.mpg
dvdauthor -o dvd -T
growisofs -dvd-compat -dvd-video -speed=4 -Z /dev/dvd ./dvd/*



javascript tools




JSMin is a tool to shrink the size of your Javascript files by removing comments and spaces. I also like to put the full source code up in a link in the comments of the HTML so that other coders can get the original stuff to reuse it.

JSLint is a lint, or syntax checker for Javascript.



rooting systems




An article about how to get root on systems. I'm pretty paranoid about security on my servers, and after an article like this, I should get even more paranoid.

For all you young crackers out there, a much more satisfying way to get root on a system is to get an old computer and put Linux on it. Then, you'll get all the access and control you could ever want.

Cracking systems is so last century. Building out of control websites that could make you billions of dollars is where it's at.



Saturday, August 04, 2007

speed it up




Simple tricks to speed up your website. Neat!



xray




xray is a bookmarklet for Safari, Firefox, Camino or Mozilla that let's you see the box model for any element.



single take




Fast, quick, cheap single take music videos are all the rage now.



12th planet




The wikipedia article for Zecharia Sitchin who talks about Nibiru, the 12th planet that causes havoc in the solar system.



Wednesday, August 01, 2007

searching with ruby




The unfortunately named but really neat looking Sphincter. Now, you gotta really try to come up with a name that bad, especially since the engine it uses is the elegant Sphinx.



More gardeners




A great quote from a guest on Rocketboom today:

"More gardeners will make the world a better place"

So true!



Fedora Core 7 Mouse Gestures




I find those new fangled mouse gestures really distracting on my laptop, and Fedora Core 7 installs them by default.

This page at folk.ntnu.no tells you how to disable them:

In kcontrol go to "Regional and Accessibility"/"Input Actions". Be sure that "Disable mouse gestures globally" is not checked in the "Gestures settings" tab. I use "Mouse 3 (secondary)".