My Science Is Better

18Sep/110

Heroku on Ubuntu

As everything that comes from ruby world, getting heroku running on Ubuntu is not as easy as we're used to (ie: apt-get install heroku) so there are a few steps that need to be followed. I've written this down so i can come back to it later and so that others don't lose hours trying to figure this out. The data on this article has been scraped from http://www.web2linux.com/05/installing-rails-3-on-ubuntu-10-04-lucid-lynx/ and http://devcenter.heroku.com/articles/quickstart

Installing dependencies

sudo apt-get install curl git-core build-essential zlib1g-dev libssl-dev libreadline5-dev

Install rvm

#for latest, check https://rvm.beginrescueend.com/
bash < 

Install ruby-1.9.2

rvm install 1.9.2 && rvm use 1.9.2 --default

Then add this line as the last line in your .bashrc:

if [[ -s "$HOME/.rvm/scripts/rvm" ]];
        then source "$HOME/.rvm/scripts/rvm";
fi

Install Heroku

Sign-up for a Heroku account if you haven’t already and then install the herokugem.

gem install heroku

You will be asked to enter your Heroku credentials the first time you run a command; after the first time, your email address and an API token will be saved to ~/.heroku/credentials for future use.

It’s generally a good idea to add your public key immediately after installing the heroku gem so that you can use git to push or clone Heroku app repositories:

heroku keys:add
Enter your Heroku credentials.
Email: joe@example.com
Password:
Uploading ssh public key /Users/joe/.ssh/id_rsa.pub

Track your application with Git

If you’re already using Git with your application, skip to the next step. If you’re not yet using Git to track your application, run this:

cd PATH/TO/MY_APP
git init
# Initialized empty Git repository in .git/
git add .
git commit -m "new app"
Created initial commit 5df2d09: new app
44 files changed, 8393 insertions(+), 0 deletions(-)

Create your Heroku application

At the command line, run heroku create. The first time you do this, you’ll be asked to enter your Heroku credentials. Once you do, your email address and an API token will be saved to ~/.heroku/credentials, so you won’t have to provide them again.

This first use will also upload your public SSH key so you’ll be able to push and pull code.

heroku create
Enter your Heroku credentials.
Email: joe@example.com
Password:
Uploading ssh public key /Users/joe/.ssh/id_rsa.pub
Created http://high-sunrise-58.heroku.com/ | git@heroku.com:high-sunrise-58.git
Git remote heroku added

The last line shows the name of your new Heroku app; in this case, it’s “high-sunrise-58”, and is available at http://high-sunrise-58.heroku.com. If you were to visit that URL before pushing your application code (either by typing it in or running heroku open), you’d see a standard Heroku welcome page.

On the next to last line, there’s another important piece of information: git@heroku.com:high-sunrise-58.git. This is the Git repository address for your new Heroku app, and if you check the output of git remote show heroku you can see that the heroku gem added it as a remote for you automatically.

Push your application to Heroku

git push heroku master
Counting objects: 65, done.
Compressing objects: 100% (58/58), done.
Writing objects: 100% (65/65), 80.54 KiB, done.
Total 65 (delta 14), reused 0 (delta 0)

-----> Heroku receiving push
-----> Rails app detected
       Compiled slug size is 0.1MB
-----> Launching....... done
       App deployed to Heroku

To git@heroku.com:high-sunrise-58.git
 * [new branch]      master -> master

Bootstrap your database

Your app is now running on Heroku with an empty database. Depending on your framework, run the appropriate command to set up your DB. For Ruby on Rails, run:

heroku rake db:migrate
(in /mnt/home/slugs/41913_b81cc1e5813c58c443e4120aff984d006f36ef20/mnt)
== 20081118092504 CreateWidgets: migrating ====================================
-- create_table(:widgets)
   -> 0.0519s
== 20081118092504 CreateWidgets: migrated (0.0520s) ===========================

That’s it, your app is now running on Heroku! You can take a look at it in your default web browser by running heroku open.

Next Steps

Now that your application is running, it’s easy to push updates:

