Wednesday, December 18, 2013

International Travel Checklist

I keep creating a check list every time I travel internationally.  So a template is long overdue.

Necessities ordered by priority (somewhat):

  • Passport (including old ones)
  • Visa / Travel Docs
  • Extra Governments IDS
  • Contact numbers and addresses (printed)
  • Cash / Credit Cards
  • Tickets
  • Hotel Reservation / Address abroad
  • Toiletries
  • Mobile Phone
  • Laptop and accessories
  • Camera
  • Clothes
  • Reading materials
  • Pasalubong (Gifts for family and friends)



Thursday, October 25, 2012

Ruby and analysis paralysis

Ruby is a wonderful language.  It also currently has a very vibrant ecosystem producing some amazingly cool things -- Rails, Sinatra, Chef, Homebrew, and EventMachine (my favorite) to name a few.
It also has several implementations -- MRI, YARV, Jruby, Rubinius, Maglev, MacRuby, etc.  But here a problem lies... there are just too many freaking choices.
Compounded with the active waxing and waning of open source ruby libraries ("there's another gem for that") the situation makes me quite unhappy at times.

Enter JRuby...

I first discovered JRuby when I encountered a problem with using MRI along with Powershell.
My first reaction with it was how slow it was to boot up -- this is mostly because of the Java VM.  But it fixed my problem so I was happy with it.
Later I discovered how some of my scripts which employ threading become quite performant because JRuby has real threading -- that put a smile into my face.
The thing that finally sold JRuby to me was when I had to write a Rails app that interacts with Windows SQL Server.  To be able to connect to SQL Server from Linux is quite a pain. You have to fiddle with TDS and UnixODBC.  That took A LOT of time to really get working.  Maybe it is because I am dumb but still...  So aside from the Rails app, I also had to configure ODBC in my Linux box -- that's one more dependency that could go wrong.  Later I discovered there is a library that doesn't need me to setup anything, but it has a regression bug when compiled with a lower version of the FreeTDS library.  The author decided he won't fix it because "we should be on TDS 0.9x anyways".  That is okay except when your distro ships with an older version -- because then depending on your Linux knowledge you could be screwed for a while trying to install a library (and its associated tools) manually instead of fetching from the distro's repo.
Opting to use JRuby instead, I got my Rails app talking to SQL Server in no time -- well there is that Rails boot overhead along with JRuby's.  I can also run the same app in my Windows box or in any other Linux distro without doing any further setup.

So if you are new to Ruby, or is also frustrated with the number of choices, I encourage you to try JRuby out.
To name a few benefits:

  • Consistency in experience
    • I have never had to do anything special moving apps between operating systems
  • 64-bit support 
    • by just installing the 64-bit Java runtime
  • Interoperability with Java
    • I have only tried this out a little but I found it quite cool
    • call Java code
    • make Java code call Ruby code
    • call other code that compile to Java? (Jython, Clojure, Groovy, Scala, etc)
  • Performance
    • if you use (properly) threads in your scripts you will a significant boost from the Java VM's  real threading.
Caveats:
  • It may lag in feature set and bug fixes from the main Ruby implementation
    • I have experienced this.  In my case I found a discrepancy between JRuby and MRI in the IO.popen3 call.  Sucks when I use JRuby as a wrapper for external apps at times.
  • Java VM overhead
    • boot/loading time
    • memory requirements
I hope more people use JRuby.  That way when they write those cool libraries they have been thinking I am assured I can try them out :)


Thursday, July 28, 2011

Trouble with Ruby calling Powershell

Today I ran into a problem where a Powershell script fails when called inside a Ruby script -- if you are asking why, it's because I have to.
Anyways, the relevant data specs are:
Dell T5500 Dual Quad Xeon
Windows 7 x64 Ultimate
Ruby 1.9.2-p180
Postgresql x64 driver

When the script is ran by itself it works just fine. But inside a very simple Ruby call:

#!/usr/bin/env ruby

#...

if system("powershell -File #{powershell_script}")
  #...
end


