Dev Setup on Linux Mint

Instead of continuously plugging my nice big monitor and mechanical keyboard into my work Macbook Pro, I decided to setup a Linux VM on my home desktop so I could do the same things I can do on the Mac. As most of the things I work with are under version control, it should be relatively simple to switch between machines.

The main things I needed were:

  1. Ruby on Rails with Postgresql
  2. Latex
  3. Python 3 and IDLE, along with some of the graphics libraries

I usually use Ubuntu, but for a change I decided to check out Linux Mint, a very popular variant.

Ruby on Rails

Based on a quick read of various blog posts, rbenv seems to be the tool more people now use to manage their ruby versions, so that’s what I decided to go with. ruby-build is also necessary to actually install ruby versions easily. Both repos and their instructions can be found on github.

  1. https://github.com/sstephenson/rbenv
  2. https://github.com/sstephenson/ruby-build

Bundler is used to manage rubygems. See more at http://bundler.io/

It’s really easy to install. Just run gem install bundler

Checkout the Rails app then run bundle install

Postgresql

To install Postgresql, I followed the instructions from their download page for Ubuntu. Linux Mint Rebecca is based on Trusty Tahr (Ubuntu 14.04), so I used that. It was also necessary to install the postgresql-server-dev-9.4 package as the pg gem needs it.

To allow my user to login with psql and do useful things, it was also necessary to create a postgres role with create db rights for my OS username.

\LaTeX

This was easy. Install texlive from the package manager. I had a missing package later on but a quick Google search told me what to install. Can’t remember the package name.

Python 3

sudo apt-get install python3-dev
sudo apt-get install python3-pip
sudo pip3 install PILLOW
sudo apt-get install idle-python3.4

iPod Touch Not Recognized

iTunes suddenly refused to recognize my iPod Touch when I plugged it in even though it shows up on Windows 8. I was pretty sure it had worked before.

Apple has a troubleshooting guide for just this scenario. http://support.apple.com/kb/TS1538

Under Step 5 (Verify that the Apple Mobile Device USB Driver is installed), I found the iPod under “Portable Devices” and followed the steps to update the device driver. The driver is in the “C:\Program Files\Common Files\Apple\Mobile Device Support\Drivers” folder. Once that was done, I restarted iTunes and my iPod was recognized immediately.

Android LED Torch App

The most popular android torch apps ask for tons of ridiculous permissions. They want network access, memory access and just about every permission available. The ONLY permission actually needed is camera access. It’s very worrying to grant so many permissions to a simple torch app. Who knows what it’s doing behind the scenes? Thus I never downloaded one and decided to just write my own instead. After all, how hard could it be?

A search for “android torch app development” led to this article on Android Hive. The code is a bit old so one of the alert dialog functions has been deprecated. I also skipped the whole part about adding in sound effects and used a built in Switch instead of trying to do a fancy image switch.

I used the instructions on handling click events on the Toggle Button page instead of the alternative of adding an onCheckedChangeListener as suggested by the Android Hive tutorial.

That seemed simple enough. The program crashed when I tried it on the emulator, I didn’t debug it but guessed it was due to the lack of a torch on the emulator. The alert should have come up but the code was deprecated so perhaps API 19 doesn’t even have it. I might be wrong about this. Anyway, I loaded it onto my device, andddd nothing happened 😦

According to this StackOverflow thread, the flash won’t work for some devices without the SurfaceView and SurfaceHolder components. This other thread gives a lot more detail on how to implement it. The answer is complete, but the line “Your activity needs to implement SurfaceHolder.Callback” literally means something in code. Not obvious on an initial copy and paste.

public class MainActivity extends Activity implements SurfaceHolder.Callback {

Note the addition of implements SurfaceHolder.Callback
Without this bit, the function to add a callback to the SurfaceHolder will fail as the this object is the wrong type. This thread contributed to the required inspiration.

Another thing I had to do was to remove the camera.release() line to stop the program crashing with a null pointer exception when the flashlight is switched off then on again.

Here’s a screenshot of this very simple app.

image

Thunderbird Profile Location

Profile with mail settings and stuff is in C:\Windows.old\Users\\AppData\Roaming\Thunderbird\Profiles\.default\

%AppData% resolves to the Roaming directory, not the Local one. This is even if the email folders have been stored elsewhere.

See https://support.mozillamessaging.com/en-US/kb/profiles#w_restoring-a-profile-backup

Useful information about passwords
http://kb.mozillazine.org/Setting_and_changing_email_passwords

Git HTTP Access

Setting up Git on AWS was easy. It was a lot harder to get HTTP pull and push access. WebDAV worked for pull, but pushing kept giving return code 22.

Turned out that the article for that was outdated and the new method involves git-http-backend.
http://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html

Instructions there are meant for general use. Some things need to be changed for Ubuntu 12.04.


sudo a2enmod cgi
sudo a2enmod alias
sudo a2enmod env

but those should already be enabled.

Put server config lines in httpd.conf, which is empty on AWS as the main apache config file is apache2.conf
Set GIT_PROJECT_ROOT to parent directory of all the .git folders
ScriptAlias is /usr/lib/git-core/git-http-backend/ instead of the libexec folder shown in the instructions. The final slash is important!! Found this out by checking the error log.

Added to /etc/apache2/sites-enabled/000-default file

In conf.d folder, added git.conf file.

<Location /git/repo.git>
AuthType Basic
AuthName "Private Git Access"
AuthUserFile /etc/apache2/passwd.git
Require valid-user
</Location>

This ensures authentication is needed. Create the password file with htpasswd

chown and chmod all the files and folders in the repository to give www-data read/write access.

Moving Mozilla Thunderbird to a New Computer

Thunderbird’s email account settings are all stored in the user’s profile folder. To get the whole setup back, just copy the profile folder from the old machine to the new one.

For me, my email storage location still had the same path, so there was no issue with the actual emails themselves.

For information about moving profile, see https://support.mozillamessaging.com/en-US/kb/profiles