Ok this came up a while ago but I never got around to following up on it. The place I work has a lot of people. More show up all the time. It is a little overwhelming when you realize that you once knew everyone and now you seriously don’t.
Thanks to the Web - I now know it is not my fault. It’s not because I’m lazy, aloof, or just a shut in. My tiny human brain just can’t handle it.
Read and enjoy the enlightenment
Inside the Monkeysphere
This Thanksgiving - I adventured into new territory. Apparently, deep frying a turkey is very popular down here. I’ve never had one - but couldn’t resist. Especially after Alton Brown dedicated an episode to it.
Below you will see a picture of my brother and I confirming that the Turkey Derrick is setup correctly.
The Turkey Derrick was awesome! I’m a little accident prone - and this made everyone in my extended family a lot less nervous about me dealing with a pot of boiling oil
If you want the plans to build your own - check out this.
Given the big jump in safety and the small cost - I thought it was totally worth it.
Most of you have already switched over to Mac (and if you have -and haven’t switch to TextMate may god have mercy on your soul.)
Me - I’m sticking to VIM. (I always meant to switch over to Emacs but I just never got there - for those of you who want an idea of how crazy Emacs is - Check This Out).
Today I learned two things that turn out to be seriously useful.
In VIM, you can do multi-line search and replace with
%s/bob/Robert/g
That line will replace all occurances of bob with Robert. The problem comes in when you have a url or file path. I ended up writing it like this
%s/\/home\/bob/\/home\/robert/g
Notice all those backslashes? They’re as annoying to type in as they are to read. When you paste a url it gets even worse.
It turns out you can use a different delimiter just choosing something else -
%s'/home/bob'/home/robert'
All this time and I didn’t know you could do that - man it makes it easier.
Now on to the next issue.
%s/.*bob.*//g
That will replace any line containing “bob” with an empty line.
So
mike bob sam bob brett
would become
mike sam brett
Those pesky blank lines can be annoying. It would be nice if there was a simple way to strip them out in VIM
Turns out there are two different ways
:v/./d
or
:g/^$/d
It turns out that the v will do the action for anything that doesn’t match - while the g must match. I haven’t figured out if there is a way to confirm the change before it happens but at least it solved the basic problem. (More tricks can be found here under vi Tricks)
Sorry - this is actually about Rails - and not those kind of cookies (Thought if you need a recipe you can try Ubuntu Cookies from Make)
I’ve been working on integration with another web app all week. This ended up meaning that I spent a lot of time looking at cookies.
Since most of the time the app minds its own business, I’m focused on flash and session. So I realized pretty quickly that I haven’t actually manually set a cookie in Rails before.
It turns out that it is pretty easy but a little confusing. Cookies follow the standard Rails pattern of session,flash etc.
There is just one thing that might trip you up. Basically you have to think of cookies as a Hash with a worm whole in it. (I didn’t make that analogy but I like it).
Basically if you read from cookies you get was was submitted as part of the request. If you write to cookies you will set a cookie in the browser. The confusing part appears to be that if you say
cookies[:timezone] = “CST”
If you put in
cookies[:timezone]
It will be nil. This is because you didn’t get that cookie on the way in. Make sense? Yeah I think the same thing. I figure it exists that way because most people don’t end up messing with them very much.
So in my case I actually needed to set a more complicated cookie. It needed to be accessible to all machines in a given domain and it needed to expire in 12 hours.
It turns out it is pretty easy to do both
cookies["TIMEZONE"] = {:value => “CST”, :expires => 12.hours.from_now, :domain => “.economysizegeek.com”}
Pretty simple - once you know what the options are. Of couse as soon as you start adding stuff like this you end up needing to be able to test cookies. In my case, the mock authentication system had some problems as a result.
Fortunately, Herryanto Siatono came to the rescue with Functional Test with Cookie
So now not only are cookies easier to work with in the app - they are easy to setup for tests as well.
Sometimes I run into things that I can tell have some serious power and usefulness - if only I could fully wrap my brain around them.
An early example in the computer realm for me is Lex & Yacc. Using them you could basically build your own grammar and your own language. I read the Oreilly book but never got over the hump to actually use them to do anything.
Today - it is Currying. In a nutshell, it allows you to take a method/function that requires more than one argument and make new versions that only require one argument.
The article that got me started was over at Shades of Gray
But in th eend he pointed to Murray which is an implementation that is even available as a gem.
It is interesting stuff. There are a few uses I can think of that fall outside of the “theoretical computer science” realm. Namely making it easier to build base functions with a number of arguments in a library and then using currying to build simple wrappers for a given project that always set certain defaults.
Consider this an oportunity to expand your brain before it is slowed by the weight of Tryptophan
TrimJunction - TrimPath - Trac
Ok I’m not sure what I think of this. I’ve played with some really neat single page apps (Hi Monkey Pirate Tiddly Wiki).
I guess this makes it just that much easier to write something completely insane as a single page app.

