-
.bashrc vs .bash_profile vs .profile
Despite years of various Unix flavor development, I can never remember the difference between the above mentioned files. So, I thought I’d finally document the outcome of my experiment here for posterity:
bash_profile: interactive login shells
bashrc: non-interactive login shells
profile: I’m guessing this is used when you do not have a bash_profile file. I found it hard to find a definitive answer, though.
$ cat .bashrc
export BASHRC=’loaded’
$ cat .bash_profile
export BASH_PROFILE=’loaded’
$ cat .profile
export PROFILE=’loaded’
$ echo $BASHRC$ echo $BASH_PROFILE
loaded
$ echo $PROFILERemoving my .bash_profile file gives the following results:
$ echo $BASHRC
$ echo $BASH_PROFILE
$ echo $PROFILE
loadedSo, it looks like the .profile is loaded when no .bash_profile exists, but that the .bash_profile supercedes .profile when it is found, preventing it from being loaded.
At least in Snow Leopard :)
Posted on November 6, 2009
-
Rails - Delegate Attributes with Override Ability
Ever find yourself in a situation where you wanted to delegate attributes from one model to an associated model unless they were specified in the original model?
I did, and I came up with a revamped version of Rails’ delegate method that not only checks if the original model has a value specified before delegating it to the associated model, but also checks that the associated model exists.
Grab the gist here: http://gist.github.com/70186
Example usage is included in it.
(originally posted on brighter.net)
Posted on October 12, 2009
-
FakeWeb with Regular Expression support for registering URIs
I have recently started using a gem called FakeWeb to fake http requests in my specs. It’s awesome - FakeWeb allowed me to ensure that I had stubbed out all external API requests (on a rather API-dependent application) with one line of code:
# prevent specs from trying to hit external api'srequire 'fakeweb'FakeWeb.allow_net_connect = false
However, I ran into an issue with it on another project that needed to block all requests except those going to a specific service. The issue was that each request had a different query string, and soon our spec helper was full of lines like this:
FakeWeb.register_uri("http://www.external.service.com/api/some/script?crazy=true¶m=foo&list=0&whatever=3", :string => "foo") FakeWeb.register_uri("http://www.external.service.com/api/some/script?crazy=true¶m=foo&list=0&whatever=4&additional=etc", :string => "foo") FakeWeb.register_uri("http://www.external.service.com/api/some/script?crazy=true¶m=foo&list=0&whatever=5&additional=bar", :string => "foo") FakeWeb.register_uri("http://www.external.service.com/api/some/script?crazy=true¶m=foo&list=0&whatever=6", :string => "foo")The query params differed depending on the request issued. Where we really got into trouble was with escaped URIs - these are harder for mere humans to read, and we missed differences in the longer ones quite a few times.
FakeWeb.register_uri("http://example.com/?a=%09%0D&b=%09%0D&ca=%09dog%4D&d=%26%0D&g=%09%0D&b=%09%0D&ca=%09dog%4D&d=%26%0D") FakeWeb.register_uri("http://example.com/?a=%09%0D&b=%09%0D&ca=%09dog%4D&d=%26%0D&g=%09%0D&b=%09%0E&ca=%09dog%4D&d=%26%0D") FakeWeb.register_uri("http://example.com/?bc=%09%0D&b=%09%0D&ca=%09dog%4D&d=%26%0D&g=%09%0D&b=%09%0D&ca=%09dog%4D&d=%26%0D")This prompted me to ask, “why not pass a regexp to FakeWeb’s register_uri method?” That way, we could pass something like /example.com\/?a=(.*)$/ for example and not have to worry about the query parameters changing… and thus have less clutter in our spec helper.
FakeWeb didn’t support this (it allowed you to pass URI and String objects) but it wasn’t too hard to add it. You can check out my fork here:
FakeWeb with Regular Expression support for registering URIs
I hope that other people find this useful. Oh yeah - please let me know on github if you find a bug in the code, and of course, feel free to fork it too!
(originally posted on brighter.net)
Posted on October 12, 2009
-
who says romance has to be a box of chocolates?
Wilson Bilkovich:It is. I love that a scottish man kicked a terrorist in the balls so hard that he hurt his foot.Wilson Bilkovich:A terrorist who was on fire at the time.Jacqui Maher:yesJacqui Maher:that made me think of youWilson Bilkovich:That's pretty much the most romantic thing I have ever had anyone say to mePosted on September 15, 2009
-
How to write a love song, Part I
Out of sorrow entire worlds have been built
Out of longing great wonders have been willed
They’re only little tears, darling, let them spill
And lay your head upon my shoulder
Outside my window the world has gone to war
Are you the one that I’ve been waiting for?
O we will know, won’t we?
The stars will explode in the sky
O but they don’t, do they?
Stars have their moment and then they die
There’s a man who spoke wonders though I’ve never met him
He said, “He who seeks finds and who knocks will be let in”
I think of you in motion and just how close you are getting
And how every little thing anticipates you
All down my veins my heart-strings call
Are you the one that I’ve been waiting for?— Nick Cave
Posted on September 14, 2009
-
an awesome morning
I was riding my bike to work this morning through brooklyn and stopped at a red light. About a dozen other cyclists ended up stopped at this corner with me, and I was thinking that I’ve definitely noticed an increase in the number of people commuting by bike over the past couple of years, and that’s fantastic.
While I was waiting for the light to change, I noticed that the woman on the bicycle next to me was wearing the coolest, prettiest shoes. Shoes that I had actually been searching for and failing to find: burgundy/black mary janes with a short heel. After being stopped at another red light a few blocks away, I got up the nerve to ask her where she got them. She couldn’t remember the brand, but as the light turned green, she offered to pull over on the next block and take them off so she could tell me.
Incredible!
She did that - the shoes, btw, are made by Jose Saenz, a shoemaker in Spain - and told me about the store she bought them at in Portland. How freaking nice is this chick? I thanked her and, as she was about to pedal away, she pointed out that you just don’t get this kind of interaction when you’re driving in a car.
Very true.
The rest of my ride was peaceful and breezy. The plant and garden guys on 6th avenue were again cutting up large branches - if anyone knows what exactly they’re doing, please let me know. A taxi actually waved me on to continue riding straight through an intersection, putting his turn signal on, not turning into my bike - amazing!
It’s mornings like this that I remember, or at least, consciously consider, how much I love my hometown. Thank you, New York :) It’s good to be back.
And thank you, female cyclist with impeccable taste in footwear. I not only found the shoe store you referred to in Portland, OR, but I also found the shoes!
Posted on September 3, 2009
-
I'm speaking at GoGaRuCo!
Posted on February 10, 2009
-
Testing Frameworks and Productivity
Posted on February 5, 2009
-
Chipotle Employee Just Gave Guy In Front Of You More Rice | The Onion - America's Finest News Source
Posted on January 26, 2009
-
hello from the beach!
Posted on January 24, 2009