Wednesday, September 3, 2008
Installing Ruby and Rails on Ubuntu
sudo apt-get install ruby ruby1.8-dev irb rubygems build-essential libopenssl-ruby
This will install ruby and ruby gems on your machine. To install rails enter following on shell prompt
sudo gem install rails rake mongrel
this will install rails and mongrel, a rails web server, on your system. If you dont need mongrel you can remove mongrel from the above line.
Mysql + Mysql Administrator + Mysql Query Browser on Ubuntu
To install mysql use apt-get. Issue command "sudo apt-get install mysql-server mysql-client libmysqlclient15-dev". This will install mysql server on your system. You can start the server using "sudo /etc/init.d/mysql start" and similarly stop it using "sudo /etc/init.d/mysql stop".
Note: RedHat users install package mysql-devel instead of libmysqlclient15-dev
To create and manage databases you can use command line utility 'mysqladmin' installed with mysql server. If you dont like command line then u can install MySql Administrator to manage mysql databases using GUI. To install MySql Administrator issue command "sudo apt-get install mysql-admin".
To connect to databases and execute queries you can use command line utitlity 'mysql' or you can install MySql Query Browser using "sudo apt-get install mysql-query-browser".
MySql Administrator and MySql Query Browser can be run from command line using commands 'mysql-admin' and 'mysql-query-browser' respectively or you can access them from Applications->Programming system menu.
Note: To install these apps you may need to enable universe repository for apt-get. To do this edit /etc/apt/sources.list and uncomment all lines of the form
deb http://xxxx.ubuntu.com/ubuntu/ hardy universe. To uncomment remove '#' from start of these lines.
Monday, September 1, 2008
Portable encrypted filesystem using Flash Drive, LInux and Cryptmount
Encrypted file-system can be easily created using cryptmount. On Ubuntu/Debian you can install cryptmount using “sudo apt-get install cryptmount”.
In this example I will demonstrate how to create an encrypted file-system on a flash drive and then use it on another machine. You will need root privileges on machines where you want to create or access this file-system. First we need to create the file system on the flash drive. To do this create an entry in the /etc/cryptmount/cmtab like this
cryptusb { dev=/media/flash/cryptusb.fs dir=/home/adnan/cryptusb fstype=ext3 fsoptions=defaults cipher=aes keyfile=/media/flash/cryptusb.key keyformat=builtin } Now create the file(specified in dev field) which will contain this encrypted file system and the mount point.
$ dd if=/dev/zero of=/media/flash/cryptusb.fs bs=1M count=32
32+0 records in
32+0 records out
33554432 bytes (34 MB) copied, 0.673204 s, 49.8 MB/s
$ mkdir /home/adnan/cryptusb
Next generate the encryption key. You will need to specify key size in bytes
$ cryptmount --generate-key 32 cryptusb
generating random key; please be patient…enter new password for target "manual":confirm password: Now issue following commands to prepare and format the file-system:
$ cryptmount --prepare cryptusb
enter password for target "cryptusb": $ mkfs.ext3 /dev/mapper/cryptusb
$ cryptmount --release cryptusb
The file-system is now ready and can be mounted using command “cryptmount cryptusb”. To unmount use “cryptmount –u cryptusb”. To use this file-system on another machine just copy
cryptusb { dev=/media/flash/cryptusb.fs dir=/home/adnan1/cryptusb fstype=ext3 fsoptions=defaults cipher=aes keyfile=/media/flash/cryptusb.key keyformat=builtin } to /etc/cryptmount/cmtab on other machine. Change path in dev and keyfile fields to path to cryptusb.fs and cryptusb.key if flash drive on this machine is not mounted as /media/flash. You can also change dir field if you want the file system to be mounted some where else. After adding this to /etc/cryptmount/cmtab save the file and issue follwing commands
$ cryptmount --prepare cryptusb
$ cryptmount --release cryptusb
and you are done. you can now mount and unmount the file system using cryptmount. You may face some problem accessing files and directories because of file permissions. You can always change file and directory permissions using “chmod” and “chown” commands. A simple workaround is to make root to be the owner of this filesystem. To do this mount this file system using “cryptmount cryptusb” then issuing command “chown root:root /home/adnan1/cryptusb”. Then you can access this file system as root on both machines. This way you wont have to change permissions whenever you take this filesystem from one machine to other.
Wednesday, August 20, 2008
Installing cryptmount on Redhat Linux Enterprise 4
Download Cryptmount, glibc, glibc-headers, glibc-devel and glibc-common and put them in the same directory. Now change ur working directory to that directory and issue command "rpm -Uvh glibc-2.8.90-11.i386.rpm glibc-common-2.8.90-11.i386.rpm glibc-devel-2.8.90-11.i386.rpm glibc-headers-2.8.90-11.i386.rpm"
This will install or update GNU C library on ur system. Now issue command "rpm -Uvh cryptmount-3.0-1.i586.rpm" and this will install cryptmount on ur system.
Sunday, June 15, 2008
Sqlite3 with Rails
Using Sqlite3 with rails is real easy. Grab the binaries from Sqlite3 download page. for windows you will require sqlite-3_5_9.zip and sqlitedll-3_5_9.zip. Unzip these files and add them to your PATH environment variable ( or u can simply put the unzipped files to your ruby/bin directory) and you are ready. All Sqlite3 functionality is accessible via sqlite3.exe which you just unzipped and added to path.
To use sqlite3 with rails install sqlite3-ruby gem using gem command. Finally you will need to specify sqlite3 as the connection in the database.yml file of your rails application. Given below is development section of a sample database.yml
development:
adapter: sqlite3
database: db/development.sqlite3
timeout: 5000
Notice that there is no username or password fields as they are not required.
When you do rake db:migrate database file will be created if not already exists.
Note: as of rails 2.0 sqlite3 is the default database and you will need to -d command line option when creating a rails application using to change it or you will need to change database.yml manually.
Thursday, June 12, 2008
REST in peace
Here you can find a simple tutorial about REST or you can follow this link to see how to build RESTful applications in Rails
Sheritech - What went wrong
But this post is about "what went wrong" so I will try to stick to the topic :)
Generally people working in startups have stakes in them. This is what compensates for things like overtime and late or small salaries, and makes people, who are part of that startup, feel like they are doing it for nobody but themselves. And this was my and others (you know who) expectation from Sheritech but when things got documented we came to know that this was not the case. So obviously I started to look at things differently and i believe same is true for other people working there.
Startups require lot of hard work and little SLEEP. It is not possible for a startup to be successful when its CEO is almost never available (I believe you know the reasons for his unavailability :D). This thing wasted the best resource that we had and destroyed the office environment.
Startups require focus and determination. It is important to have a game plan before starting a new company. If one partner is thinking one thing and other is thinking another, it is never going to succeed.
Lastly and most importantly in any business owners/partners should be fair with each other and employees. You cant deceive people for long and it always ends badly when you try to.
The most important thing that I learnt from Sheritech and which I want to share is "Never ever work for your friend" because if you do you lose both.