Comments

I just moved this blog from Posterous to vps hosted Octopress. I’ll cover just a few Windows tips that could get into way.

You’ll obviously need Ruby. Go to RubyInstaller to get excellent Ruby prepackaged for Windows. I tried with both Ruby2.0 32bit and 64bit. And both work fine.

Check that you are using correct DevKit. eg. 64bit Ruby requires 64bit DevKit. Octopress setup and installation after that should go fine. Just follow instructions. Only one thing to note: you should avoid paths with spaces and accented national characters in path. C:/Users/username/Documents/blog should be just fine, is your user name is without spaces and accented chars.

Import is done by following Jekyll wiki. Check here.

There was an error generating site that read something like incompatible 852 and utf-8. 852 is my OEM (console) code page. You just need to change code page of your console to utf-8. You can do that by simply typing:

C:\chcp 65001

Note that this changes code page in current console session only.

Since Octopress supports rsync out-of-the box, which is not supported on Windows, I chose to capify deployment. This means adding capistrano to gems, and setup simple deploy_via :copy solution.

That’s it. It wasn’t too hard.

Comments

I was told it was never meant to be.
I was told that it will get me a lonesome, laughable spot.

Yet, I took that kid under my repo, showed him a trick
or two, like how to live without a fork. Made him simple,
constant and present.

I had a honor to communicate with Salvatore, Claudio,
and also with other people who contributed code, or
pointed at glitches.

Now the time has come to let the kid move on.

The new home for Redis on Windows is fully open,
developed in open; contributions welcomed. There are
more capable hands on the deck. There is a fork
alternative, perhaps even better than fork itself.
It will be tested more and deployed.

Redis on Windows is now stronger.

So, rethink your project. Get involved. It is here:

https://github.com/MSOpenTech/redis

Thank you.

Comments

New version 2.4.0 from “2.4” branch is ready.

Windows notice:

Background saving operations are supported as foreground
on windows, so it is advised to turn off automatic saving,
and call SAVE and SAVEAOF manualy when needed.

Forked source is at:

  http://github.com/dmajkic/redis

Windows binary files (both 32bit and x64) are hanging at:

  http://github.com/dmajkic/redis/downloads

Direct download link for 2.4.0 binaries:

  https://github.com/downloads/dmajkic/redis/redis-2.4.0-win32-win64.zip

I’ll use Redis 2.4 internaly from now on since it is faster,
takes less memory, and tests take significant less time to execute.

2.2 forked branch should receive an update in a day or two,
to match official 2.2.14 and with backported fixes from 2.4 port.


Thank you for support.

Windows x64 build is ready and passes all tests.

Please note that there are more differences between 64bit Linux and 64 bit Windows, than on 32bit, so this build should be treated as “needs more testing”, beside the fact that all supplied redis tests pass.

Prebuilt binaries for v2.1.7, both 32bit and x64 versions, can be downloaded from here:

https://github.com/dmajkic/redis/downloads

Source code is on GitHub

https://github.com/dmajkic/redis

Regards.

Comments

Since I am officially on vacation and since I won’t travel anywhere, at least I can do is to support projects I like. Redis is first.

I was already exploring redis, learning how it works. While doing so, I came close to full win32 port. Moments ago I polished a few last bits and here it is.

Details:

  • Native MinGW port, no external dependencies
  • Windows 32 (didn’t try to compile on Win64)
  • Everything is ported: server, client, linenoise, fix utils, benchmark.
  • As close to unix version as possible
  • All tests pass
  • All commands work
  • Only caveat is since there is no fork() on windows
    commands using it do work, but they work in foreground.


If you have full msysGit or ruby DevKit you can clone my repository and build it using make from command line. More detail in README and source code comments, and I’ll post more here about porting.

Source code

http://github.com/dmajkic/redis


Prebuild binaries (Win32)

http://github.com/dmajkic/redis/downloads  (looks like GitHub denies access)

http://dl.dropbox.com/u/2931334/redis-2.1.4-win32.zip (alternate location)

More about redis:

http://www.redis.io 

 

Stay tuned. 

Comments

Cucumber: For future reference, and time-saving, here is what we did.

Why wolud anybody use Ruby on Windows? With Microsoft SQL Server?

At the company where I work we decided to generate db integration tests. We need database model rock solid for new release we are planing soon. Our old db test system was based on pure SQL, and was working fine. but model itself got complex and SQL is far from what user wants to do and wants to see. We realized that we need test that is very close to what non-tech user is actually talking about, 

I did a small research and found Cucumber, and after a few tweaks we got excellent results. For future reference, and time-saving, here is what we did.

In Ruby slang we “created rails project connecting activerecord with legacy database on MS SQL Server, using Cucumber for testing”

Let’s go: Download Ruby 1.9.1 and install gems 

You can install from installer, but I’ll start from plain 7zip file: 

http://rubyforge.org/frs/download.php/69039/ruby-1.9.1-p378-i386-mingw32.7z

Unzip it to C:\Ruby191, and make that dir accessible to all users. This is where all ruby files and gems will be located. 

Add C:\Ruby191\bin to your PATH. After that try these two commands: 

ruby –version
gem -v

If you get versions (1.9.x and 1.3.x), you are ready to start with basic gems:

