Tuesday, November 23, 2010

Some problem after compiling opendnssec

1. Botan
ldd /usr/local/bin/softhsm
ln -s /usr/local/lib/libbotan-1.8.2.so /usr/lib

dpkg-reconfigure tzdata


softhsm --init-token --slot 0 --label "mydnssec"

Monday, November 22, 2010

FreeBSD 8.1 (OpenDNSSEC 1.2.0rc1)

When configuring OpenDNSSEC in FreeBSD, some errors was found:

Error 1
configure: error: libxml2 required, but not found.

Solution for error 1
cd /usr/ports/textproc/libxml2
make install;make distclean

Error 2
configure: error: Can't find ldns library

Solution for error 2
ftp http://www.nlnetlabs.nl/downloads/ldns/ldns-1.6.7.tar.gzendnssec-1.2.0rc1
tar vxfz ldns-1.6.7.tar.gzendnssec-1.2.0rc1

Error 3
configure: error: OpenSSL >= 1.0.0 is needed for GOST support or rerun with --disable-gost

Solution for error 3
Install latest OpenSSL version 1.0.0 or above.
ftp http://www.openssl.org/source/openssl-1.0.0b.tar.gz

Error4
configure: error: sqlite3 command not found

Solution for error4
Install SQLite3

Err0r 5
configure: error: ruby interpreter was not found, tried "ruby ruby1.8 ruby1.7 ruby1.6"

Solution
RVM ruby version 1.8,7

Error 6
configure: error: Missing dnsruby version 1.51 or greater

Solution
gem install dnsruby







Sunday, November 07, 2010

Phusion_Passenger/3.0.0.pre2 configured -- resuming normal operations [ pid=56614 thr=0x7fff706fcc20 file=ext/apache2/Hooks.cpp:859 time=2010-09-19 22:18:29.96 ]: Unexpected error in mod_passenger: Cannot spawn application '/Users/robertrouse/Sites/myapp': The spawn server has exited unexpectedly.   Backtrace:      in 'virtual Passenger::SessionPtr Passenger::ApplicationPool::Client::get(const Passenger::PoolOptions&)' (Client.h:750)      in 'Passenger::SessionPtr Hooks::getSession(const Passenger::PoolOptions&)' (Hooks.cpp:296)      in 'int Hooks::handleRequest(request_rec*)' (Hooks.cpp:565) 
rvm repair all

Saturday, October 09, 2010

Installing rails mysql..

root:/var/root# gem install mysql
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out


The Solution

root:/Applications/xampp/xamppfiles/bin# gem install mysql -- --with-mysql-config=/Applications/xampp/xamppfiles/bin/mysql_config
Building native extensions. This could take a while...
Successfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1...

Friday, August 20, 2010

Migration from MSSQL to MySQL

1. Fetch table schema from MSSQL

Script


#!/usr/bin/env ruby
require 'rubygems'
require 'dbi'
db = DBI.connect('dbi:ODBC:dbintegration', 'epres_amir', 'epres_amir8899')
select = db.prepare("select * from information_schema.columns where table_name = 'ref_course' order by ordinal_position")
select.execute
while rec = select.fetch do
puts rec.to_s
end
db.disconnect

Output:

