Set up Ubuntu server 7.10 gusty Ruby on Rails and Webmin
Download and install ubuntu 32bit ( trust me ) 7.10 server
Install, when it asks select LAMP installation
Answer questions and install, it takes about 30 minutes
When finished login and run from command line:
Follow these instructions:
Taken from: ssh webmin and ip configuration Configuring Static ip address in Ubuntu server
Ubuntu installer has configured our system to get its network settings via DHCP, Now we will change that to a static IP address for this you need to edit Edit /etc/network/interfaces and enter your ip address details (in this example setup I will use the IP address 172.19.0.10):
sudo vi /etc/network/interfaces
and enter the following save the file and exit
The primary network interface
auto eth0
iface eth0 inet static
address 172.19.0.10
netmask 255.255.255.0
network 172.19.0.0
broadcast 172.19.0.255
gateway 172.19.0.1
Now you need to restart your network services using the following command
sudo /etc/init.d/networking restart
You need to setup manually DNS servers in resolv.conf file when you are not using DHCP.
sudo vi /etc/resolv.conf
You need to add look something like this
search domain.com
nameserver xxx.xxx.xxx.xxx
Install SSH Server
If you want to access your server remotely through SSH you need to install SSH server for this you need to run the following command
sudo apt-get install ssh openssh-server
You will be prompted to insert the installation CD again and this will complete SSH server in your Gutsy lamp server.This is really simple and easy server installation for new users and who wants a quick server.
Installing Webmin in Ubuntu Gutsy Gibbon
Webmin is a web-based interface for system administration for Unix. Using any modern web browser, you can setup user accounts, Apache, DNS, file sharing and much more. Webmin removes the need to manually edit Unix configuration files like /etc/passwd, and lets you manage a system from the console or remotely.
You can install webmin for your server web interface to configure apache,mysql servers.Now we will see how to install webmin in Ubuntu 7.10
Preparing your system
First you need to install the following packages
sudo apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl libmd5-perl
Now download the latest webmin using the following command
wget http://prdownloads.sourceforge.net/webadmin/webmin_1.370_all.deb
Now we have webmin1.370all.deb package install this package using the following command
sudo dpkg -i webmin_1.370_all.deb
This will complete the installation.
Ubuntu in particular don’t allow logins by the root user by default. However, the user created at system installation time can use sudo to switch to root. Webmin will allow any user who has this sudo capability to login with full root privileges.
Now you need to open your web browser and enter the following
https://your-server-ip:10000/
Install Subversion tools
sudo apt-get install subversion
Installing rails
Taken from: Here
sudo apt-get install ruby rdoc irb libyaml-ruby libzlib-ruby ri libopenssl-ruby
wget http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz
tar xzvf rubygems-1.0.1.tgz
cd rubygems-1.0.1
sudo ruby setup.rb
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
sudo gem update --system
sudo gem install rails
sudo apt-get install build-essential ruby1.8-dev
sudo gem install mongrel
sudo apt-get install mysql-client mysql-admin mysql-query-browser
sudo apt-get install libmysqlclient15-dev
sudo gem install mysql
sudo apt-get install sqlite3 swig libsqlite3-ruby libsqlite3-dev
sudo gem install sqlite3-ruby
echo "export RUBYOPT=rubygems" >> ~/.profile
rails path/to/your/app
Install ImageMagick
sudo apt-get install imagemagick
sudo apt-get install libmagick9-dev
sudo gem install rmagick -v 1.15.12
Add Modules to Apache
cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/headers.load
sudo ln -s ../mods-available/deflate.conf
sudo ln -s ../mods-available/deflate.load
sudo ln -s ../mods-available/proxy_ajp.load
sudo ln -s ../mods-available/proxy_balancer.load
sudo ln -s ../mods-available/proxy.conf
sudo ln -s ../mods-available/proxy_connect.load
sudo ln -s ../mods-available/proxy_ftp.load
sudo ln -s ../mods-available/proxy_http.load
sudo ln -s ../mods-available/proxy.load
sudo ln -s ../mods-available/rewrite.load
Set up apache
Add a www folder to your home directory
mkdir ~/www
Add this to your apache config file, at the end
/etc/apache2/sites-enabled/000-default
<VirtualHost * >
ServerName YOUR-SERVER-NAME.com
CustomLog /var/log/apache2/YOUR-SERVER-NAME.log combined
DocumentRoot /home/YOUR-USERNAME/www/current/public
<Directory "/home/YOUR-USERNAME/www/current/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
RewriteEngine On
RewriteRule /html / [L,P,QSA]
# Don't do forward proxying
# Enable reverse proxying
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
# RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
# RewriteCond %{SCRIPT_FILENAME} !maintenance.html
# RewriteRule ^.*$ /system/maintenance.html [L]
RewriteRule ^/$ /index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
# Redirect all non-static requests to cluster
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteRule .* http://127.0.0.1:3000%{REQUEST_URI} [L,P,QSA]
# Deflate
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/xml application/xhtml+xml text/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</VirtualHost>
Set up ssl here
Restart Apache
sudo /etc/init.d/apache2
Prepare site for rails
From your development machine, where you are working on the new rails site.
Install capistrano if you havent
gem install capistrano
Capify your site, if you haven’t cd #{rails_root} capify .
Install Subversion
Instructions here
Add your site to subversion, if you havent already
cd {RAILS_ROOT}
cd ..
svn mkdir http://YOUR-SITE.COM/svn/repos/RAILS-PROJECT-NAME -m'adding project'
svn mkdir http://YOUR-SITE.COM/svn/repos/RAILS-PROJECT-NAME/trunk -m'adding project'
svn mkdir http://YOUR-SITE.COM/svn/repos/RAILS-PROJECT-NAME/branches -m'adding project'
svn mkdir http://YOUR-SITE.COM/svn/repos/RAILS-PROJECT-NAME/tags -m'adding project'
svn add . http://YOUR-SITE.COM/svn/repos/RAILS-PROJECT-NAME/trunk -m'adding project'
Edit the {RAILS_ROOT}/config/deploy.rb cap deploy
DONE
Make a CD iso Image in OSX
Insert CD/DVD source
GUI method OSX
- Go to /Applications/Utilities/Disk Utility
- Select the cd SESSION, it’s the cd icon that is indented One level, click info, note the Disk Identifier of the disc, something like disk1s1
- Note: you can click “New Image” to make an image of the cd at this point.
- Select Image Format of DVD/CD Master from the dropdown.
- Make the image.
- Then rename the extension to .iso.
GUI windows I found a nifty windows program Infrarecorder that copies cds and makes images.
Command line method OSX:
Note: the disk1s1 part comes from Disk Utility ( see above ).
diskutil unmountDisk /dev/disk1s1
dd if=/dev/disk1s1 of=file.iso bs=2048
# you now have an iso.
Speed up jruby
This is just a note for myself.
I heard this at a Ruby.MN meeting where Charlie Nutter spoke
If you disable object space when you kick off jruby, it really speeds it up.
jruby -J-server -O your-file-name.rb
(-J-server uses the "server" JVM and -O disables ObjectSpace)
Roles based authentication for rails
This plugin works well.
Shure e5c vs UltimateEars super.fi.5 pro


