ruby – Sheep Guarding Llama https://sheepguardingllama.com Scott Alan Miller :: A Life Online Sat, 26 Sep 2009 14:01:44 +0000 en-US hourly 1 https://wordpress.org/?v=6.9.1 Installing ruby-sqlite3 on Red Hat or CentOS Linux https://sheepguardingllama.com/2008/11/installing-ruby-sqlite3-on-red-hat-or-centos-linux/ https://sheepguardingllama.com/2008/11/installing-ruby-sqlite3-on-red-hat-or-centos-linux/#comments Sun, 23 Nov 2008 22:04:22 +0000 http://www.sheepguardingllama.com/?p=3012 Continue reading "Installing ruby-sqlite3 on Red Hat or CentOS Linux"

]]>
For my development environment, I like to SQLite3 on Red Hat Enterprise Linux (RHEL / CentOS.)  When working with the gem installer for the sqlite-ruby package I kept getting an error on my newest machine.  I searched online and found no answers anywhere while finding many people having this save problem.  I have found a solution.  There is no need to compile Ruby again from source.

The command used was:

gem install sqlite3-ruby

What I found was the following error:

gem install sqlite3-ruby
Building native extensions.  This could take a while…
ERROR:  Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb install sqlite3-ruby
checking for fdatasync() in -lrt… no
checking for sqlite3.h… no

make
make: *** No rule to make target `ruby.h’, needed by `sqlite3_api_wrap.o’.  Stop.

Gem files will remain installed in /usr/lib64/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4 for inspection.
Results logged to /usr/lib64/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out

There are two main causes of this problem.  The first is that the correct dev packages are not installed.  Be sure that you install the correct packages for Red Hat.  In RHEL 5, which I use, SQLite3 is now simply SQLite.

yum install ruby-devel sqlite sqlite-devel ruby-rdoc

If you are still receiving the error then you most likely do not have a C compiler installed.  The Gem system needs make and the GCC.  So install those as well.  (Obviously you could combine these two steps.)

yum install make gcc

Voila, you SQLite / SQLite3 installation on Red Hat (RHEL), Fedora, or CentOS Linux should be working fine.  Now your “rake db:migrate” should be working.

Update: If you follow these direction and get the error that sqlite3-ruby requires Ruby version > 1.8.5 then you can go to my follow-up directions on
SQLite3-Ruby Gem Version Issues on Red Hat Linux and CentOS

]]>
https://sheepguardingllama.com/2008/11/installing-ruby-sqlite3-on-red-hat-or-centos-linux/feed/ 16
Simple Ruby Twitter Client – Tweet [Ruby] https://sheepguardingllama.com/2008/10/simple-ruby-twitter-client-tweet-ruby/ https://sheepguardingllama.com/2008/10/simple-ruby-twitter-client-tweet-ruby/#comments Fri, 31 Oct 2008 18:41:58 +0000 http://www.sheepguardingllama.com/?p=2833 Continue reading "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.’

]]>
https://sheepguardingllama.com/2008/10/simple-ruby-twitter-client-tweet-ruby/feed/ 5
October 6, 2008: A Day with No Title, Oops https://sheepguardingllama.com/2008/10/october-6-2008/ https://sheepguardingllama.com/2008/10/october-6-2008/#respond Tue, 07 Oct 2008 16:23:53 +0000 http://www.sheepguardingllama.com/?p=2670 Continue reading "October 6, 2008: A Day with No Title, Oops"

]]>
46 Days to Baby Day! (33 Weeks and Three Days Pregnant)

18 Work Days Left for Dominica; House closing in 1 – 19 days.

I am on the early morning shift today so Dominica got me up when she got up to get ready to go to work.  The office was pretty slow this morning.  It was a nice morning to be on the early shift.

For breakfast I ran over to Airlie Cafe and picked up a sandwich.  Oreo is happy to be home with me today.  He spent the entire morning sitting in the brown chair in the living room right beside my desk all bundled in his wool blankets like a little papoose (actually, at 25lbs, he is a rather large papoose.)  I have the windows open and am wearing a sweatshirt around the apartment.

Today feels a bit like winter.  It is dark and cold and the streets are mostly barren of people.  The apartment is rather chilly.  Yesterday was much, much warmer.  According to the Weather Channel, today is supposed to be the coldest day in the first half of October.  Too bad, today would have been the perfect weather for moving.

