Satya's blog - 2010/

Aug 23 2010 00:28 Backups on Amazon EC2

If you like to rsync/rdiff your backups to an EBS volume on Amazon, this script will spin up a spot instance, attach the volume, run your backup, detach, and cleanup. A little bash knowledge and EC2 knowledge is required.

Original from http://roeeb.blogspot.com/2010/03/backup-to-amazon-ec2-using-spot.html (who seems to have got it from http://blog.blackpepper.co.uk/black-pepper-blog/Using-Amazon-EC2-EBS-S3-for-automated-backups.html ) but I cleaned it up a bit... a lot. And I've added micro-instance support as of Sep 10 2010.

http://www.thesatya.com/code/ec2-backup.bash-dist

Update: Here's a script that'll snapshot a given volume, keeping N snapshots, deleting older ones. http://www.thesatya.com/code/ec2-snapshot.bash-dist

Last updated: Sep 11 2010 00:04

Tag: sysadmin

Jul 08 2010 19:56 Moonbase Alpha

Moonbase Alpha released for free on Steam this week. I tried it.

Over a gig for a relatively simple game? Sigh.

Two to five gigs of hard drive space? What?

4 gigs RAM? *What*? (okay, so maybe it said 2 gigs. Still: *what*?)

And then I ran it.

Slow. Sloooow. Laggy. Too laggy to play. Sorry, NASA, you lose the game development badge.

I mean it even lags on the *MENU* screen. It's always a bad sign when the menu screen lags.

I mean, good god, I'm on low-end hardware that was new in late 2009. This game is supposed to be from 2005. And it *lags*? Even Battlefield 2 is playable on this hardware.

This is about moon-walking and fixing-things with wrenches and robots. Shouldn't lag. The graphics aren't even that special; they look worse than BF2. So why does it lag? Must be something wrong in the code somewhere.

What a waste. Looked like it could have been fun.

Tag: game

Jul 02 2010 07:27 Youtube on Roku

Assuming you have a local web server.

Step 1. Get Roksbox

Step 2. Go to Youtube, login, create a playlist (as many as you want).

Step 3. Get the alphanumeric ID of the playlist.

Step 4. Go to http://www.thesatya.com/cgi-bin/rry/get_playlists.pl and plugin the ID.

Step 5. Add the resulting URL to the roksbox videoqueue.xml file. (See roksbox docs for info.)

Step 6. Add whatever you want to the playlist.

Step 7. Enjoy!

From that link, you can also get the code.

Tag: entertainment

Jun 11 2010 23:16 One thing TV gets wrong about me

In response to a post on Boing Boing by Craig Engler, general manager and senior vice president of Syfy digital:

I don't care about any of your 7 things. I rarely watch live TV. I prefer to get the DVDs and Netflix, because I can then watch on my own time, seek when I need to, and not see things I don't want to (like advertisements). I don't much care about the one-year delay between airing of a show and DVD release.

Another thing that live TV does: inconsistent show times. I can't be guaranteed to always have Foo on X channel at Y time every Monday. And even if it is, it's probably a re-run. And even if it's not, there's all the other reasons mentioned previously (seeking, pausing).

Now I agree, this is just one man's opinion and makes no difference to big TV's business model (which it can stuff up it's business end). But it's my blog and I'll say what I want to say.

Tag: rant

Jun 08 2010 21:30 Unseen Academicals

Unseen Academicals is apparently Terry Pratchett's latest work. I must have set my expectations too high. It was luke-warm. Perhaps not as bad as FaustEric. It just seemed like he had crammed every character in there, stopping just short of including the witches. It read like a fanfic. A good fanfic, but still. And people seemed just slightly out of character. Vetinari talked too much. The Arch-chancellor wasn't out of it (didn't appear to be out of it, I should say, he's never actually out of it) as much as usual. Ponder was assertive. Rincewind didn't run away. Mister Vimes was *nice*. Okay, I'm nit-picking, but the bit about Vetinari certainly grated. I suppose he's getting old, maybe?

All the minor characters, one-offs, mentioning the bank and post office, all felt like name-dropping.

They never explained how the opening scene tied in with everything.

What's with the cover? Is that a basketball? I don't see any pentagons. And they're *handling the ball*. I know that Ankh-Morpork street football is closer to rugby but that looks like a post-Vetinari football they're trying to catch. But it isn't a (soccer) football! Rugby meets soccer, maybe?

I did like the confusion caused by the offsides rule, and the other little touches. The underlying fabric of a Discworld novel is there, and it kept me up till late at night, but it lacked a certain je ne sais quoi. Just slightly off-balance.

Tag: book

May 09 2010 22:19 Faucet repair and shelving

(This was supposed to be posted in February.)

No longer does my son have to deal with a sad stream of lipid water. For less than $4 and 10 minutes labor, I changed the broken aerator on his bathroom sink for a new one. It only took that long because I haven't done this before. We didn't know it was broken, but I eventually got around to looking at it (with a mirror) and noticed the lack of mesh screen.

So I figured it didn't have an aerator, I can go get a new one. I did, and the guy (the people at Lowe's are usually knowledgable and helpful) told me, based on the picture I showed him, that that's probably an old broken one, I may need to remove it first. He also gave me the dual-thread one that I used, and it turned out to be an EXACT match for the one I took out. I tell ya, always take a digital camera along.

