Friday, September 17, 2010

Ripping DVDs and Ubuntu

I've been mucking around now for a while trying to work out the best way to rip and encode DVDs.

I tried using Handbrake for a while to rip and encode, but what I really want is something that just does it in the background. On the mac, RipIt is a great tool for ripping the DVD to the HDD allowing you to go back at your leisure and encode it.

What i really want is a solution that will autorip on DVD tray-close (like RipIt on the mac) and then a cron that will encode. This is a post about how I get on.

First, we'll need to add restricted formats:
  • sudo apt-get install libdvdread4
  • sudo /usr/share/doc/libdvdread4/install-css.sh
Now, install dvdbackup
  • sudo apt-get install dvdbackup
Create a directory to put the ripped DVDs into and enter it and execute the command to rip the DVD:
  • mkdir Ripped
  • cd Ripped
  • dvdbackup -M
You can also use the -F option rather than -M to just get the main feature, but I had bother with using handbrakeCLI to encode after doing that. Also use the -v flag to give a bit more output.

And, to eject, just use the command
  • eject
So, now we need to work out how to do that automatically when a DVD is inserted into the machine. In the perfect world, we'd do that using the terminal only so that it could run flawlessly on a headless server.

Handbrake

We need to install handbrake from a PPA.
  • sudo add-apt-repository ppa:handbrake-ubuntu/ppa
  • sudo apt-get update && sudo apt-get install handbrake-cli
Then, it's a simple hop skip and a jump to a simple CLI command to encode the ripped disc using a preset for "Film"
  • HandBrakeCLI -i 21/ --main-feature -o 21.mp4 --preset="Film"
