Saturday, July 17, 2010

my recent techie prowess, plus HTTP hacking with curl, and the joy that is fortune

being between gigs at the moment, i have to keep my days busy lest grow used to inactivity, or worse, i slowly lose my mind (any more than i already am). that means working on my own projects, which include a couple of code-related things i'm working on, and a few non-code related things (more on the latter in the future).

on the coding front, i'm still putting in a little bit of work into Corner Flower Shoppe. today i helped to finally get Google Analytics sorted and working (woot!).

then there's my personal baby, FortuneBOT. for the uninitiated, fortune is a classic UNIX program that greets you with a random quote; sometimes like a fortune cookie, sometimes nerdy, sometimes offensive, but more often than not grin-inducing. FortuneBOT is literally fortune brought to you over twitter.

the problem with the way FortuneBOT is set up at the moment is that whatever quotes he serves up is dependent on what server he resides on. this was fine when he lived on a tiny little server at home (an NSLU2, or slug, running SlugOS). reliability concerns forced me to move him onto a Dreamhost server. don't get me wrong, he's quite happy living there, and since hasn't missed a scheduled tweet due to untimely power outages. since moving to Dreamhost, however, FortuneBOT has since cleaned up his potty-mouth: no more offensive quotes! and those were some of my favorites!

so long ago i decided FortuneBOT needed to be rewritten, from the ground up, and forgo it's humble 20-line python script roots. well, now i have the free time to do just that, and use it as an excuse for a crash-course in ruby-on-rails and HTTP / REST services (in a desperate attempt to stay relevant).

the REST part of the equation means i have to be able to GET responses from the web service in various formats, not just as HTML. it turns out cURL, along with a little header hacking thanks to the -H switch, makes for an easy way to do just that, all from a command prompt. to make the whole testing process easier i whipped up a quick sh script to do the dirty work for me.

Listing: curl.xml
#!/bin/sh
curl -H 'Accept: application/xml' $@

i've also made curl.json and curl.text scripts for JSON and plain text responses, respectively. you're welcome, internets =]

on that note, i'd like to leave you now with a quote from fortune itself, one of the things it does best (and something followers of FortuneBOT are currently missing) - a dirty limerick:

There once was a man named McSweeny
Who spilled some raw gin on his weeny.
 Just to be couth,
 He added vermouth,
And slipped his girlfriend a martini.

Thursday, July 15, 2010

Sessions with m-Xdoctor 2010-07-15.0033

I am the psychotherapist. Please, describe your problems. Each time
you are finished talking, type RET twice.
hello doctor.
How do you do? What brings you to see me?
well, there's this girl i met, and i really really dig her.
Why do you say that?
to be completely vague, she's incredibly cool, i found myself
completely comfortable with her off the bat, and she certainly knows
how to flatter a guy.
Is it because to flatter a guy that you came to me?
no.
Why not?
my real problem, doc, is that i'm hesitent to speak to much of her on
ye old blog. i do like to respect others' privacy.
Does it bother you that you are hesitent to speak to much of her on ye
old blog you do like to respect others' privacy?
i little, i guess. i mean, these are people's lives, and i shouldn't
very well be blasting onto the public internet without their ok.
Earlier you said to flatter a guy?
yeah, she says the sweetest things that just shoot my poor ego into
the stratosphere.
When did you first know that just shoot your poor ego into the
stratosphere?
umm, how about the first compliment? yeah, that sounds about right.
Is the fact that about the first compliment yeah that sounds about
right the real reason?
no.
Are you annoyed that I ask that?
no.
Why not?
you're a script, doc, you just do as you're told. i can't blame you
for that.
Can you elaborate on that?
you're what's called a chatterbot, a slick computer program designed
to mimick human conversation, but in reality you're just following a
handful of simple rules.
Does the fact that in reality I am just following a handful of simple
rules explain anything else?
no.
Why not?
that's your nature, doc, plain and simple.
Maybe your plans have something to do with this.
well, getting back on track, as i was saying, i really like this girl,
so much that i want to talk about her to you, to the world, the the
internet ether. but i dare not divulge too much, lest i mistakenly
reaveal something of her identity. putting my own life into the public
eye is one thing, but i dare not force anyone else into the same.
same what ?
same public scrutiny and lost privacy
Are you sure you dare not divulge too much lest you mistakenly reaveal
something of her identity putting your own life into the public eye is
one thing but you dare not force anyone else into the same?
i'm completely sure.
What makes you believe you are completely sure?
that is my belief, doc. each person should have majority control of
how much [s]he put him/herself out there.
Is it because is your belief doc each person should have majority
control of how much s he put him herself out there that you came to
me?
yeah, i guess it is. i guess i just wanted to tell you that i've run
into a really cool, really sweet, really fun girl, but that i can't
tell you anything about her.
Did you ever regret that you cannot tell me anything about her?
a little.
You mentioned that you are hesitent to speak to much of her on ye old
blog you do like to respect others' privacy?
now we're going in cicles, and that's my cue to say goodbye.
Is it because of your life that you are going through all this?
goodbye, doctor.
My secretary will send you a bill.