The hard parts: matching the aerator, and remembering which way to turn the wrench. Oh yeah, having a pipe wrench made things MUCH easier. (And I'm not one of those people who has to go "left-loosy" either, it's just hard to get right when the thread is UNDER the thing.)

As for the shelving, I have this 5-level shelf unit in the garage. I wanted it attached to the wall so it doesn't tip when the boy climbs or pulls on it (and he will). At first I got a set of pipe-straps (C-clamps?) that didn't fit, and they had too much give anyway, since the "pipe" supports of the shelf weren't flush to the wall. Or so I thought; as it turns out the shelf wasn't close enough to the wall.

Today I talked to the guy in the hardware department and explained exactly what I wanted. He suggested I use these big ol' self-tapping screw anchors and tie it with a chain. I happened to have suitable chain lying around, so I did that and now the shelf unit is anchored firmly to the wall. Doesn't even budge. It's awesome!

Last updated: Jun 08 2010 21:43

Tag: diy

Apr 06 2010 11:23 Netflix, Roku, and subtitles

I just got the Roku, and aside from quick-seek, I miss subtitles[0]. I watch lots of British stuff (Doctor Who), and even some American stuff isn't too clear. Having the volume up loud isn't an option -- all I get is noise, usually.

[0] Or do I mean closed-captions?

I also watch foreign movies. *Those* have Engish subtitles/translations. So why can't Netflix do the same for English-language content? I'm not asking for 4 or more streams per title (none, English, French, Spanish -- these are the big 3 languages on DVDs), but two.

I miss quick-seeking because when I miss what someone said, with subtitles I can read the subtitle but without, I have to seek backward ("rewind", for those of us who grew up on tape). And then I have to wait several seconds for the device to download what it JUST showed me a few seconds ago. Both silverlight and the Roku need a better buffer.

Netflix, any help?

Tag: netflix

Feb 22 2010 20:16 Rails and Oracle

Getting Rails to work with Oracle is straight-forward. Get the instant client libraries from Oracle. I got the following, and unzipped them into /opt/oracle/instantclient-VERSION:

instantclient-basic-linux32-10.2.0.3-20061115.zip
instantclient-sdk-linux32-10.2.0.3-20061115.zip
instantclient-sqlplus-linux32-10.2.0.3-20061115.zip

for n in instantclient*.zip; do unzip $n; done

Symlink the directory so that we don't have to refer to it by version number, and then symlink certain files inside it because the libraries are supposed to be generically-named:

ln -s instantclient-VERSION instantclient
cd instantclient
ln -s libclntsh.so.11.1 libclntsh.so
ln -s libocci.so.11.1 libocci.so

In /etc/apache2/envvars add:

export LD_LIBRARY_PATH=/opt/oracle/instantclient:$LD_LIBRARY_PATH

And then install the ruby-oci8 driver, and the activerecord_oracle_adapter:

sudo env LD_LIBRARY_PATH=$LD_LIBRARY_PATH /usr/bin/gem install ruby-oci8 --version "< 2.0.0"
sudo gem install activerecord-oracle-adapter

Here's an example config/database.yml file:

production:
  adapter: oracle
  database: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=foo.example.com)(PORT=1234))(CONNECT_DATA=(SID=databse)))
  username: foo
  password: boo

There, all done. There might be a way to do this using ODBC but I'm just happy this works pain-free (unlike sybase).

Tag: rails

Feb 20 2010 10:45 Sybase and Rails, with ODBC

I've been trying to get Sybase working with Rails, as detailed before in my blog. Here's what eventually worked for me, on Ubuntu 9.10 and Rails 2.3.5, using Phusion Passenger.

