Archive | September, 2007

Useful Rails commands

22 Sep

Similar to print_r in PHP is the YAML::Debug(object)

e.g. if you have an object @foo

print YAML::dump(@foo)

remove an element from a hash:

hashname.delete("keyname")

Using FTPS in Websphere Integration Developer FTP Adapter

7 Sep

You’ll need an FTPS server to test this (note: NOT a SFTP server).

(WID uses FTP over SSL/TLS with implicit encryption – you can test this by watching the commands it sends to a server – the first thing it sends is encrypted. Try FileZilla as a good client)

I used freeFtpd which seems to do it well.

1. Set up freeFTPd server selecting the “Use FTP+SSL” and “Use FTPSimplicit” options
2. Save the “Certificate” used in freeFTPd onto the client running WID.
3. On the WID client, import the certificate into a keystore:

keytool -import -file c:\freeftpd.cer -keystore c:\mykeystore

Note that it is important to make sure the keytool you are using is the same as the one running WID.
4. In WID add the property to pick up the keystore. This is found in the Administrative Console of the server in: Application Servers->server1->Server Infrastructure->Process Definition->Java Virtual Machine->Custom Properties. Add the variable named “javax.net.ssl.trustStore” and set it to “c:\mykeystore” (or wherever you created it).
5. In WID in the properties of the FTP interface (from the Assembly Diagram) you need to set the url to ftps:// (rather than ftp://)

VSFTPD over SSL

6 Sep

Need to add the following to bottom of /etc/vsftpd/vsftpd.conf:

ssl_enable=YES
ssl_tlsv1=YES
ssl_sslv2=YES
ssl_sslv3=YES
rsa_cert_file=/etc/vsftpd/vsftpd.pem
force_local_data_ssl=YES

Then you have to create the /etc/vsftpd/vsftpd.pem file:

openssl req -x509 -nodes -days 7300 -newkey rsa:2048 -keyout vsftpd.pem -out vsftpd.pem

To export this .pem file so that a client can import it, use:

openssl x509 -outform DER -in vsftpd.pem -out cacert.cert

Then a java client can import the certificate doing:

keytool -import -trustcacerts -alias mycert -file cacert.cert -keystore mykeystore

Rails – Getting Started

5 Sep

Useful rails commands.

To get a basic rails page going:
1. Get rails up to date
$> gem update -y –include-dependencies

2. Get the generic rails stuff into this directory
$> rails stock

3. Create the model (i.e. the database)

a. Create the schema for a table called ‘Stock’ with the ‘name’, ‘code’, ‘price’ and ‘sector’ columns
$> ruby script/generate scaffold_resource Stock name:string code:string price:integer sector:string

b. edit config/database.yml to define your development db (you might wanna use sqlite), e.g.

 development:
  adapter: sqlite
  database: db/stock_development
  username: root
  password:

(Note i had to install sqlite and libsqlite-dev as well as do a ‘gem install sqlite’ to get this to work)

c. Execute the sql
$> rake db:migrate

4. Create routing
Edit config/routes.rb to map the table name and add the controller name.
(Note the controller name is the same as the name in app/controllers/stocks_controller.rb)
Add

map.resources :stocks

Add

map.connect '', :controller => "stocks",:action=>"index"

5. Start the server with WebRick the dev webserver
$> ruby script/server webrick

6. Go to the page with a webserver
http://:3000

Powered by ScribeFire.