Rails 3 on debian with Sqlite 3

October 13, 2010

Decided to move to Rails 3 recently and get up to speed on the new framework version.

I list here the process I followed to install it on Debian (Lenny).

*Note, some of these commands need root / administrator privileges. Notably the apt and install commands. Use sudo, su or a root shell.

Install dependancies

# optional VCS, we use Mercurial Locally and Git for deployments to Heroku (hosting)

apt-get install git-core mercurial

# libmysqlclient15off libreadline5-dev
apt-get install build-essential libreadline5-dev libssl-dev zlib1g zlib1g-dev

#optional Database, I have detail for getting Sqlite3 later
#apt-get install mysql-common mysql-server

Install Ruby

wget ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.2-p0.tar.gz
tar xzf ruby-1.9.2-p0.tar.gz
cd ruby-1.9.2-p0
./configure
make
make install

Install sqlite 3

wget http://www.sqlite.org/sqlite-amalgamation-3.7.2.tar.gz
tar xzf sqlite-amalgamation-3.7.2.tar.gz
cd sqlite-3.7.2/

./configure
make
make install

gem install rails sqlite3-ruby

Create your rails app

rails new Items
rails g scaffold Item name:string detail:text
rake db:migrate
rm public/index.html
vim config/routes.rb

add this line:

root :to => "items#index"

then start the server:

rails s

Open your browser and go to http://localhost:3000/

And that’s it!


Deploying your Rails 3 app to Heroku from Debian GNU/Linux

October 11, 2010

Deploying apps to Heroku is as simple as

git push heroku master

But you need a little bit of setup first.

If you haven’t got git, install it with

apt-get install git-core

You will also need the Heroku gem

gem install heroku

Then set up your app, adding the files to the git repository

cd myapp
git init
git add *
git commit -m 'first commit, using git for pushes to heroku which hosts rails apps free and uses git'

Create a key for secure authentication to Heroku

ssh-keygen -t rsa -C "me@mycompany.com"
heroku keys:add

Create your heroku app

heroku create

And push your new rails app to it

git push heroku master

Now browse to the url you were given in previous steps as feedback from heroku, and you should see your app, now live !


root user password recovery / resetting on Debian/GNU based linux systems

August 5, 2010

I have had need for this more often than I would like of late, it is a nice and quick way to reset the root password if you can’t remember, or the person who had it isn’t around any more. You need access to the actual console of course, physical access or a remote KVM. I’ve used this on both Debian boxes and Ubuntu boxes recently.

  1. rebooot the machine
  2. interrupt the boot sequence at the GRUB bootloader / LILO screen (I haven’t seen LILO on Deban / Ubuntu in quite a while)
  3. edit the boot line with “kernel” information (select and press e to edit)
  4. add init=/bin/bash to the end of the line
  5. hit enter and then press ‘b’ to boot
  6. when the boot sequence has finished, type the following:

mount -o remount,rw /
passwd root
(enter the new password for the ‘root’ user)
shutdown -r now (to reboot and login as root with the new password)


Debian : Apache : PHP : Database Error: Unable to connect to the database:The MySQL adapter “mysql” is not available.

May 28, 2010

Got this today when I browsed to my Joomla site, which I had just imported from elsewhere.

Database Error: Unable to connect to the database:The MySQL adapter "mysql" is not available.

Setting the correct database password in the joomla configuration file fixed the issue.


Sed and Print in Perl

February 15, 2010

I recently needed a sed-like script for a web based perl app doing to internally convert request ports and came across some interesting print code in the process of testing it

#!/usr/bin/perl

sub println
{
$\ = "\n";
@_ = ($_) unless @_;
print @_;
}

 

my $sec = "https://dmom.domain.com:633/confirm/me/";
$sec =~ s/:633/:81/;
println $sec;


Palm Pilot: Backing stuff up over USB on Ubuntu Debian GNU/Linux

October 1, 2008

Quite easy really. Once you have the usb connection validated (see earlier post), backing up is simply a matter of :

pilot-xfer -p usb: -b ~/my-new-palm-backup-dir

You can also do a local update (-u palm-backup-dir) or a sync (-s palm-backup-dir).