["DBIntegration", "dbo", "REF_COURSE", "COURSEID", "1", nil, "No ", "varchar", 15, 15, nil, nil, nil, nil, nil, nil, "iso_1", nil, nil, "SQL_Latin1_General_CP1_CI_AS", nil, nil, nil]
["DBIntegration", "dbo", "REF_COURSE", "COURSE_CODE", "2", nil, "YES", "varchar", 15, 15, nil, nil, nil, nil, nil, nil, "iso_1", nil, nil, "SQL_Latin1_General_CP1_CI_AS", nil, nil, nil]
["DBIntegration", "dbo", "REF_COURSE", "COURSE_DESCBM", "3", nil, "YES", "varchar", 200, 200, nil, nil, nil, nil, nil, nil, "iso_1", nil, nil, "SQL_Latin1_General_CP1_CI_AS", nil, nil, nil]
["DBIntegration", "dbo", "REF_COURSE", "COURSE_DESCBI", "4", nil, "YES", "varchar", 200, 200, nil, nil, nil, nil, nil, nil, "iso_1", nil, nil, "SQL_Latin1_General_CP1_CI_AS", nil, nil, nil]
["DBIntegration", "dbo", "REF_COURSE", "CREDIT_HR", "5", nil, "YES", "numeric", nil, nil, true, "10", 2, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]
["DBIntegration", "dbo", "REF_COURSE", "EXAM_COURSE", "6", nil, "YES", "varchar", 15, 15, nil, nil, nil, nil, nil, nil, "iso_1", nil, nil, "SQL_Latin1_General_CP1_CI_AS", nil, nil, nil]
["DBIntegration", "dbo", "REF_COURSE", "FACULTYID", "7", nil, "YES", "varchar", 15, 15, nil, nil, nil, nil, nil, nil, "iso_1", nil, nil, "SQL_Latin1_General_CP1_CI_AS", nil, nil, nil]
["DBIntegration", "dbo", "REF_COURSE", "ACTIVE", "8", nil, "YES", "varchar", 15, 15, nil, nil, nil, nil, nil, nil, "iso_1", nil, nil, "SQL_Latin1_General_CP1_CI_AS", nil, nil, nil]
["DBIntegration", "dbo", "REF_COURSE", "OWNERID", "9", nil, "YES", "varchar", 15, 15, nil, nil, nil, nil, nil, nil, "iso_1", nil, nil, "SQL_Latin1_General_CP1_CI_AS", nil, nil, nil]
["DBIntegration", "dbo", "REF_COURSE", "PROJECT_COURSE", "10", nil, "YES", "varchar", 15, 15, nil, nil, nil, nil, nil, nil, "iso_1", nil, nil, "SQL_Latin1_General_CP1_CI_AS", nil, nil, nil]
["DBIntegration", "dbo", "REF_COURSE", "FINAL_EXAM", "11", nil, "YES", "varchar", 15, 15, nil, nil, nil, nil, nil, nil, "iso_1", nil, nil, "SQL_Latin1_General_CP1_CI_AS", nil, nil, nil]
["DBIntegration", "dbo", "REF_COURSE", "EXAM_DURATION", "12", nil, "YES", "varchar", 15, 15, nil, nil, nil, nil, nil, nil, "iso_1", nil, nil, "SQL_Latin1_General_CP1_CI_AS", nil, nil, nil]
["DBIntegration", "dbo", "REF_COURSE", "COMMON_COURSE", "13", nil, "YES", "varchar", 15, 15, nil, nil, nil, nil, nil, nil, "iso_1", nil, nil, "SQL_Latin1_General_CP1_CI_AS", nil, nil, nil]
["DBIntegration", "dbo", "REF_COURSE", "COURSETYPE", "14", nil, "YES", "varchar", 15, 15, nil, nil, nil, nil, nil, nil, "iso_1", nil, nil, "SQL_Latin1_General_CP1_CI_AS", nil, nil, nil]
["DBIntegration", "dbo", "REF_COURSE", "COURSE_CATEGORY", "15", nil, "YES", "varchar", 1, 1, nil, nil, nil, nil, nil, nil, "iso_1", nil, nil, "SQL_Latin1_General_CP1_CI_AS", nil, nil, nil]
["DBIntegration", "dbo", "REF_COURSE", "COMMON_FAC", "16", nil, "YES", "varchar", 10, 10, nil, nil, nil, nil, nil, nil, "iso_1", nil, nil, "SQL_Latin1_General_CP1_CI_AS", nil, nil, nil]
["DBIntegration", "dbo", "REF_COURSE", "DATE_RELOAD", "17", nil, "YES", "datetime", nil, nil, true, nil, 3, "3", nil, nil, nil, nil, nil, nil, nil, nil, nil]

2. Create table in MySQL DB base on MSSQL schema