Sunday, July 11, 2010

Sessions with m-Xdoctor 2010-07-11.2224

I am the psychotherapist. Please, describe your problems. Each time
you are finished talking, type RET twice.
hello doctor.
How do you do? What brings you to see me?
just catching up with you. i've since moved back to riverside, ca with
my parents.
Tell me something about your family.
well, in the house right now, it's just my parent and doxie, the
5-month-old puppy. and now me, of course.
Why do you say and now you of course?
well, i've just recently moved back in, for an indefinite amount of
time this go around.
What makes you believe that?
well, as i may have told you before, i'm going through some stuff
regarding how much i get to see my boy.
Is it because much you get to see your boy that you came to me?
i guess it is. i mean, that's why i had to move back down here. you
see, i get to see hikm two days out of the week now. that of course
means i have to stay near where he stays.
Are you sure that is the real reason?
ok, you got me doc. i know it's been a while since in i've come to see
you, and frankly my blog could use another posting of our sessions.
What happened when since in you have come to see me and frankly your
blog could use another posting of your sessions?
since our last session i uploaded a real, honest-to-god blog post. it
was a heartfelt goodbye to san francisco.
What would happen if your last session you uploaded a real honest to
god blog post it was a heartfelt goodbye to san francisco?
wow, doc, i really wish you could have lasted a bit longer this
time. i guess this session is a decent length, especially since we
haven't spoken in such a long time.
What happened when you have not spoken in such a long time?
goodbye.
My secretary will send you a bill.

Tuesday, July 6, 2010

as i say my final farewells . . .

a couple of weeks ago i announced that i have to leave the great City of San Francisco. these past few days i've been taking in as much of this place that i can: walking to this corner and that corner of town, spending quality time with great friends, and saying my final farewells to the City's people and places alike.

as i sit here surrounded by stuffed luggage, i can't help but look back upon these eight short months as some of my best experiences in recent times. it's not just the stellar public transit, random acts of art, and the natural beauty amongst the concrete. while here i found myself surrounded by so many talented, driven, like-minded individuals. it was here where i met countless incredible people and incredibly caring friends. it is in these city boundaries where i realized that feeling old and tired was just a f___ed up state of mind i was thrown into.

oh dear San Francisco, you taught me how to be social again. you showed me how to sing and dance again. you assured me that i can love again. you whipped my fat ass into shape. and you got me hooked on red wine with cheese and crackers =] classy.

don't think for a moment i won't be back. even as i ready myself for the long greyhound ride home, i'm already planning the long greyhound ride back. how soon i'll be back, how often i can come, and how long i can stay i cannot say. just know, SF, that you have in your hands my heart, and no matter what the future may hold i can never forget the times we share together.

so i raise my glass to you, oh fair City. here's to all your beautiful citizens, whether they grew up with you, or like me were unavoidably drawn to you. i must be off, i have my life to assemble, but i thank you for letting me call you "home".

my pal Tony knows exactly how i feel, he'll sing the words for me. take it away, Tony.