gem install –no-rdoc –no-ri rails 
gem install –no-rdoc –no-ri database_cleaner factory_girl rspec rspec-rails cucumber cucumber-rails

You can now create a rails app, but be patient. We need to set a few more things.

Tricky part 1: Connecting to MS SQL Server from Ruby 1.9.1 

gem install –no-rdoc –no-ri activerecord-sqlserver-adapter

This will do on 1.8.6 and 1.8.7. But it is not enough for 1.9.1

For 1.9.1 to work you need to download this file (thanks to Cosimo Guglielmucci):

http://web.tiscali.it/mamva/ruby19-odbc-mswin32.zip

And unzip it to the C:\Ruby19\lib\ruby\1.9.1\i386-mingw32\ folder.

Now you can create a rails app, and connect it to MS SQL, but we still need to set a few more things.

Tricky part 2: RSpec on Windows and Ruby 1.9.1

RSpec gem relays on test-unit 1.2.3, but it will fail to load it if there is a newer one installed. Solution is simple. First find out which test-unit you have installed: 

gem list test-unit 

if there is no test-unit 1.2.3 or there are more versions installed: 

gem uninstall test-unit 
gem install test-unit -v 1.2.3

Tricky part 3: Cucumber on Windows and Ruby 1.9.1

Cucumber got it’s name as ”all green -> you are done”, and it relays on colored console output. On windows that means that cucumber depends on win32console gem. That gem fails on Ruby 1.9.1. But there is a soulution (thanks to Luis Lavena)

gem install win32console –prerelease

This command will install win32console beta version which works on 1.9.1 

If your console codepage is not 1252, you will have incorect output - eg. incredible ”missing ‘a’ problem”. Solution is to chenge your console code page: 

chcp 1252

Cucumber will also remember where it stopped with testing, but it saves path with backslashes on windows, and that backslash can trigger hard to spot errors (missing files, etc…). If you encounter such error just delete rerun.txt file in root of your project. 

Solution for this is to set enviroment variable: 

SET CUCUMBER_FORWARD_SLASH_PATHS=true 

Since Cucumber need enviroment variables and chcp, the best thing to do is to create batch file in root of your project:

191.bat

SET Path=%PATH%;C:\Ruby19\bin;

SET HOME=%HOMEDRIVE%%HOMEPATH%

SET GEM_BIN=C:\ruby19\bin 

SET CUCUMBER_OUTPUT_ENCODING=cp1252

SET CUCUMBER_FORWARD_SLASH_PATHS=true

chcp 1252

ruby –version

 

This will make Ruby and Cucumber happy. Open console, cd to your project and call 191.bat. In fact, I have 186.bat and 187.bat; each with its own gems. 

Create your rails project 

We are using rails since it ties activerecord, rspec and cucumber very nice. With lots of examples. Please note that we are not making a website. Of course nothing stops you to do exacly that. Here is short command line tutorial: 

rails dbtest
cd dbtest
ruby script/generate cucumber

Database connection is set in config/database.yml It should look like this:

development:
  adapter: sqlserver
  dsn: WingsTest

test: &TEST
  adapter: sqlserver
  dsn: WingsTest

production:
  adapter: sqlserver
  dsn: WingsTest

cucumber:
  <<: *TEST

I created ODBC DSN  (Control Panel->Administrative Tools->ODBC) for my database connection.

Note that I’am using only one db, and you should use three if you are creating a website.

Tricky part 4: Legacy MS SQL Server database on Rails

First thing to notice is that activerecord expects lowercase table and field names. And our db is all uppercase. 

Fastest solution was to patch activerecord-sqlserver-adapter. Only thing changed was to insert LOWER(FIELD_NAME) in a few places where adapter fetches tablenames and field names metadata from SQL Server. The only file changed was:

C:\Ruby19\lib\ruby\gems\1.9.1\gems\activerecord-sqlserver-adapter-2.3.4\lib\active_record\connection_adapters\sqlserver_adapter.rb 

My patch is public. I forked activerecord-sqlserver-adapter on GitHub made change and published back my changes. You can get them from:

http://github.com/dmajkic/2000-2005-adapter

If you have legacy database, that is CaSE INsenSItiVE, you are welcome to use my fork.


Then I generated schema.rb with

rake db:schema:dump

If your connection is ok, you will get schema.rb file with all your tables. After that we added activerecord model or two just to get started with cucumber.

That’s it . 

If you are going to use Ruby for website development, you will need to follow more tutorials and go with installing more gems.

As for us, we now have a Cucumber “stage” set, and we are adding steps and scenarios as needed. 

Comments

27. January is celebrated as Saint Sava day in Serbia, and that is the time when schools and students are tributing his life through art and sport performances.

Valjevo is no difference, and since 1993. City of Valjevo and Athletic Club Metalac organise St. Sava Street Race.  Beside youg categoriies, race also features senior competition and is considered a first winter test. 

Race it self has an interesting history: it was started in hard times, by the people who where first to stand for democracy in Serbia, first race winner was famous serbian athlete Goran Raičević. 

Official site of the Street Race is www.svetosavskatrka.org where you can find more about race history, results, street tracks and so on. Site is in serbian cyrilc, so please use google translate. 

See you on start.