Develop and test changes locally.
Commit code to git.
Push your changes to Heroku with git push heroku.

14Jul/1118

Install native 64bit Flash Player 11 on Linux

Update 3 [30 10 2011]: The script was updated to install of Flash Player 11.2 Beta
Update 2 [7 09 2011]: The script was updated to install rc1 of Flash Player 11
Update 1 [13 08 2011]: The script was updated to install b2 of Flash Player 11

Abobe released yesterday the first beta of Flash Player 11 for Linux 64 bit.

I've put together a small script that takes care of installing it on Ubuntu:

#!/bin/bash
# Script  created by
# Romeo-Adrian Cioaba romeo.cioaba@spotonearth.com

echo "Stopping any Firefox that might be running"
sudo killall -9 firefox

echo "Removing any other flash plugin previously installed:"
sudo apt-get remove -y --purge flashplugin-nonfree gnash gnash-common mozilla-plugin-gnash swfdec-mozilla libflashsupport nspluginwrapper
sudo rm -f /usr/lib/mozilla/plugins/*flash*
sudo rm -f ~/.mozilla/plugins/*flash*
sudo rm -f /usr/lib/firefox/plugins/*flash*
sudo rm -f /usr/lib/firefox-addons/plugins/*flash*
sudo rm -rfd /usr/lib/nspluginwrapper

echo "Installing Flash Player 11"
cd ~
wget 'http://download.macromedia.com/pub/labs/flashplatformruntimes/flashplayer11-2/flashplayer11-2_p1_install_lin_64_102611.tar.gz'
tar zxvf flashplayer11-2_p1_install_lin_64_102611.tar.gz
sudo cp libflashplayer.so /usr/lib/mozilla/plugins/
sudo cp -r usr/ /usr

echo "Linking the libraries so Firefox and apps depending on XULRunner (vuze, liferea, rsswol) can find it."
sudo ln -sf /usr/lib/mozilla/plugins/libflashplayer.so /usr/lib/firefox-addons/plugins/
sudo ln -sf /usr/lib/mozilla/plugins/libflashplayer.so  /usr/lib/xulrunner-addons/plugins/

# now doing some cleaning up:
sudo rm -rf libflashplayer.so
sudo rm -rf usr/
sudo rm -rf flashplayer11-2_p1_install_lin_64_102611.tar.gz

A very interesting application that comes bundled in this release is the "flash-player-properties" app which allows us to finally be able to set permissions to mic/camera on websites.

3May/110

Ubuntu show desktop on corner hover (mac os x style)

Open gconf-editor
ALT+F2

gconf-editor

Navigate:

apps → compiz → general→ allscreens → options → show_desktop_edge

If the show_desktop_edge key is not there, create it as string and then add the value BottomLeft and save.

19Feb/110

How to: Replace OpenOffice.org with LibreOffice on Ubuntu

Here are a few easy steps to replace openoffice.org with libreoffice on ubuntu:

CLI instructions (these will take care of removing OpenOffice.org and installing LibreOffice):

Add the PPA and install LibreOffice:

sudo add-apt-repository ppa:libreoffice/ppa
sudo apt-get update
sudo apt-get install libreoffice

For GNOME integration (for people running default Ubuntu):

sudo apt-get install libreoffice-gnome

or for KDE Integration (for people running Kubuntu):

sudo apt-get install libreoffice-kde

As of Ubuntu 11.04, LibreOffice will replace by default OpenOffice.

24Jan/115

Fix gitk ugly fonts in Ubuntu

I've recently started playing around with git and found out the power of gitk. Gitk is a small tool built using tcl/tk that helps the user visualize the changes he's done in a graphical, easy to follow manner. By default Ubuntu 10.10 ships with tk8.4 installed by default and that makes gitk look really ugly, as tk8.4 doesn't support antialiased fonts. To fix this problem simply install tk8.5 and make it default on your machine:

sudo apt-get install tk8.5
sudo update-alternatives --config wish
# a list will show up and you need to type in the number that corresponds to tk8.5 (in my case was 3) then hit enter.

That's it. You can now reopen gitk and see the difference.

Tagged as: , , , , , 5 Comments
16Jan/111

Find string in files and show line number with grep

Handy snippet to find some string inside the files in a directory:

grep -r --line-number "string_you_search" path/where/to/look

Note the -r tells grep also to look into all subfolders recursively.

Tagged as: , , , 1 Comment
7Nov/101

Setup VPN server and client using OpenVPN

The good thing during the last years is that net access is almost everywhere, and is pretty cheap or even free. A lot of bars, hotels, restaurants offer a free wifi connection, but most of the times that connection is not secured. The biggest security risk with unencrypted connections is the man-in-the-middle type of attack. You are sitting on a bar, checking email, browsing and all your traffic is not encrypted. That means that an attacker can tap into your connection and "listen", intercept everything you are typing. Like that the attacker can get sensitive data (accounts, passwords, credit card numbers etc.)

Since you don't have any control over the connection, what one can do to protect himself is to use a VPN. With a VPN, you are creating a secure (encrypted) point-to-point connection between your PC and the VPN server. Translated, that means that all the Internet traffic you are doing, is going through that secure channel, which can't be hacked that easily.

Here us how to setup a vpn server using openVPN

The server

1. Install openvpn and openssl

sudo apt-get install openvpn libssl-dev openssl

2. Configurations

cd /etc/openvpn/
cp -r /usr/share/doc/openvpn/examples/easy-rsa/2.0/* /etc/openvpn/easy-rsa/

3. Create server certificates

cd /etc/openvpn/easy-rsa/
source vars
./clean-all
./build-dh
./pkitool --initca
./pkitool --server server
cd keys
openvpn --genkey --secret ta.key
cp server.crt server.key ca.crt dh1024.pem ta.key /etc/openvpn/

4. Create client certificates

cd /etc/openvpn/easy-rsa/
source vars
./pkitool hostname

For each new client that connects to the VPN you'll need to create new client certificates using step 4

5. Create server configuration file:

cp /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz /etc/openvpn/
gzip -d /etc/openvpn/server.conf.gz

After editing your file should look like this:

dev tun
proto tcp
port 1194

ca ca.crt
cert server.crt
key server.key
dh dh1024.pem

user nobody
group nogroup
server 10.10.0.0 255.255.255.0

persist-key
persist-tun

client-to-client

push "redirect-gateway def1"
push "dhcp-option DNS 208.67.222.222"
push "dhcp-option DNS 208.67.220.220"

6. Enable routing and MASQUERADE for your VPN by placing the following in your /etc/rc.local

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 10.10.0.0/24 -o eth0 -j MASQUERADE

7. Start the server

/etc/rc.local
/etc/init.d/openvpn restart

The Client

1. Ubuntu (all modern linux?)
I'm using an Ubuntu machine as a client. To use openvpn in Ubuntu just install the openvpn plugin for NetworkManager:

sudo apt-get install network-manager-openvpn

A reboot is recommended.

You can now go and add your connection in Network Manager

2. Windows - to come
3. Mac OS X - to come

Tagged as: , , 1 Comment
17Sep/1020

Install Adobe® Flash® Player “Square” on Linux

Adobe® Flash® Player "Square" is a preview release that enables native 64-bit support on Linux, Mac OS, and Windows operating systems, as well as enhanced support for Microsoft Internet Explorer 9 beta.

I'm glad to see Adobe has is finally embracing the way it should the 64 bit Platform. This release is a milestone as far as i know, as is the first one that's released in the same time for win, mac and linux. I've put together a small tutorial on
how to install adobe flash player square on linux:

#!/bin/bash
# Script  created by
# Romeo-Adrian Cioaba romeo.cioaba@spotonearth.com

echo "Stopping any Firefox that might be running"
sudo killall -9 firefox

echo "Removing any other flash plugin previously installed:"
sudo apt-get remove -y --purge flashplugin-nonfree gnash gnash-common mozilla-plugin-gnash swfdec-mozilla libflashsupport nspluginwrapper
sudo rm -f /usr/lib/mozilla/plugins/*flash*
sudo rm -f ~/.mozilla/plugins/*flash*
sudo rm -f /usr/lib/firefox/plugins/*flash*
sudo rm -f /usr/lib/firefox-addons/plugins/*flash*
sudo rm -rfd /usr/lib/nspluginwrapper

echo "Installing Flash Player Square"
cd ~
# 64 bit
wget http://download.macromedia.com/pub/labs/flashplayer10/flashplayer_square_p1_64bit_linux_091510.tar.gz
tar zxvf flashplayer_square_p1_64bit_linux_091510.tar.gz
# 32 bit
# wget http://download.macromedia.com/pub/labs/flashplayer10/flashplayer_square_p1_32bit_linux_091510.tar.gz
# tar zxvf flashplayer_square_p1_32bit_linux_091510.tar.gz
sudo cp libflashplayer.so /usr/lib/mozilla/plugins/

echo "Linking the libraries so Firefox and apps depending on XULRunner (vuze, liferea, rsswol) can find it."
sudo ln -sf /usr/lib/mozilla/plugins/libflashplayer.so /usr/lib/firefox-addons/plugins/
sudo ln -sf /usr/lib/mozilla/plugins/libflashplayer.so  /usr/lib/xulrunner-addons/plugins/

# now doing some cleaning up:
sudo rm -rf libflashplayer.so
sudo rm -rf flashplayer_square_p1_64bit_linux_091510.tar.gz

To check if the install did it's job, you need to check about:plugins in your address bar. It should show you this for flash player:

Shockwave Flash

File: libflashplayer.so
Version:
Shockwave Flash 10.2 d161
MIME Type Description Suffixes Enabled
application/x-shockwave-flash Shockwave Flash swf Yes
application/futuresplash FutureSplash Player spl Yes

As usual, I've wrapped everything mentioned before into a script to easily install flash player square on Linux

If this version doesn't work out that well for you, you can still check my other tutorial on how to install native 64bit flash player on Linux
Happy browsing!

30Aug/101

CLI Disk Usage

Modern Linux systems have plenty of tools for both Gnome and Kde to analyze the disk space. But if you log into a server via SSH or similar, you're out of luck. You need a tool for Cli Disk Usage analytics. That tool is ncdu.

You can install it easy:

sudo apt-get install ncdu

Issuing ncdu inside the folder you want to check will open a cool ncurses interface, really easy to use :)

29Aug/100

Converting disc images to another format on Linux

While this information is available all over the net, i find myself losing enough time now and again trying to figure out how to convert a disk image to iso or something useful for that matter. So i decided to put together a small tutorial on converting disk images to another format on Linux, so i can easily access it whenever i need it.

The most popular disk image formats i've had to deal with are: iso (which Ubuntu handles by default perfectly), CloneCD/IMG (used by CloneCD), CUE/BIN, MDF (created by Alcohol 120%), NRG (Nero images) and last but not least DMG (format used mainly by Apple).

Since Linux handles very well .iso files, the idea is to convert any of the image types listed into iso and then the job is easy. For all of the formats there are tools to do just that. You can install them as follows:

sudo apt-get install ccd2iso bchunk mdf2iso nrg2iso dmg2img

Example usage:

# ccd
ccd2iso /path/to/example.img /path/to/example.iso
# bin/cue
bchunk /path/to/example.bin /path/to/example.cue /path/to/example.iso
# mdf
mdf2iso /path/to/example.mdf /path/to/example.iso
# nrg
nrg2iso /path/to/example.nrg /path/to/example.iso
# dmg
dmg2img filename.dmg

Some of those formats can be also mounted using the CLI:

# ccd/img
sudo mount -o loop example.img /media/example
# nrg
sudo mount -o loop,offset=307200 /path/to/example.nrg /media/example
# dmg
dmg2img /path/to/example.dmg /path/to/example.img
sudo modprobe hfsplus
sudo mount -t hfsplus -o loop example.img /media/example

Tag Cloud

Categories

Archives

Akismet

Blogroll

Ads