Simple Ruby Twitter Client – Tweet [Ruby]

This is my simple, Ruby based Twitter client using Curl designed for UNIX systems like Linux, Mac OSX, FreeBSD, Solaris, etc.  The only requirements are Curl and Ruby.

In order to use Tweet, simply copy all of the included code into your favourite text editor (I use vi) and save as ‘Tweet’.  Don’t forget to “chmod a+x tweet” so that it is executable.  I suggest moving Tweet into your path (perhaps you should consider /usr/local/bin as a recommended directory) to make it easier to use.  I have designed Tweet to be useful to users on a multi-user UNIX system.  It is a command-line utility that simply accepts text input and posts that text, maximum of 144 characters, to your Twitter account.  An existing Twitter account is necessary so sign up if you do not have one already.

There is very little to know in order to use Tweet [Ruby].  (Should I name this RTweet perhaps?)  The one thing that is needed is to set your username and password.  Tweet [Ruby] is designed to accept username and password data from the system environmental variables $tweetuser and $tweetpass.  This design decision was made because it makes it extremely simple to have multiple users on the same system be able to use Tweet [Ruby] transparently from one another.  If you desire, you can bypass this setting by changing the “unset” user and pass settings in the code to your username and password.  This hardcoding is not recommended but is available if needed.

Once you have your username and password set (you can see what your settings currently are by using the -t option) all you need to do is enter the text that you want to publish.  Here is an example:

tweet ‘This is my first post from Tweet [Ruby].  Thanks Scott, this is great.’

Here is the code, go crazy.

#!/usr/bin/ruby -w
#Scott Alan Miller's "Tweet" - Twitter Command Line Script

text = ARGV[0].chomp
user = "unset"         #Supplied Username
pass = "unset"         #Supplied Password
url  = "http://twitter.com/statuses/update.xml"
ver  = "1.0"

user = ENV['tweetuser'] if ENV['tweetuser']
pass = ENV['tweetpass'] if ENV['tweetpass']

if    text.length <= 0
  puts "Please enter text to post."
elsif text.length >= 144
  puts "Please limit post to 144 chars."
elsif text == "-v"  # Version Message
  puts "Current Version of Tweet [Ruby] is " + ver
elsif text == "-h"  # Help Message
  puts "Tweet [Ruby] Help: \n"
  puts "To set environmental username and password:"
  puts "  export tweetuser=yourusername"
  puts "  export tweetpass=yourpassword\n"
  puts "Usage:"
  puts "  tweet \'This is my message.\'"
elsif text == "-t"  # Variable Test
  puts "Username: " + user
  puts "Password: " + pass