Further options are available with pilot-xfer --help

Now to have a look at J-Pilot, a GUI. (no, it’s not written in Java)


Palm Tungsten T, USB, Pilot-Link, Ubuntu Debian GNU/Linux

September 30, 2008

Couldn’t get my old Palm Tungsten T to work with pilot link. After reading around and trying various things with dev files, I eventually found this post about a bug in pilot link.

Sure enough, removing the visor module with

sudo modprobe -r visor

meant the Palm now responded to

pilot-xfer -p usb: -l

and I got a lot of output about files on the Palm when I hit the sync button on the USB cradle.

So, I have added

blacklist visor

to

/etc/modprobe.d/blacklist

so that module won’t be loaded in the future.

Hopefully this bodes well for my attempts at seamless synchronisation of my Palm Tungsten|T on Ubuntu


Want to see the date and time in the Mutt mail client when reading e-mail ?

April 17, 2008

Then add the following to your ~/.muttrc


ignore *
unignore from date subject to cc
unignore organization organisation x-mailer: x-newsreader: x-mailing-list:
unignore posted-to:

Really, you just need to add unignore date. This snippet above firstly turns everything off, then selectively decides to show the headers as listed with unignore.

I have been slightly annoyed for a while now that my Mutt configuration wasn’t displaying the send-time when i was reading emails. I had the date in the e-mail list, but nothing in the actual email.

Finally I got to look it up :D


Linux on USB disks : Damn Small Linux

April 5, 2008

Today I tried out installing two separate, cut-down, versions of Linux onto a USB drive.

This post details my experience with damn small linux.

Damn Small Linux

I tried getting various files, including the embedded zip file, but failed to install to
a USB disk. The idea seemed pretty simple, unzip the files onto the USB
disk, run sys linux. Go. But it just wouldn’t work. Kept reporting
missing files early in boot.

The alternative, boot into the system form the iso and install from there, also failed.

Note, in both cases I am booting into a virtual machine, not natively.

http://ftp.heanet.ie/mirrors/damnsmalllinux.org/current/dsl-4.2.5.iso

Instead of burning a CDR I booted the cd image with Qemu, a free virtual machine emulator (available in Ubuntu Debian Gnu/Linux)

qemu -k en-gb -m 512 -localtime -boot d -cdrom dsl-4.2.5.iso /dev/sdb1

I provided the USB drive as the hard-drive to the virtual machine
(/dev/sdb1) and instructed the boot drive to be the cd (‘-cdrom
cd-image.iso’) with the option ‘-boot d’.

DSL booted up into the GUI without issue.

Then
I selected the install option “USB-HDD Pendrive Install.” from the DSL Menu -> Apps -> Tools

I also tried HDD install.

Neither work. The filesystem has errors on creation. Might try again when booted native from the CD, instead of through the virtual macine.


Linux on USB disks : Puppy Linux

April 4, 2008

Today I tried out installing two separate, cut-down, versions of Linux onto a USB drive.

This post details my experience with puppy linux.

Puppy linux

I tried getting various files but ended up using the iso download file.

ftp://ibiblio.org/pub/linux/distributions/puppylinux/puppy-3.01-seamonkey.iso

Instead of burning a CDR I booted the cd image with Qemu, a free virtual machine emulator (available in Ubuntu Debian Gnu/Linux)

qemu -k en-gb -m 512 -localtime -boot d -cdrom puppy-3.01-seamonkey.iso /dev/sdb1

I provided the USB drive as the hard-drive to the virtual machine (/dev/sdb1) and instructed the boot drive to be the cd (‘-cdrom cd-image.iso) with the option ‘-boot d’.

I booted into XVESA, XORG didn’t work.
Then I selected the install option “Install to IDE flash drive.” from the puppy installer at Menu -> Setup -> Puppy Universal Installer

I shut down the virtual machine, and rebooted, this time from the newly set-up USB disk, with:

qemu -k en-gb -m 512 -localtime /dev/sdb1

Worked fine, no issues !

Previously I had tried downloading other puppy linux files from the download server, but failed to install to a USB disk (without too much trying I must admit though in fairness)


Follow

Get every new post delivered to your Inbox.