Archive for the ‘programming’ Category

New position at Cyrus

Thursday, April 22nd, 2010

On Monday, April 26th, I am starting a new job at Cyrus Innovation. It may well be fair that I am starting a new career – it’s a hop, skip and jump for me. I’m switching from Systems Administration / Tech Support / Hell desk (not a typo, sadly) to Development / Programming.

I am very much looking forward to it. It means a hobby/job switch: I will now do sysadmin stuff as a hobby, and programming as a full-time job. We’ll see how it works out :)

I remember looking up to the early programmers in awe – they were wizards, and their skill probably couldn’t be equaled, reached, or even, likely, attempted. Then came Ruby. There will always be master hackers – but with Ruby, and its community, it seems that everything is easily at hand. People care about making code elegant and accessible. Things which would take lines and lines of codes in other languages are usually between one and four lines. It’s powerful. And it’s not difficult. The most arcane and powerful elements of the language are … Accessible. The code doesn’t get in the way of the mental gymnastics.

I’m sure I’ll be using other languages – it’s a good way to grow, after all – and I look forward to it. Finally: a place where I can, and will, always be learning.

Git : moving a remote branch

Tuesday, December 29th, 2009

One can’t actually move a remote branch, but you can copy a branch and delete a branch, so…

Copy oldbranch in repo to newbranch.

git push {repo} {oldbranch}:heads/{newbranch}

Ex: git push origin foobranch:barbranch
renames foobranch to barbranch

Remove a remote branch: it’s all about the colon:

git push <remote_repo> :heads/<branch>

Example: git push origin :heads/some-branch removes some-branch from the remote repo (apparently git push origin :some-branch works as well).

This works for removing a tag as well: git push origin :sometag

Ruby SGF Parser

Tuesday, September 15th, 2009

So, I play weiqi (known as the game of go, but I prefer using the chinese name).
There are some SGF parsers out there for Ruby, but I wanted to write my own – the other ones didn’t seem comprehensive enough, didn’t seem Ruby-like enough in their objectifiying the women data.
My original goal was twofold: write a script to rename all the SGF files in my collection so they can be easily parsed later, and … Learn more Ruby!
Here is the github link: http://github.com/Trevoke/SGFParser
It’s a work in progress. Right now it parses the SGF file properly, but the user has a fair amount of work to do to use the data.. Which, maybe, is the way it needs to be. But I’m gonna try to follow the principle of least surprise to the bitter end! :)

Connecting to Sybase with Rails on Windows XP

Friday, September 11th, 2009

This is known to work on ASE 12.5.1 – you’re welcome to let me know what else worked, I am particularly curious about later versions of Sybase ASE, such as 15.

Prerequisites:

  1. Sybase PC Client 12.52
  2. The Ruby Sybase  files
  3. gem install activerecord-sybase-adapter -s http://gems.rubyonrails.org

Put the Sybase files in C:\ruby\lib\ruby\site_ruby\1.8\i386-msvcrt .

Copy all the DLLs in %SYBASE%\OCS-12_5\dll and put them in %RUBY%\bin (if you are not familiar with Windows notation, this simply means to go where you installed each of Sybase and Ruby and then go to the proper subdirectory). Why all of them? Well, because I’m too lazy to know which ones we -do- need.

Set some environment variables, just to make sure Sybase works fine:

Right-click on My Computer, Properties > Advanced > Environment Variables
If you have full permissions, go ahead and add those as SYSTEM VARIABLES.. Otherwise, well, only for your user (but aren’t you doing this on a server?).

SYBASE=c:\sybase    (where you installed Sybase).

JDBC_HOME=c:\sybase\jConnect-6_0   (again, where you installed Sybase, then the subdirectory).

CLASSPATH=%JDBC_HOME%\classes\jconn3.jar (just make sure that’s the right number).

If you’re going to create a user on your Sybase server for specific Rails usage, it needs to have SELECT permissions on the following : sysobjects, syscolumns, systypes, syscomments.

Edit your %SYBASE%\ini\sql.ini and add the information for your server in there.

Next.. In Rails, the magic will look like this in database.yml :

production:
adapter: sybase
database: <YOUR_DB_HERE>
username: <USERNAME>
password: <PASSWORD>
host: <NAME_GIVEN_IN_SQL_INI_HERE>

And that should be pretty much it!

Don’t forget to edit your model if you’re working with legacy data:

class Patient < ActiveRecord::Base
set_table_name "some_odd_name"
set_primary_key "some_primary_key_column"
end

Javascript help

Thursday, May 7th, 2009

I want to have a variable number of text fields in a form, and sending all of these text fields to one function when it is submitted. My best guess is that they’d have to be passed in as an array, unless there’s a more elegant solution (akin to ARGV in Ruby, or the arguments passed in to a program that starts.. ?).

Does anybody have an idea?