I got my “classwork” done for my RIT class first thing this morning giving me a bit of a jump on the week.  Then I went on and read all of the reading assignments for this week.  Then, as there was more time available, I just went ahead and did this week’s homework!  Talk about getting a jump on the week.  I completed the entire week’s work on the morning of the first day!  This is going to be a really busy week, though, so getting this out of the way was a really good idea.

Today is another wild ride for the financial markets.  What a day.  Today the Dow fell below 10,000 points taken us to the lowest market levels in four years!  At least I can say that it is an interesting time to be working in the financial markets.

I went to do the work that I needed to do for BrainBench today and realized that my manager had not applied the work that I did last time correctly and that now we had two rounds of work having been completed based on work that was not correct.  All of this came about because the web site that I use to do my workflow with them doesn’t have all of the necessary functionality implemented so I have to have my manager at BB do some of the work for me.

Today was a scary day on the market.  At one point we had a drop of over 800 points – the all time largest point drop.  But at the end of the day it was just over 300 points down.  Still a pretty bad day.  Oil dropped to just under $88 though so gas should be getting cheaper quickly which will, in theory, encourage people to do some additional spending.  If it stays down until Christmas it might have a significant impact on Christmas shopping habits.

The weather was crazy here today.  Very cold this morning.  Then mid-afternoon it got so warm and sunny that Dominica was driving the convertible with the top down when she went to lunch.  Then by five it was cold and windy again.

Katie saw gas at $3.03 in NJ yesterday.  Imagine what it will be tomorrow!

On her way home from work Dominica picked up food from Cheeseburger in Paradise.  We get BBQ Cheddar Veggie Burgers from there.  They are pretty good.  Although what I really miss is the veggie burger from Tom Wahl’s in Avon, New York.  They make the best veggie burger anywhere.

We watched several episodes of Magnum P.I. during and after dinner.  Dominica has gotten hooked on that show.  It really is a classic.  She went to bed around nine or nine thirty.  I went out to the office and continued studying Ruby on Rails from the book that I finished this weekend.  I am attempting to do all of the samples and examples in the book to get as much out of it as possible.  I am having a lot of run with it.

To get a little more out of the book I decided to adapt the project in the book to SQLite instead of MySQL which they use.  I have used MySQL a lot over the years but have never used SQLite in my own project and was interested to see it at work.

I stayed up until elevenish and then headed off to bed myself.  Tomorrow will be my only day on Wall Street this week.  The weather is nice, though, so I am looking forward to not overheating on my walk into the office.

]]>
https://sheepguardingllama.com/2008/10/october-6-2008/feed/ 0
Ruby/Qt: qtruby4.rb:2144: [BUG] [x86_64-linux] https://sheepguardingllama.com/2008/10/rubyqt-qtruby4rb2144-bug-x86_64-linux/ https://sheepguardingllama.com/2008/10/rubyqt-qtruby4rb2144-bug-x86_64-linux/#respond Sat, 04 Oct 2008 17:01:50 +0000 http://www.sheepguardingllama.com/?p=2661 Continue reading "Ruby/Qt: qtruby4.rb:2144: [BUG] [x86_64-linux]"

]]>
You are working with Ruby and Qt and you get the following error:

/usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation fault
ruby 1.8.6 (2008-03-03) [x86_64-linux]

This is usually caused by a library linking problem. Most likely you are using:

require 'Qt'

Personally, I run into this problem when using Ruby/Qt on Novell OpenSUSE 11 64bit (x86_64 / AMD64).  What needs to be done is that linking needs to occur explicitly to the correct library.  If you are using ‘Qt3’ then you can link directly to that or, in my case, you want to use Qt4/KDE4 bindings then you will want to link to korundum4:

require 'korundum4'

Problem solved!

Thanks to Bemerkenswertes Meinerseits for some guidance in German!

]]>
https://sheepguardingllama.com/2008/10/rubyqt-qtruby4rb2144-bug-x86_64-linux/feed/ 0
June 20, 2008: Introducing HandBrake Helper https://sheepguardingllama.com/2008/06/june-20-2008-introducing-handbrake-helper/ https://sheepguardingllama.com/2008/06/june-20-2008-introducing-handbrake-helper/#respond Sat, 21 Jun 2008 09:29:02 +0000 http://www.sheepguardingllama.com/?p=2417 Continue reading "June 20, 2008: Introducing HandBrake Helper"

]]>
Oreo was incredibly tired as Dominica dragged him off to daycare this morning. He was giving me the big, sad puppy dog eyes saying “save me daddy” which he does when he really, really wants to just stay home and sleep. He doesn’t know that on days when he goes to daycare that I get up as he walks out the door and start working right away. He imagines that after he leaves that I stay in bed and he just wants to snuggle all morning.