Super-Fly super.fi.5
Christmas gifts have been opened. Now I can write a review. I gave my brother some super.fi.5 pro earphones for Christmas. I A/B tested against my shure e5c’s. I paid $365 for the Shure’s; I need to be around people sometimes while working, so I gravitated towards coffee shops, and camped out with my laptop. The sound of the roaster or grinder started to get to me so I bought the Shures to dull the din. They worked very well, and after 3 years of ownership I’m positive they have paid for themselves in productivity increase. Ear plugs would have worked too, but silence is boring.
The fit
Both are canalphones. Both come with a wide fit kit ( 4 different sets of silicone and foam eartips ) I found the Shure darker light weight silicone eartips to be the most comfortable amongst the Shures. The super.fi.5 pro have eartips made of the same material as the Shure. The tips are quite comfortable as well. The Ultimate Ears tips are better secured to the earphone, this is a big deal. They won’t slip off. My Shures have a friction fit for the ear tip. The tip sometimes just slides off the Shures.
The Shure fits flush, actually in the ear, they look like hearing aids. The Ultimate Ears I likened to having baby carrots stuffed in my ears. I looked like Uhura on Star Trek. They look like earbuds, not hearing aids.
Both have a flexible wire that wraps around the ear to secure the canalphone. Just like Secret Service agents. the Ultimate ear wins here. The wire is smaller in gauge and more comfortable. The wire is so light that it doesn’t transmit the sound of the wire rubbing against the skin to your ears.
The cord on the Shure’s is 2 feet longer than the UE’s. If you are using the canalphones for an ipod in your pocket, both work, but the Ultimate Ears have the advantage, less cord to get caught on stuff. If you are using these on a laptop, The Shure’s have the advantage, the cord can comfortably fit behind the back, and snake up to the plug.
The price
This is weird, the Ultimate Ears are WAY WAY cheaper. The retail for the UE’s are $250 ( I found mine for significantly less ). The retail for the Shure’s are $599. Given the price difference I thought the sound quality would be different, I was wrong.
About the price of the Shures. A while back I needed service for my Shure’s. Shure doesn’t fix these, they replace them for $120. The $600 price most likely is 2 middle mans worth of markup.
The sound
Both sound great. You can definitely hear difference in MP3 sample rates. You can hear the fingers brush against the texture of a guitar string. The difference vs normal ipod buds is amazing. There is texture and presence to the sound that either have.
That said I prefer the Ultimate Ears, just. The sound is open and bright yet still has lots -O- Bass. They sound alive, like a really good studio monitor. The sound has more presence than the Shures, Presence like Sennheiser HD 600’s or Magnaplaner speakers. That good.
Both have ridiculous sensitivity, you can hear if the earphone is plugged in, even if no music is playing. That said, start with the volume OFF, loud == pain with either of these. Both seal your ear canal, If you don’t hear lots of Bass, the fit is wrong. Try wetting the tip with saliva ( ick ). They block as much sound as normal earplugs when properly fitted. You can listen to very quiet music in very noisy locations.
How random is random, Ruby on Rails UUID's 2
I needed a good random number. Some opensource login generator I used had
They made a random number like this.
Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )
I don't know if thats really random. I think it is.
UUID's are unique by definition. I have a ruby uuid library.
Ruby is slow for UUID's
Mysql is fast.
# a function that uses mysql > 4.1 to generate uuid's. Just stick it in your model.
def uuid()
sql = "SELECT UUID()"
record = connection.select_one(sql)
return record['UUID()']
end
Rails RJS page.replace_html "div_id_name", :text=> "text goes here" 1
I constantly get burned on this one. You cannot render partial :text in an rjs template.
NO :: page.replace_html "div_id_name", :text=> "text goes here"
YES :: page.replace_html "div_id_name", "text goes here"
My pain your gain.
Undelete a file in linux ext3 filesystem
Yes I screwed up. And I needed that file too.
After alot of looking I found the solution
download sleuthkit unzip and compile. The program you need is in that-folder/bin
Basicly:
Open up a terminal session.
su root
# find the device that your hard drive is using
mount | column -t
# open up the drive in debugfs, In my case the drive is at /dev/sda1
debugfs /dev/sda1
# cd to where the file was
cd /var/mail
# show the deleted file
ls -d
# the deleted files are in the brackets <somenumbers>
# note that number
q
# find the block group that contains that node
debugfs: imap <415926>
Inode 415926 is part of block group 25
located at block 819426, offset 0x0a80
# find the Blocks per group for the drive
debugfs: stats
[...]
Blocks per group: 32768
[...]
# figure out the start block
# start-block= block-group * blocks-per-group
# figure out the end block
# end-block= start-block + blocks-per-group - 1
# Run sleuthkit and get the file
cd {sleuthkit directory}/bin
# for this demo case
# start-block=819200
# end-block=851867
# make sure that the file you write to ( > ) is on a different filesystem or you may overwrite your source file, I didn't do this and got lucky.
dls /dev/sda1 819200-851867 > /mnt/yourdata.dat
# your data MAY be at /mnt/yourdata.dat
django ImportError: No module named yoursitename 2
This has been frustrating me on and off for quite a while. Here’s how to fix it.
add a file called __init__.py to your folder. Done.
The error message, if you can call it that, is vague.
Basically, all python modules require this file.
Django doesn’t add one when you create a site ( an oversight in my opinion ), so you have to remember to add one. I have been doing PYTHONPATH funkiness and other hacks to get the site working without this. Now I can just relax, code and drink tea.
Computer accessories Signal - 2 - Noise
I just bought a most important computer accessory, eyeglasses. My prescription is very light, but was having trouble with monitors. I asked the eye doctor about this. I had been using my reading glasses. Doctor said for computer use go down .25 from your reading glasses, this is because of the different focal target area, computers are further away than books. So 1.00 becomes 0.75. I can concentrate much easier. More Signal, less noise