My powershell script started failing. After some debugging I found that the reason for the failure was the ODBC connection call inside the PS was failing. But why?
The clue in this problem was the x64 driver used for connecting to Postgresql. Since Ruby 1.9.2-p180 is a 32-bit application it calls the 32-bit version of Powershell which craps out when made to use the 64-bit driver.

So what was the solution? I installed the x64 version of Jruby for Windows (along with the x64 version of the JRE). And now my call to powershell works! Except it somehow hangs...

Replacing system() with IO.popen() solved the problem.

#!/usr/bin/env ruby

#...

out = IO.popen("powershell -File #{powershell_script}")
out.readlines # wait for the program to finish
  #...
end


My main Ruby interpreter is MRI/YARV. But with this recent issue, along with several good feedback I've read on JRuby (such as real threads) maybe I'll use it as the default interpreter.

From what I understand you can call the standard Java libraries inside JRuby, which might be very useful in some use cases.

There are a lot of other languages targeting the Java VM such as Clojure, Scala, Groovy, etc...maybe there's something I'm missing...or it could really be true that the Java VM is one of the best VMs out there.

Saturday, January 22, 2011

Bash them files

I had to regularly clean up a folder of old files in one of the mounts on a Linux box. Being a Python programmer mostly doing his development in Windows, the quickest solution I could think of was writing a Python script using
shutil.rmtree
.

The pseudo-code is like this:
import os
import shutil

from datetime import datetime

# save time now
# list all folders in mount
# for each folder 4 hours older than the saved time, call shutil.rmtree

Without posting all of the code you can see that I also had to handle any exception. The whole script was about 20 lines -- which I was pretty proud of...until I discovered I can do the same thing using:

find /mnt/Archive -mindepth 1 -depth -mmin +240 -delete

:/...I should have remembered the rule I was following years ago which made me somewhat master DOS batch programming.

Use the right tool for the job...and shell commands (and shell scripts) more often than not perform a stellar job at system maintenance.

*sigh* I've been trying to put off having to learn
awk, sed, xargs, etc
which are often used in conjuction with other commands in shell scripting. It has finally caught up with me.

Wednesday, January 12, 2011

Linux Mint on a Roll

Recent check at http://distrowatch.com/ showed that Linux Mint is now the #2 most popular Linux distribution.  A little old news I know, but I just would like to congratulate the Mint team for doing such a good job.

The latest Linux Mint distribution (codename "Julia") is so beautiful I often end up just staring at my screen, in awe of the great work that was done.

I first discovered Mint a little over a year ago when after a long hiatus, I've decided to dabble on Linux again.  Linux Mint 8 "Helena" was the one available then and it was beautiful.  But it does not compare to "Julia" at all.  Linux Mint is no longer just the Linux desktop for me...it is the desktop.

I will look for ways to contribute to the project -- personal agenda is to name a release.  Version 12 has to start with a "K" -- it has to be Kara.  In honor of my all time crush, Miss Kara David.

Saturday, December 18, 2010

Rails 3 tutorial frustration

So I decided to try learning Rails after I've finally understood what Ruby is all about -- which was AMAZING!

It's nice that there's an online version for the book:
http://railstutorial.org/ruby-on-rails-tutorial-book

As I was reading through the pages and following the examples, frustration started settling it.

You see the book assumes you have ALL of the necessary packages needed when following the install guide.

I don't want to give the complete step-by-step, but basically to play with Rails 3 you need to:

1. Install rvm (http://rvm.beginrescueend.com/)
2. Using rvm install some ruby (which downloads ruby source and compiles it)
-- here's where the problem starts
-- ruby compiles successfully but depending on your installed dev files, it may lack features that you will need when following the examples in the book.

I inadvertently mastered thru repetition the installation of a rails environment for my linux boxes (Isadora, Julia, Lucid).

To save others from frustration here's the list of packages that you need to install BEFORE installing some ruby into your rvm:

build-essential bison openssl libreadline5 libreadline-dev curl git-core zlib1g zlib1g-dev libssl-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev

Hope this saves others time that I didn't wanted to have spend. I was not able to watch Glee that day! :/

Wednesday, August 09, 2006

Reg hack for re imaging on domain based systems

Para pwedeng i-ghost or vmWare snapshot..:D


[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters]
"DisablePasswordChange"=dword:00000001