We managed to do so much Handbraking that we are running out of storage space – which is a big deal since I have half of a terabyte on my main desktop reserved for h.264 files and am using a bit of space over on my other desktop as well.  I have to start moving files out to the Netgear SC-101 SAN drives now.  We have an additional one terabyte there but access to it is painfully slow and less reliable so we don’t want to store anything there that we want to access anytime soon or that we are worried about losing.  Our plan is, after we get a house, to install a large server dedicated to our media archives that will have lightning fast access to everything all in one spot.  We are hoping to be able to install around eight to twelve terabytes there  as that is pretty likely to be what we will need in the short term to power our AppleTV(s).

I kicked off the download of OpenSuse 11.0 this morning.  It is still early and people are trying hard to get their own copies so the downloads are pretty slow but at least I have it running.  Maybe by tomorrow I can try an installation.  I am doing the download over BitTorrent which isn’t the fastest way to get it, yet, but at least I am contributing to making the system faster so that other people can get it that much more quickly.

My work day was pretty long.  I started at ten after seven this morning and my deployments were not completed until almost eight in the evening.  We ordered in Chinese for dinner from Golden City.  They ran out of tofu so there was only enough to make Dominica’s dinner but not mine.  So I had vegetable fried rice and extra spring rolls and cheese wontons which was a bad idea as it gave me a tummy ache which would get me up in the middle of the night for quite a while.

We watched more Third Rock from the Sun tonight.  I also started work on a neat little Ruby command line application that makes doing a large number of Handbrake jobs easier.  I call it HandBrake Helper.  The design is to have folders into which you can drop files to be processed by HandBrake.  Each folder has a configuration file in it telling HandBrake what settings should be used for files in that folder.  Then you just place your files to be converted into the appropriate folder and kick off HandBrake Helper and it automatically processes your files for you and cleans up after itself.  I just started work on it this evening but had enough done that it is now running the HandBrake jobs on my Linux machines.  I was able to kick it off before going to bed so that it would work through the night for me.  Using HandBrake Helper makes doing conversions much more convenient and it keeps track of my preferred settings so that I don’t have to enter them every time hoping that I don’t get them wrong.

Tomorrow Dominica and I are going in to Manhattan around eleven in the morning to meet up with Nathan, Tammy, Bob, Lisa, Eric and other friends from Ithaca at Planet Hollywood for lunch.  Then it is on to see Mary Poppins on Broadway at a matinée.

]]>
https://sheepguardingllama.com/2008/06/june-20-2008-introducing-handbrake-helper/feed/ 0
January 30, 2008: First Netflix Movie https://sheepguardingllama.com/2008/01/january-30-2008-first-netflix-movie/ https://sheepguardingllama.com/2008/01/january-30-2008-first-netflix-movie/#respond Thu, 31 Jan 2008 04:36:49 +0000 http://www.sheepguardingllama.com/?p=2241 Continue reading "January 30, 2008: First Netflix Movie"

]]>
I was exhausted this morning, the last few days have been catching up with me, and so decided to sleep in with Oreo for a little while and leave about the same time as Dominica. I was surprised to find that it was decently warm and raining when I got outside. I can’t believe that it is January. (Or February -1 as we say at work.)

I stopped at Cafe Airlie on the way through and got my usual egg, cheese and potato with black pepper on a hardroll and some apple juice for my walk to the train station. It is so warm out that even with a light rain my fleece is a bit too much and I am too warm.

Dominica discovered this bit of disturbia today that occurred along a highway that we drive past on a regular basis. This is right along our normal route between Newark and “back home.” Although now we tend to go out to Williamsport before heading north.
Things were relatively busy at the office today. But busy in big bursts. Really busy bits with large bits of nothing as well.

I learned today that the coach of the New Jersey Giants (an American Football team from Rutherford, New Jersey which is playing in the NFL Super Bowl this year) used to be the coach of the Rochester Institute of Technology, RIT, Tigers. RIT is where I am currently attending for my Masters of Information Technology degree.