else
  result = %x[curl -s -S -u #{user}:#{pass} -d status="#{text}" #{url}]
  puts "Update Failure" if result.grep(/text/) == nil
end

If you end up using my little Twitter client, please send me a Tweet to let me know!

tweet ‘@scottalanmiller Using Tweet, best Twitter client ever.  Ruby rulz.’

October 30, 2008 Part Three

And the long day continues…

It was almost eight by the time that the maid wrapped up and we were in the process of loading the car.  When we went down to the lobby to get the car loaded we ran into a ton of people on their way to the halloween party and everyone kept asking us to go.  We finally caved in and decided to put in an appearance.

We love the Eleven80 Halloween Party, it is awesome.  It is Eleven80’s biggest event of the year.  A lot of people were really disappointed that they didn’t get to see Oreo compete in the dog costume contest this year.  He won last year and has a really cool pirate (salty dog?) costume this year that Dominica’s mom made for him.  He is the only dog that always has a custom made costume.  He looks so adorable in it.  He was far and away the favourite to win this year but with him being in Peekskill there was no way for us to get him down to Newark in time for the judging.

We stayed at the party for maybe half an hour.  It wasn’t very long.  We did not venture in very far and only made it to the ramp of the bowling alley.  We got to see several people just before leaving so that was good.  It is really starting to hit us tonight that we are leaving and really have been here for a really long time and know a lot of people now.  This is our third Eleven80 Halloween Party.  We were invited back for next year’s party and we will definitely make an effort to come visit.  Oreo would love to be back for an evening and show off his costume.

We hit the road around nine thirty with a very loaded car full of plants and food from the apartment.  It was almost eleven when we arrived in Peekskill!  We had not been planning on having been out this late.  What a long day.  We are not sorry that we delayed and stopped by the party, though, as it was really good to get to say some goodbyes.

Dad and aunt Sharon were still awake when we got to the house although they sure were not going to be awake for much longer.  Oreo had really been missing us all day and spent the day following dad around like, well, like a lost puppy.  We unloaded the car and visited for twenty minutes or so and got to get a first look at how the painting has been coming along.  The upstairs looks awesome.  The nursery is all but done and the master bathroom is done and bits of the master bedroom are done (there is just a master bedroom and the nursery as far as bedrooms go.)  They are hoping to complete the master bedroom tomorrow.

Dominica, Oreo and I arrived back at Eleven80 in Newark at one thirty in the morning.  Wow were we tired.  We pumped up the air mattress and did some quick, last minute packing to be sure that we were ready for tomorrow morning and got to bed sometime around a quarter till two!  The alarm was set for five thirty so this is a very short night.

No sooner than we dropped off to sleep on the not very comfortable air mattress than the phone rang, it was ten after two in the morning, from the valet saying that our car was double parked and blocking the street and that they needed our keys.  We had dropped off the keys so we were pretty confused.  I got out of bed and searched around the completely empty apartment for a few minutes before Kamil, the concierge, found where they had fallen behind a computer monitor on the desk and had disappeared.  So our short, less than four hour night was now a much less than four hour night with an interruption in the middle of it.  Tomorrow morning is going to be rough.

There is very little for us to do in the morning.  We are both going to shower, pack up the few clothes that we have here, deflate the bed, load the car, get Oreo ready for his daycare halloween party and get Dominica off to her final day at work.  (Her finaly official day.  We’ve decided that if she feels well enough come Monday that she is going to work Monday and Tuesday of next week.  Those are the two busiest days for her office when they will miss her the most.  Then she will take her three bereavement days and that will round out the week.  It will be a full five days later before she could work again and there is no way that she will be able to do so that close to the baby day.)  Then, as soon as Dominica leaves for work I am orchestrating the check-out of the apartment.  That is just a brief walkthrough to determine any damage, stains, missing parts, etc. in the apartment for which we will be charged.  Very quick and easy.  Then I will take the PATH from Newark to the WTC for the last time.

After work tomorrow we all just head to Peekskill and shift completely to our new home!

Twitter from the Linux Command Line

Okay, so you are a crazy BASH or Korn shell nut (DASH, ASH, TCSH, CSH, ZSH, etc., etc. yes, I mean all of you) and you totally want to be able to Tweet on your Twitter feed without going to one of those krufty GUI utilities.  Such overkill for such a simple task.  I feel your pain.  When I found this little nugget of command line coolness I just had to share it with all of you.  Special thanks to Marco Kotrotsos from Incredicorp who published this on IBM Developer Works.

If you have curl installed, all you need to do is:

curl -u username:pass -d status=”text” http://twitter.com/statuses/update.xml

So, to give you a real world example, if you are “bobtheuser” and your password is “pass1234” and you want to say “Hey, my first UNIX Shell Tweet.” then you just need to:

curl -u bobtheuser:pass1234 -d status="Hey, my first UNIX Shell Tweet." \
http://twitter.com/statuses/update.xml

You will get some feedback in the form of a response XML file. Happy Tweeting!

Disclaimer: I realize that using “Linux” in the subject is misleading.  This is not a Linux specific post but will apply to FreeBSD, OpenBSD, NetBSD, Mac OSX, UNIX, Solaris, AIX, Windows with Cygwin or just about any system with a command line and the curl utility installed.

I use this as the basis for my Ruby based Twitter Client for the command line.

October 30, 2008 Continued

I took the PATH to Newark at one and arrived at Eleven80 just after two.  In the middle of the day without any traffic whatsoever it takes about sixty five minutes to get from office to home in Newark and seventy to seventy five minutes during rush hour and more when the weather is warmer because I have to walk so much slower.  Today was extra fast because I actually had to run for the PATH train doors as they were closing just as I made it to the platform.

I got to the apartment and got logged back in to the office and then spent an hour working and cleaning as much as I could to get ready for the maid service to arrive.  I know that it sounds strange to be cleaning ahead of the maid but this is the move out final cleaning and I have to get absolutely everything out of her way so that she can really clean.  We have her booked for four hours today!

I am a member of some Disney photo groups on Flickr and one of them had a Disney ride competition this week.   I was flipping through some of the pictures and found an image of the final scene from Walt’s original Carousel of Progress as seen in 1979.  The ride was updated in 1981 to the final scene that I saw the first two times that I went to Walt Disney World.  In 1993 it was updated again to the travesty atrocity that they have now.  I really wish that they would put it back.  It was so much better before.  The way that Walt intended it to be with each scene being twenty years after the one before.  Now the scenes are 1904, 1924, 1944 and this weird, Orwellian view of 2004 actually made in 1993.  It is awful.  The 1981 update that I originally saw was not too bad even though they tore out 1964 to put in 1984.  It was close enough that it at least still worked more or less.

The maid from Maids on Call arrived right at three and got right to work.  She is scheduled to be here until seven.  That is a long day.

Tonight is Dominica and my very last chance to have dinner in Newark – at least while living here.  So, for old time’s sake, we ordered in dinner from Food for Life.  It just wouldn’t be right to not have FFL on our final night in Newark.  It is so hard to believe that our first meal at Food for Life in Newark was more than two years ago!  It doesn’t seem like that at all.  The first time that we ate at Food for Life was September 26, 2006.  Twenty-five months ago.

I got the BLT that I first got that very first time at FFL.  Just for old times’ sake.  It is still delicious after all of this time.  I didn’t really think about moving out of Newark much until I went into Food for Life.  It was completely empty except for the employees and me, just like our first night there.  I got a chance to say goodbye.  It is weird that the people who work there now have only been working there for half as long as we have been going there regularly.

It is a quarter after seven now.  I am shutting down the laptop in the apartment now to go offline and to pack up everything that is remaining.  I have been working for the last five hours just standing at the kitchen counter.  My feet are killing me.  We have to make a run to and from Peekskill yet tonight.  It is a very long night.

We are very sad that we have to miss the awesome Eleven80 Halloween Party.  It was awesome last year and we were really looking forward to it again this year but there is just no way that we can take the time to do that tonight.

October 30, 2008: Getting the Apartment Ready

22 Days to Baby Day! (36 Weeks and Six Days Pregnant)

1 Work Day Left for Dominica.

“Information wants to be ambient.” – Erin McKean, Lexicographer

Scott’s new words for today: layoffable and layoffability.  In reference to “how layoffable” a certain employee is.  The more layoffable you are the easier it is for the company to lay you off.  If you are completely critical to the firm then you are not very layoffable or your layoffability is very low.  Go ahead, start using them.  It’s fun.

I got to Peekskill Station without any problems at 9:23 last night.  I was running to make the train home.  I really did not want to miss it or it was going to be one crazy late night for me.  I got to check out the Peekskill waterfront at night while I waited for the family to come pick me up.  There is a bar in the train station itself as well as the Peekskill Brewery being right across the street.  These will be handy for evenings when I get it but have to wait before Dominica is able to pick me up from the train.  I also found that there were taxis waiting at the station when the train arrived which will definitely come in handy from time to time when Dominica just can’t get down to the station to get me or, for example, when Dominica goes into labor and I have to rush to the hospital from Manhattan.

Everyone came down to the station and picked me up around nine thirty.  It was pretty chilly standing outside without a jacket this evening.  They were coming to get me straight from having dinner at the New City Diner which Dominica raved about again being extremely happy with her meal there.  That is our third time eating there this week.

For dinner, Dominica picked up fish and chips for me.  They have awesome fish and chips at the New City Diner.  We went home and I ate dinner then everyone had the pear tartlets that I brought home from Financier Patisserie.  Those were really amazing.  Dad and aunt Sharon were not prepared for how awesome real patisserie desserts are.

We did our best to make it an early night but there was not much hope.  It was around eleven when we all finally managed to get to bed.  It is going to be a short night.

Today was the only day that Dominica and I both need to commute from Peekskill.  We were up at five thirty and out the door around six fifty.  Dominica dropped me at the Peekskill Station where I easily caught the 7:08 Metro North train to Grand Central Terminal in Manhattan.  She drove on from Peekskill north over the Bear Mountain Bridge and down to Totowa, New Jersey.  She was in the office by 7:53 which was not bad at all.  She made great time for rush hour.

The views from Peekskill Station are awesome.  While I was waiting for the morning commuter train I got to watch the freight trains in Orange County across the Hudson River lazily winding their way along the river’s edge.  It is so cool to watch trains across the river.  The lower Hudson Valley is one of the greatest train watching spots ever.  You can also watch traffic as it winds down from Bear Mountain Bridge on either side of the river.  And the ferry boats making their way towards the city.  I wish that there was a ferry that I could take so that I could alternate routes to shake things up a bit but no such luck coming from Peekskill.  Nyack has a very cool ferry, I hear from Katie.

The ride was nice.  The train was definitely full this morning.  Not standing room only but every seat was taken.  Peekskill is one of the later stops with only Cortlandt and Croton-Harman being “pickup” stops made before the Harlem and Grand Central drop off stops.

At Grand Central Terminal I managed to pick up the Peekskill/Cordlandt Schedule to carry with me.  That will make things easier when I am rushing for the trains at night.  I got to ride the “sardine train”, the Lexington Avenue Express (5) from GCT to Wall Street today.  Katie has been warning me about it.  Everyone tries to avoid teh 4 & 5 trains in the morning as they are awful but there is very little that I can do to get around it.  I managed to get onto the first train this morning but it was definitely back completely full and very uncomfortable.  More like riding on the London Underground (the Tube) or DLR than riding a New York City subway.

I timed my trip carefully this morning and with the Lex Express getting stuck around Utica Station for almost ten minutes and me grabbing a bagel and coffee (sesame seed with cream cheese, large with milk and no sugar, of course) on the way the time from door to desk was one hour and fifty minutes.  That’s total travel time.  Less than two hours from the time I step at the door until I am typing on my computer.  It is a very long commute but a comfortable one that I am not going to mind so much.  I really do get a lot of chance to read, listen to podcasts, microblog (tweet) and just relax and have some time to myself.  Once we master the time that we need to leave the house, get a monthly pass rather than buying the tickets on the platform and if I don’t get stuck anywhere the trip could theoretically be shaved to as little as one hour and thirty five minutes from door to desk, and that is during rush hour.  There are times that it could, with the right set of trains, be as little as one hour and twenty five minutes.

No sooner do I learn this new commute that I get to the office and learn that the rumour mill says that I am being relocated, again.  This time up to Tribeca to the fixed income trading floors.  The move is not all bad, of course, as there is always some amount of silver lining.  Chances are that I would maintain my Wall Street office in addition to my spot on the floor (the floor would be paid for from a different budget, I believe.)  The commute will be longer by a bit and more of a pain.  There is the problem of the gym, as well, since there is no gym with a pool anywhere near the Tribeca building.  So I would need to commute from Tribeca to Downtown in order to swim.  The upside is that it is a higher profile position sitting directly on the floor.  Not that being high profile is all good, but it isn’t all bad either.  (I was told that it was very unlikely that this would actually happen.  We will wait and see.)

To add to all of our stress, Dominica found out that tomorrow is our last day of open enrollment for our health care coverage from Siemens so we have to decide on health plans, tonight.  Deciding in a few weeks would be so much better.  We are stuck going to a less expensive plan too because we start paying out of pocket for the coverage starting pretty soon.  That is going to be very, very painful.  We decided to move to a lower cost HMO plan that is still going to cost us more than $1,050 per month out of pocket.  Eek!

I also had to deal with homeowner’s insurance this morning.  Apparently it is required that we be covered by our homeowner’s association even though they refused to disclose any and all homeowner’s association information prior to the sale of the house.  I called the insurance company early this morning to attempt to get things rolling.  I need to make changes for the cars anyway since we have a new address and now that Dominica is not going to be commuting at all.

Serious email delays at the office this morning.  Thirty to forty minutes for internal email delivery.  That makes for quite a mess.

Jim Zemlin, executive director of the Linux Foundation, has an interesting post recently about how it is possible that Linux will be shipping on more computers (desktops, laptops, etc., not servers) next year than Windows.  It is a short and interesting article.  Very interesting that Linux may make it on to the majority of user’s computers without them even realizing that Linux is providing a significant base to their user experience rather than Windows.  The Linux distro causing the splash (sorry) is SplashTop.  Interesting product indeed.

A related product is the new Asus EeePC B202.  I don’t know too much about it, but it definitely looks quite interesting.  It is a lot like having a desktop version of the EeePC Netbook.  Not a very powerful machine but very inexpensive and has been doing quite well for certain uses.  I expect that this type of device will become increasingly popular as more and more people need environmentally friendly, almost-always on email and browsing solutions for their home.  In a world where people have become accustomed to always being able to check their email and lookup movies on IMDB, get an anwer from Wikipedia, read a blog, grab a recipe, etc. having a nearly instant-on computer that uses almost no resources, generates almost no noise or heat and costs very little could be a pretty big player.  Look for more devices like this to be appearing from the big vendors once people begin to realize the need for something in this niche.  Add in the ability to handle lots of media (just add a dash of VideoLAN’s VLC player) and you have one awesome piece of equipment.

Today is another super busy day with house and apartment stuff so I know that I am not going to have very much time to write and post SGL so my plan is actually to post very, very early in the day.  I am leaving the office during my lunch window and taking the train back to Newark.  I will be working from Newark for the afternoon.  I have to be there to coordinate with the maid service who is cleaning the apartment today for the check out.  Then, as soon as Dominica can get to Newark from Totowa after work, we are loading up the car with everything that we can fit into it and taking a load up to Peekskill.  That should include all of the plants at the very least.  Then we will return to Newark with the air mattress and Oreo where we will spend the night.

Tomorrow Oreo is going to daycare to his halloween party.  Dominica is going to her last day of work.  I am staying in Newark to do the final apartment move out inspection with Ramone then I am taking my final commute on the PATH.   And at the end of the day we are commuting from Wall Street and Totowa up to Peekskill and will be completely done with our life in New Jersey.

It is one in the afternoon and I am signing off now to head back to Newark.