Script

require 'rubygems'
require 'active_record'

ActiveRecord::Base.establish_connection(
:adapter=> "mysql",
:host => "localhost",
:username => "sub_integration",
:password => "sub_integration",
:database=> "skt"
)

ActiveRecord::Schema.define do
create_table :subjects do |table|
table.string :COURSEID
table.string :COURSE_CODE
table.string :COURSE_DESCBM
table.string :COURSE_DESCBI
table.integer:CREDIT_HR
table.string :EXAM_COURSE
table.string :FACULTYID
table.string :ACTIVE
table.string :OWNERID
table.string :PROJECT_COURSE
table.string :FINAL_EXAM
table.string :EXAM_DURATION
table.string :COMMON_COURSE
table.string :COURSETYPE
table.string :COURSE_CATEGORY
table.string :COMMON_FAC
table.string :DATE_RELOAD
table.timestamps
end
end

3. Migration

Script:

#!/usr/bin/env ruby
require 'rubygems'
require 'dbi'
require 'active_record'


ActiveRecord::Base.establish_connection(
:adapter=> "mysql",
:host => "localhost",
:username => "sub_integration",
:password => "sub_integration",
:database=> "skt"
)

class Subject < db =" DBI.connect('dbi:ODBC:dbintegration'," select =" db.prepare('SELECT" rec =" select.fetch" subject =" Subject.new("> rec[0],
"COURSE_CODE" => rec[1],
"COURSE_DESCBM" => rec[2],
"COURSE_DESCBI" => rec[3],
"CREDIT_HR" => rec[4],
"EXAM_COURSE" => rec[5],
"FACULTYID" => rec[6],
"ACTIVE" => rec[7],
"OWNERID" => rec[8],
"PROJECT_COURSE" => rec[10],
"FINAL_EXAM" => rec[11],
"EXAM_DURATION" => rec[12],
"COMMON_COURSE" => rec[13],
"COURSETYPE" => rec[14],
"COURSE_CATEGORY" => rec[15],
"COMMON_FAC" => rec[15],
"DATE_RELOAD" => rec[16]
)
subject.save
end
db.disconnect

Tuesday, July 20, 2010

Accessing MSSQL with Ruby

1. unixODBC
wget http://www.unixodbc.org/unixODBC-2.3.0.tar.gz
tar vxfz unixODBC-2.3.0.tar.gz;cd unixODBC-2.3.0
./configure; make; make install
2. freedts
wget http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz
tar vxfz freetds-stable.tgz; cd freetds-0.82
./configure --with-unixodbc=/usr/local ; make; make install
Database information
Server: 10.0.1.70
Database Type: MSSQL 2000
Database Name: dbintegration
Username: epres_amir
Password: epres_amir8899
Configuration File
1. /usr/local/etc/freetds.conf
[dbintegration]
host = 10.0.10.73
tds version = 7.0
port = 1433
2 /usr/local/etc/odbcinst.ini
[FreeTDS]
Description = FreeTDS unixODBC Driver
Driver = /usr/local/lib/libtdsodbc.so
Setup = /usr/local/lib/libtdsodbc.so
UsageCount = 1
3. /usr/local/etc/odbc.ini
[dbintegration]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
Trace = No
Servername = dbintegration
Database = dbintegration
Testing Connection to DB
isql -v dbintegration epres_amir epre_amir8899
or
TDSVER=7.0 tsql -H 10.0.1.70 -p 1433 -U epres_amir -P epres_amir8899


Getting ruby to work with freeTDS

Install dbi & dbd-odbc/unixODBC
gem install dbi
gem install dbd-odbc
Sample ruby code
#!/usr/bin/env ruby
require 'rubygems'
require 'dbi'
db = DBI.connect('dbi:ODBC:dbintegration', 'epres_amir', 'epres_amir8899')
select = db.prepare('SELECT TOP 100 * FROM ref_course')
#return schema select * from information_schema.columns where table_name = 'ref_course' order by ordinal_position