Install the rubygems package. Install rails and stuff via gem, and some ruby libraries via apt-get. Note: We apt-get install rubygems, and all the other rails stuff is installed as a gem. Because we wanted latest stuff. *Ruby* libraries are apt-get installed where possible, otherwise via gem. freetds and sybct libraries are compiled on the box. Yuck.

The following gems are installed (I've taken out ones, like calendar_date_select, that are obviously irrelevant for this purpose):

activerecord (2.3.5, 2.3.4, 2.3.3, 2.3.2, 1.15.6)
activerecord-jdbc-adapter (0.9.2, 0.9.1)
activerecord-odbc-adapter (2.0)
activerecord-oracle-adapter (1.0.0.9250)
activerecord-oracle_enhanced-adapter (1.2.3)
activerecord-sybase-adapter (1.0.0.9250)
activeresource (2.3.5, 2.3.4, 2.3.3, 2.3.2)
activesupport (2.3.5, 2.3.4, 2.3.3, 2.3.2, 1.4.4)
dbd-odbc (0.2.5)
dbi (0.4.3)
deprecated (2.0.1)
fastthread (1.0.7)
rack (1.1.0, 1.0.1, 1.0.0)
rails (2.3.5, 2.3.4, 2.3.3, 2.3.2)
rake (0.8.7)
ruby-oci8 (1.0.7)
ruby-odbc (0.9999)
rubygems-update (1.3.5)

I'd gem install rails, dbd-odbc, and rubygems-update. That should pull in most of the others as dependencies. Don't install ruby-odbc and ruby-oci8 right off. For ruby-odbc, see below, and for ruby-oci8, See another article (to be written). The oci8 is for Oracle.

Additional stuff to install (again, only relevant stuff listed):

sudo gem install activerecord-sybase-adapter -s http://gems.rubyonrails.org
sudo gem install activerecord-oracle-adapter -s http://gems.rubyonrails.org

sudo apt-get install libiodbc2 libodbcinstq1c2 odbcinst1debian1 freetds-common freetds-dev tdsodbc unixodbc unixodbc-dev libdbi-ruby

Your /etc/freetds/freetds.conf file (not sure you need this for ODBC):

[A]
        host = somehost1
        port = 4100
        tds version = 5.0
[D]
        host = somehost2
        port = 4100
        tds version = 5.0

Begin activerecord-sybase-adapter instructions. If you want to use ODBC only, skip this section.

At some point, I got sybase-ctlib ruby library (sybct-ruby) from here: http://enjoy1.bb-east.ne.jp/~tetsu/sybct-ruby-0.2.12.tar.gz (sybase-ctlib project page). Also download freetds-stable, ./configure and make, and then edit sybct's extconf.rb file:

sybase = "/usr/local/"
$CFLAGS = "-g -Wall -DFREETDS -I#{sybase}/include"
$LDFLAGS = " -L#{sybase}/lib -L/freetds-0.82/src/tds/.libs" 
$LOCAL_LIBS = "-lct  -lsybdb -ltds -rdynamic -ldl -lnsl -lm"

Note the ldflags line — you have to tell it where libtds is located. You can find freetdsdirectory -name "libtds*" to find the libtds location. Then in the sybase-ctlib directory, run:

ruby extconf.rb
make
sudo cp sybct.rb sybct.so sybsql.rb /usr/local/lib/site_ruby/1.8/i486-linux/

Fix this destination according to your system. The command "make install" tries to put it in the right place, but doesn't copy all three files.

At this point you should be able to use the native sybase adapter in Rails. Your config/database.xml:

my_db:
  adapter: sybase
  host: a
  database: whatever
  username: heh
  password: youwish

End activerecord-sybase-adapter instructions. If you want to use ODBC only, skip the above section.

For the ODBC connection, I stuck this in ~/odbc and ran "odbcinst -i -s -d ~/odbc" (I have tdsodbc and unixodbc, dunno how much of that is required). Actually, I just stuck the following stuff in /etc/odbc.ini:

[d]
Description     = d server, name elided
Driver      = /usr/lib/odbc/libtdsodbc.so
Server=fqdn.example.com
Port=4100
TDS Version      = 5.0
[a]
Description     = a server, name elided
Driver      = /usr/lib/odbc/libtdsodbc.so
Server=fqdn2.example.com
Port=4100
TDS Version      = 5.0

Test with this command: isql -v d user pass where d is the 'd' from the odbc file, and user and pass are the actual ones.

For ODBC with Rails: Per instructions from RubyODBC maintainer (Christian Werner, whom I hereby thank again). First line removes libdbd-odbc-ruby libdbd-odbc-ruby1.8 libodbc-ruby1.8 if they were installed:

sudo apt-get purge libodbc-ruby1.8
sudo gem install ruby-odbc -- --build-flags --disable-dlopen

And that got Sybase over ODBC to work. disable-dlopen is kinda important. Important information that I was looking for but couldn't find: "-- --build-flags" is how you pass stuff to extconf.rb when the gem install command is going to compile the gem. Now you should be able to use ODBC in Rails with this config/database.yml file:

my_db:
  adapter: odbc
  dsn: a
  database: whatever
  username: heh
  password: youwish

Phew!

Update: I don't think you need the sybse-ctlib library, nor the freetds source/compile, if you're only doing the ODBC thing. You can get by with the freetds package installed by apt-get. If you're using the activerecord sybase adapter, that's when you need sybase-ctlib and therefore the freetds source.

Summary:
# freetds and odbc packages (the last two may auto-install as dependencies):
sudo apt-get install freetds-common tdsodbc unixodbc \ odbcinst1debian1 libodbcinstq1c2
# for ruby-odbc to compile correctly:
sudo apt-get purge libodbc-ruby1.8
# to build ruby-odbc:
sudo apt-get install unixodbc-dev
sudo gem install ruby-odbc -- --build-flags --disable-dlopen

Last updated: Mar 23 2010 14:55

Tag: rails

Feb 09 2010 18:49 Inherit the Stars

James P. Hogan's Inherit the Stars is an excellent piece of Science Fiction. It's not long. It's about the investigation of a dead body on the moon. It's the ultimate cold case. The evidence has been cooling for fifty thousand years.

I like the scientific tone of the book. It *could* be true. But I also like the back-drop which predicts, in a story published in 1977, laptops, the Internet, silicon chips, and warp drive.

I've read it three times now, and every time it delights. It's available at the Baen Free library: Inherit the Stars. I also own a paperback copy.

Tag: book review

Jan 23 2010 18:32 Check the breakers

I was working on the nest of wiring behind my desk. I pulled a plug and everything went dark. It was just that room and a few other things like the front hallway. So naturally I checked the breaker. It hadn't tripped. I reset it anyway. No joy.

Deciding it might be a bad breaker, I opened up the panel and tested with a multimeter. I got 30 volts across the switch and 100 volts, I forget which was open and which was closed. Heck, the meter (a decent Fluke, for gosh' sake) was reading some tens of volts with the leads not touching anything.

So I figured, replace the breaker and see what happens, or at least have Lowe's (my new hangout) test it. Too bad I couldn't get the screw to move. So I put the breaker back in and decided to see if anyone on the internet had insight. (Alright, so the wife was telling me to go check the internet.)

Now the room with no power is the study. That means I had no modem nor router. I simply ran an extension cord from another room and plugged in the master surge strip. I have a couple devices hanging off that, and the UPS. The modem hangs off the UPS's surge-only side, and the computers and monitor hang off the un-interruptable side. So I now had enough power for modem and router. If I felt like running two Amperes of current through this extension cord, I could run the computers. Another amp or two and I could have light! I declined.

Getting on the wife's wireless computer, I looked for something like "power loss in one room" and found the first hit. That described a situation exactly like mine, and the first response said to check for a GFCI (Ground Fault Circuit Interruptor) in the downed circuit. This is often an outlet panel with a couple of pushbuttons labelled "Test" and "Reset" (that site didn't say this, I already knew what a GFCI panel looks like).

That's when a light went off in my head. The breaker panel is in the garage, and the garage lights (and the rest of the house) were on. So I didn't even think of the outlets in the garage wall. The front hallway runs next to the garage, and is part of the downed circuit. The garage wall outlets are not on the garage circuit. They're on -- wait for it -- the hallway circuit. And those outlets include a GFCI. So I went and hit the reset button on it. Still no joy, because -- I had left the breaker off after the previous round. I flipped it, and.

Last updated: Feb 08 2010 19:07

Tag: house diy

Comments:
  • Mon Feb 8 13:04:30 2010 Chuck Boyd wrote:
    I too know about hitting the reset button on the little safety device....after my handyman was called and asked to restore power.

    He took pity and did a few other odd jobs while he was there so I didn't feel like a complete idiot as I paid him.