Amazingly, this encoded the film at, on average, 280fps (granted, I'm running a quad core AMD monster), but still! I'd tried this on the Mac, using the GUI version and was getting an encode with an average fps of about 9!

Sunday, September 05, 2010

Drweb and plesk

I have been getting some really irritating emails for a couple of weeks from Plesk... actually, it's been a bit longer than that, but I just filtered them out via a gmail auto-delete - probably not the best way to deal with the situation!

What's strange it that I didn't even have dr-web installed. A couple of searches on google revealed a helpful page on serverfault.com which suggested that diabling the update call in the drweb-update cron would be helpful.

So:
  • sudo touch var/log/drwebupdate.log
  • sudo joe /etc/cron.d/drweb-update
  • add ">> /var/log/drwebupdate.log" to the line that has update.pl
  • save the file...

Tuesday, July 13, 2010

tbackup and Plesk

I just installed tbackup from 4psa for Plesk. It installed fine and the licence was installed without a problem. However, every time I tried to set it up, it said that the directory that the backups were to be saved to didn't exist.

Problem was that the debs are for 32-bit systems and the system is 64-bit. A helpful tech from 4psa kindly informed me that the ia32-libs package needed installing.
sudo apt-get install ia32-libs

And everything works fine.

Monday, June 14, 2010

Rhodes + Android + Eclipse + Ubuntu 10.4

In an attempt to start using Rhodes to build an Android app, I'm building my local dev environment, hence the title "Rhodes + Android + Eclipse + Ubuntu 10.4".

Handy pages:
Installing ruby and some essentials

So.. let's start at the beginning, we'll need Ruby, rails and rubygems (which is now in the repros - change the X.X below for the latest version - use tab-complete to the the options).
sudo apt-get install ruby-full build-essential rubygemsX.X
Installing rhodes

Once we have done that, let's get rhodes (version 2.0 is currently in beta)
sudo gem install templater
sudo gem install rake
sudo gem install rails
sudo gem install rhodes --pre
Irritatingly, the apt-get install of rubygems doesn't add the path of the gems that we later installed to the PATH... doh! Have a look where rubgems has been installed to - should be something like "/usr/lib/gems/1.9.1/" although the last directory name will clearly depend on what version you installed above. Open up ~/.bashrc and add (thanks to adamtao):
PATH = "${PATH}":/var/lib/gems/1.9.1/bin
export PATH
You also need to install eclipse and the Android SDK and NDK. I'm not going to list the routine for getting it done since it's explained well elsewhere. Setup for android development including getting all the files from the android development site. Setup an Android AVD (Android virtual device) and test the emulator with a simple hello world script.

Setting up rhodes

Now we need to link our rhodes installation to the SDK and eclipse.
rhodes-setup
You'll be prompted with questions - my answers are below:
  • JDK path: /usr/lib/jvm/java-6-openjdk/
  • Android SDK path: /opt/androidSDK/
  • Android NDK path: /opt/androidNDK/
  • the remainder of the questions related to Windows and Blackberry: (left blank)
Helpful way to find paths is to either look in your path (echo $PATH) or use "locate" (locate java > java_list) and then look in the java_list file that has just been created.

Create a soft link to the rhodes directory:
sudo ln -s /var/lib/gems/1.9.1/gems/rhodes-2.0.0.beta9/ /var/lib/rhodes
First application

So, for now, I'm going to work via the command line and with gedit to edit files; using tutorial2 as a starting point:
  • rhogen app testapp
  • cd testapp
  • joe build.yml
    I wanted to remove the iphone refs and add in some android ones
sdk:"/var/lib/gems/1.9.1/gems/rhodes-2.0.0.beta9"
sdkversion: 2.0.0
name: testapp
version: 1.0
vendor: rhomobile
build: debug
bbver: 4.6
applog: rholog.txt
android:
version: 2.1
extensions: ["extension-name-here", "second-extension-name"]
  • rake run:android
You'll be asked if you want to setup hardware - type yes and answer the questions.

When you have finished, and want to uninstall the app:
  • rake uninstall:android


More to come as a work through the process

Smartphone app development

At radiopaedia.org, we have had iPhone apps for a while - and they are great. However, with a growing userbase that is using Android and other platforms, we'd really like to expand our apps and develop our teaching files for Android too.

Given the usual mantra of "okay, I'll give it a go", I'd launched myself head first into Android app development. My coding background is traditional webdesign - HTML, PHP, CSS and a little bit of javascript (which has been increasing lately with the use of Jquery).

So, the Java environment that is Android development is completely new to me. After a late night and a little bit of progress, I was pointed in the direction of Rhodes - a Ruby-based development stack that allows traditional HTML, CSS and javascript for designing your app and a Ruby backend for the MVC part of the app.

It sounds amazing - and what's better is that you can take your Rhodes app and build it as an iPhone app, Android app, windows mobile app... And it builds the Objective C++, Java etc. And, to give the apps a naitive feel, all you need to do is tweak the CSS - amazing.

For development, I could use RhoHub, an online SDK which looks pretty cool. But, if you want to create private apps with more than 3 contributors, you need to pay. So, I'm going to attempt to build a Rhodes development environment locally using the Android SDK and eclipse on Ubuntu 10.4 - with me luck!

Blogger templater

I'd heard about the new blogger templater, but hadn't had a chance to play with it. But, given that I'm just about to post another item to the blog about smartphone app development, I thought I'd have a play. And... I was duly impressed... and after a couple of clicks have a much improved look to the blog.

Monday, May 17, 2010

Local development with GIT and Plesk

I'm loving GIT. But, what I really wanted to do was to create a development environment locally that pushed changes to a server which was therefore always up to date.

So, I've got an Ubuntu (lucid) machine locally and an Ubuntu server running Plesk 9.x remotely.

Make sure that git is installed on both systems
sudo apt-get install git-core
Make sure that you setup Plesk to give the user shell access (bin/bash) in Web Hosting Settings.

Follow this helpful todo.

Easy! When you are working remotely to setup the git repro, you will need to be root - so remember to change the httpdocs and httpdocs.git directory permissions back to "username:psaserv" and do it recursively:
chown -R username:psaserv httpdocs
chown -R username:psaserv httpdocs.git
Passwordless login and git clone

It's worth while setting up passwordless login:
ssh-copy-id -i .ssh/id_rsa.pub username@domainname.tld
Then, the command to get the git repro locally becomes:
git clone ssh://username@domainname.tld/var/www/vhosts/domainname.tld/httpdocs.git
Setup apache

You'll need to make sure the apache2, php5 are installed:
sudo apt-get install apache2 php5
You need to setup apache by editing the conf file: /etc/apache2/sites-available/default. If you are going to run multiple local sites, you'll have to declare them here. For each site, add the following:
<VirtualHost *:80>
ServerName localservername
DocumentRoot /home/sites/location/httpdocs/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/sites/location/httpdocs/ >
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
You also need to edit /etc/hosts to provide a route to your local server. Add a line:
127.0.0.1 localserver

Setup database forwarding

We could just setup mysql or other database locally. However, then you need to try and keep local and remote databases synced. If you are just reading, it's much simpler to setup an ssh tunnel to your remote server.

While the ssh for the git clone was as a plesk user of the particular website, this ssh should be performed as a user of the server i.e. it should log you in a you, not as a website. You need to make sure that mysql is NOT running locally:
sudo stop mysql
And then, type
ssh -L3306:localhost:3306 remoteserver.tld
For ease, if you save this command to a file and put it in /usr/local/bin and then "chmod +x" it, you can simply type the name of the file (e.g. connect) and the tunnel will be set up.

Connecting to the tunnelled mysql db via PHP

The other piece of glue is to realise that you can't connect to the database as localhost, you have to use 127.0.0.1, e.g.:
mysql_connect('127.0.0.1', $username, $password);
All in all, a pretty successful development environment.