select.execute
while rec = select.fetch do
puts rec.to_s
end
db.disconnect
Sample output
["OAD011", "OAD011", "MENAIP", "KEYBOARDING", #, "Y", nil, "1", "OM", "N", "Y", "60", "160", "KI", nil, "PEP", #]
["MAT225", "MAT225", "KEJURUTERAAN MATEMATIK III", "ENGINEERING MATHEMATICS III", #, "Y", nil, "1", "EM", "N", "Y", "180", "0", "KI", nil, nil, #]
["HRM551", "HRM551", "PENGURUSAN PERUBAHAN", "MANAGEMENT OF CHANGE", #, "Y", nil, "1", "BM", "N", "Y", "180", "160", "KI", nil, "PEP", #]
["ICM358", "ICM358", "INST FOOD SERVICE MGMT", "INST FOOD SERVICE MGMT", #, nil, nil, "0", "HM", "N", "N", nil, nil, "KI", nil, nil, #]
["IDE256-2", "IDE256", "STUDIO PRESENT .II", "STUDIO PRESENT .II", #, nil, nil, "0", "AD", "N", "N", nil, nil, "KI", nil, nil, #]
["IDE256-3", "IDE256", "STUDIO PRESENT.II", "STUDIO PRESENT.II", #, nil, nil, "0", "AD", "N", "N", nil, nil, "KI", nil, nil, #]
["LAW333", "LAW333", "SUPERVISED RESEARCH", "SUPERVISED RESEARCH", #, nil, nil, "0", "AL", "N", "N", nil, nil, "KI", nil, nil, #]
["LAW354", "LAW354", "CIV PROC DRAFTING II", "CIV PROC DRAFTING II", #, nil, nil, "0", "AL", "N", "N", nil, nil, "KI", nil, nil, #]

Saturday, July 03, 2010

Rails on windows

1. Installing ruby

http://rubyforge.org/frs/download.php/71078/rubyinstaller-1.9.1-p378.exe

2. Installing rails

C:\Users\amir>gem install rails
Successfully installed rake-0.8.7
Successfully installed activesupport-2.3.8
Successfully installed activerecord-2.3.8
Successfully installed rack-1.1.0
Successfully installed actionpack-2.3.8
Successfully installed actionmailer-2.3.8
Successfully installed activeresource-2.3.8
Successfully installed rails-2.3.8
8 gems installed
Installing ri documentation for rake-0.8.7...
Installing ri documentation for activesupport-2.3.8...
Installing ri documentation for activerecord-2.3.8...
Installing ri documentation for rack-1.1.0...
Installing ri documentation for actionpack-2.3.8...
Installing ri documentation for actionmailer-2.3.8...
Installing ri documentation for activeresource-2.3.8...
Installing ri documentation for rails-2.3.8...
Updating class cache with 0 classes...
Installing RDoc documentation for rake-0.8.7...
Installing RDoc documentation for activesupport-2.3.8...
Installing RDoc documentation for activerecord-2.3.8...
Installing RDoc documentation for rack-1.1.0...
Installing RDoc documentation for actionpack-2.3.8...
Installing RDoc documentation for actionmailer-2.3.8...
Installing RDoc documentation for activeresource-2.3.8...
Installing RDoc documentation for rails-2.3.8...

3. Installing SQLite3

First you will need to download two files from the Sqlite web site http://www.sqlite.org/download.html:

- http://www.sqlite.org/sqlite-3_6_23_1.zip
- http://www.sqlite.org/sqlitedll-3_6_23_1.zip

The first file is the Sqlite command line program used for modifing the Sqlite database. You may or may not use this.

The second file is the Windows DLL library file and Ruby uses this when Rails makes Sqlite database calls.

When both these ZIP files have been extracted you should have the following files:

  • sqlite3.exe
  • sqlite3.def
  • sqlite3.dll
Copy these file to the bin directory of your Ruby installation

gem install sqlite3-ruby

4. create a project

rails test
cd test
ruby script/server

Now you test page running on http://127.0.0.1:3000

Yeah