Wow. I just watched Dave Thomas’ talk Ruby Metaprogramming: Extending Ruby for Fun and Profit and it explained so many things.

It’s quite worth watching if you like Ruby and don’t know about metaprogramming and Ruby hooks and what ‘self’ means, fully.

 

Someday I’ll come out with a proper revision numbering scheme for it.
I’ve implemented some Cucumber testing, the code now actually parses SGF files properly, including the KGS ones, it’ll work on Ruby 1.8.6, 1.8.7, 1.9.1, so .. It’s all good on that front.

The code’s not as clean as I’d like it to be, and probably not as commented, either.

http://github.com/Trevoke/SGFParser

I am not -saving- SGF files with it yet, but heck if I’m not parsing them. And now YOU can, too !

 

If you get this error : Mysql::Error: query: not connected: or one just like it, it’s because you need an older DLL.. Which I just happen to have found, because I needed to fix this problem too!
libmySQL.dll

Enjoy.

 

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! :)

 

Just a link:

http://www.databaseapplications.com.au/authentication.jsp

Something for me to read and digest later when I have time.

 

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
 

My answer : get Python! Someone wrote a handy program in Python that helps you out:

http://ntlmaps.sourceforge.net/

1) Download
2) change the configuration file (most likely just enter your username and password)
3) double-click on runserver.bat
4) make sure one of your environmental variables is http_proxy = http://localhost:5865 and the other one ftp_proxy = ftp://localhost:5865
5) use rubygems

Of course, if someone were to rewrite it in Ruby.. ;-)

 

Short post to give a link to the HAML plugin for Netbeans:

http://mediacast.sun.com/details.jsp?id=3759

http://mediacast.sun.com/users/~tor/media/org-netbeans-modules-haml.nbm/details

Download and install

http://wiki.netbeans.org/FaqPluginInstall

And I get to test my wordpress-livejournal-twitter-facebook crossposting mania!

 

If you’ve done any kind of table display in Rails, you’ve probably discovered the useful ‘cycle’ method:

“>

This works after you’ve set two CSS classes between which you want to alternate – in my example, even and odd, because I have such amazing imagination. Come to think of it, to make my code more readable, it should be ‘lightbg’ and ‘darkbg’, or something similar. I’ll fix that.

But yeah – how do you do that in HAML?
Piece of CAKE (in this case, it is not a lie).

%tr{:class => cycle(‘even’, ‘odd’) }

 

You’ll notice, if you follow those screencasts (around now, anyway, as the plugin’s code is likely to change, or maybe the screencasts themselves) that when you add in_place_editing, you suddenly get broken HTML..

The fix is thankfully easy!

vendors > plugins > in_place_editing > lib > in_place_macros_helper.rb
Line 79:
tag = content_tag(tag_options.delete(:tag), h(instance_tag.value(instance_tag.object)), tag_options)

Change to :
tag = content_tag(tag_options.delete(:tag), instance_tag.value(instance_tag.object), tag_options)

And you’re set!

© 2011 Seven steps Suffusion theme by Sayontan Sinha