My Ruby based email log processing script ran today processing about two million database rows of data. That took several hours of intensive processing. It was 230MB of data sitting in my email account that had to be moved out. But that is a lot of stuff that isn’t stored in there anymore and that is no longer stored on my home storage area network (SAN.) I am very happy with how the script is working.

I did have to make some modifications to the script to get it to process all of the rows correctly. I had not dealt with some older data yet and there were some “end of log” messages, some unnecessary quotation marks and some bad line feeds that needed to be stripped out. But the script is more robust now and is getting better by the day. I think that by tomorrow night that I will most likely be done with all of the archival email processing except, possibly, for one small batch that needs some special oversight. Then I can focus on some reporting tools to dig into all of the data that I have been collecting.

I did some reading in “Practical Ruby for System Administration” today and learned some new tricks for using Ruby as part of by BASH command line. I never think of using Ruby (or Perl, for that matter) in a “one liner” or in-line mode. But it can be extremely useful for that. So I think that this is some good learning for me.

During her lunch break today Dominica went shopping and picked up a folding table for us to use in our apartment. We have been without anything resembling a table for two years now and it is beginning to be a problem. We definitely need a table for our Dungeons and Dragons games. So she picked one up at Home Depot. She also picked up some shoes while she was out. Her shoe collection is getting pretty big.

Dad lost power due to a massive windstorm tearing across Upstate New York today. We were talking over instant messenger when his power went out and he disappeared. It was gone for what seemed like four or five hours but it was on again by the time that I got home from the office.

I had to rush home so that I could help her to unload the car but she got stuck in traffic and I was home almost an hour before her anyway even though we left at almost exactly the same time (she left five to ten minutes before me.) I got home and logged right back into work and put in another hour or so. Then I helped Dominica unload the car, we fed the dog and we ran right over to Food for Life for a quick dinner.

After dinner we came home and I wrapped up the “office” work, started in on my Project Management homework, read some of “Manage It!” by Johanna Rothman which I am trying to finish reading this week and kicked off another long round of email transfers so that I can continue the process of migrating the data into the database. I can’t believe that I am already into the seventh week of my Project Management class. It is amazing to me how quickly the classes just fly by. When I was young they seem to drag on forever. Now I can’t even seem to get a chance to get into one before it is over.

Our first Netflix DVD came via the post today – 28 Weeks Later. It is the sequel to 28 Days Later which is one of the greatest, if not the greatest zombie apocalypse films of all time. Dominica has been extremely anxious to watch it. So I am trying to make time tonight so that we can watch it. If we don’t get to watch it tonight it could be a long time before we get to see it and one of the problems with Netflix and us is that if we don’t get to watch one movie then we don’t get to move on to another movie until we do. This is a problem when there is a movie that we both want to watch like this one. Normally the plan is for Dominica to get movies that only she wants to watch and use Netflix as a method of providing just her with movies so that she can watch them when I am working. It is already apparent how difficult a serialized movie stream will be if we try to watch everything together.

Dominica did some homework tonight as well for her GPS and the New Geography class. I pointed her in the direction of the O’Reilly Where 2.0 Conference which is perfectly tied in with her class. If you are interested in the content from the conference from 2005 through 2007 you can listen to the talks and panel discussions on IT Conversations for free. Very good stuff. Well worth a listen.

Tomorrow is a doggie-daddy day. Oreo is very excited. He was totally ready for today to be his sleep-in day but had to go to daycare. I will be working from home tomorrow and performing a much needed clean up of the apartment. Tomorrow night Dominica and I are heading to the Prudential Center for the first time and will be seeing the live show of Dancing with the Stars which was one of my Christmas presents for Dominica (yes, she actually asked for that.) The really cool thing about the show is that we will get to see Wayne Newton who will be singing, but not dancing, at the show. On Friday we are thinking about heading north up to my dad’s place to visit for the weekend (surprise dad!) But we will have to see how the weather is going to be. We don’t want to be driving in snow. But we do want to avoid the American football game this weekend.

It was almost nine when we started watching 28 Weeks Later. The movie was very interesting because it takes place in London and specifically on Canary Wharf where I worked while I was there just a couple of months ago. They showed people riding the DLR, getting off at Canary Wharf train station and had tons of footage of the buildings, Citi London and One Canada Square, that I worked in while I was there. There was just tons of shots all over the place that Dominica and I got to go which was incredibly cool. But that didn’t redeem the movie which was a horribly cheesy successor to the first film. This film seemed to be a zombie apocalypse cover for social commentary on the US military today. It was not an enjoyable film in the least. The plot was weak and boring and the gross factor was way too high and unnecessary. And every character in the movie was so horribly stupid and everything relied on so much coincidence and plot holes that it made no sense at all. I would avoid this movie unless you just can’t resist seeing Canary Wharf and the Isle of Dogs firebombed. And even then, just watch those bits. For those of us who have worked there it is pretty neat to see your office used as the site of a zombie infestation!

After that we popped in an episode of The Fresh Prince of Bel Air to watch before heading off to bed. The final result is that the movie was bad but Netflix is a great deal and we are very excited to be using it now.

]]>
https://sheepguardingllama.com/2008/01/january-30-2008-first-netflix-movie/feed/ 0
January 29, 2008: Books, Email and Logs https://sheepguardingllama.com/2008/01/january-29-2008-books-email-and-logs/ https://sheepguardingllama.com/2008/01/january-29-2008-books-email-and-logs/#respond Wed, 30 Jan 2008 17:52:05 +0000 http://www.sheepguardingllama.com/?p=2240 Continue reading "January 29, 2008: Books, Email and Logs"

]]>
I got up nice and early this morning and got right into the office. I am trying to get myself back on to my early schedule. That always works out so much better for me.

I got some maintenance work done on SGL today. The biggest change is that I am tracking the site using Google Analytics now. So I am quite excited to see how that works. I think that we will find that my traffic profile is a lot better than Word Press Stats suggest. I am also quite interested to see more historical data and geographic data.

Today I finished “reading” “Lost Discoveries : The Ancient Roots of Modern Science–from the Babylonians to the Maya” by Dick Teresi. It is a fascinating book and covers a lot of interesting ground. A great read although, like most things that I enjoy, rather dry.

I began “reading” Simon Winchester’s “Outposts: Journeys to the Surviving Relics of the British Empire” which is an interesting look at the remains of Britain’s once vast empire now reduced to mostly tiny islands scattered to the four corners of the world. Winchester is one of my favourite authors and always has great insight no matter what he is working on. Unfortunately “Outposts” had to be abridged for the audio version and the parts on Hong Kong and the Falkland Islands were left “on the cutting room floor” so to speak. Although Hong Kong is no longer a relic of the empire it was at the time of the original writing.

Today was busy and I was stuck in the office a little late again. But not too bad. I had my now usual falafel lunch from the little Halal truck one block west of here and got through the day.

On the way home I swung into Borders on Broadway and found a book on Ruby that I was looking for: “Practical Ruby for System Administration” by Andre Ben Hamou and APress.  I prefer Ruby to Perl for system administration tasks (and most everything else) and was interested to see what this book might have to offer.  It had a warm reception in some online reviews that I read so I decided that as a full time system administrator who uses Ruby it just seemed appropriate that I should have this book if for no other purposes than knowing whether or not to recommend it to others.

I did some work on my Ruby script for reading in Netgear firewall logs via IMAP and parsing them into a MySQL Database.  My script is working pretty well now.  I updated it so that it now logs to the system event log which is very handy for trouble shooting.  I also set it to run every hour on the hour so that my email mailbox stays clean.  Now I don’t have to worry about manually running it all of the time.

Tonight I started the project of taking all of my old, archived Netgear firewall logs that were downloaded to Thunderbird and saved as an offline folder and put onto my home SAN – my Netgear SC101.  I remounted the offline folder to Thunderbird and began the process of reloading the data onto the email server for processing.  There are scores of thousands of emails to be uploaded.  This is going to be quite a project that will definitely take a few days at the least.  I moved as many as I could tonight before going to bed.

Dominica was in the mood for makizushi sushi and so decided to have some delivered.  I wasn’t very hungry and sushi didn’t really do it for me.  The food was good but I really don’t enjoy sushi all that much.  We don’t get sashimi very often.  It is the seaweed and rice rolls (makizushi) that Dominica really enjoys.  I don’t mind it but it doesn’t get me very excited and I just wasn’t in the mood for it tonight.

We watched a few episodes of The Fresh Prince of Bel Air and tried to call it an early night.  We haven’t been getting enough sleep and are starting to get tired.

]]>
https://sheepguardingllama.com/2008/01/january-29-2008-books-email-and-logs/feed/ 0