Thursday, March 26, 2009

ocaml batteries on Ubuntu

OCaml is a functional programming language. I'm trying to learn it right now, but it clearly has a steep learning curve, especially if you aren't familiar with functional programming languages. It does seem impressive in many ways, but we'll see, eh?

Anyway, the standard library seems a little sparse, so I am trying to install 'batteries'. Turns out it wants some dependencies to build and they aren't entirely straightforward. Here's how to get it building:

sudo aptitude install libcamomile-ocaml-dev libzip-ocaml-dev libtype-conv-camlp4-dev
libsexplib-ocaml-dev libbin-prot-camlp4-dev libocamlnet-ocaml-dev

(do we need libmagic-ocaml-dev ??)
This is super weird, you have to configure the program as super user because it wants to make a directory for batteries in /usr/local. Anyway, here's the install

sudo ./configure
sudo make all opt install install-doc

And it does take forever to make the documentation (maybe 5 minutes to install on my computer).

Friday, March 6, 2009

how to set up your own git repository with only a server, ssh, and git

This assumes you have ssh access to a server somewhere which you want to use as a sort of centralized repository and that server and your local machine have git on them. Don't tell anyone I used centralized and git in the same sentence, but centralized makes a lot of sense to me for lots of things, especially my own projects.

I'll do it the long way first and then with a tiny bit of bash scripting:

# ssh into your server
ssh jtprince@yourserver.domain.edu
# on remote machine:
mkdir git
mkdir git/project1.git && cd git/project1.git
git --bare init
exit

# on local machine
mkdir project1 && cd project1  # if you don't already have a project
# make a commit (you need at least one commit)
git init
echo "some text" > file.txt
git add .
git commit -m 'init commit'

# now we will push it to the server
git push ssh://jtprince@yourserver.domain.edu/home/jtprince/git/project1.git master

# we still need to link our git folder with the server
git remote add origin ssh://jtprince@yourserver.domain.edu/home/jtprince/git/project1.git
git config branch.master.remote origin
git config branch.master.merge refs/heads/master

Now for the BASH scripting I promised. This is basically the same thing but maybe a little easier to copy and paste once you set up your variables:

SERVER='jtprince@yourserver.domain.edu'
PROJ="project2"
PROJ_URL="ssh://$SERVER/home/jtprince/git/${PROJ}.git"

# set up the remote git repo in one command:
ssh $SERVER "mkdir git/${PROJ}.git; cd git/${PROJ}.git; git --bare init"

# (inside your project directory... with files/dirs already present):
git init ; git add . ; git commit -m 'init commit'; git push $PROJ_URL master ; git remote add origin $PROJ_URL ; git config branch.master.remote origin ; git config branch.master.merge refs/heads/master


And my rant...

At least in the ruby and linux developer community, Git seems to be quite hip right now. I personally think bazaar wipes git all over the floor, but due to server circumstances beyond my control I need to version control my files with git.

While the above operation is CLEARLY and SUCCINCTLY documented in the main bazaar docs, I've had to piece this together myself for git. Now, I suppose if I had actually read and digested the volumes of arcane documentation, switches, and nuances of git, I wouldn't be griping right now. That said, projects like 'eg' can make it easier and I'm sure the things people want to do with a vcs will become documented soon enough in git... the beauties of open source.

Tuesday, February 17, 2009

Gnome Do Dominates

I am always trying to do things faster, and as we all know, using the keyboard is often faster than the mouse. Gnome Do, which you can install from synaptic is intuitive and lets you really fly. Try it out.

Friday, February 13, 2009

Can't mount external hard drive

Some people have suggested "forcing" your external hard drive to mount. This is a bad idea as you can lose your data. Simply plug your external hard drive into a Windows system and then safely remove the external hard drive; if you just unplug it without safely removing it, Ubuntu won't let you mount it without forcing it to.

Tuesday, January 13, 2009

Aggregate in R

For data that needs to be collapsed, the aggregate() function works great. For example:



If you need to collapse these so you only have one row per GLEAN, and have the Female and Male columns be the average of the collapsed rows, aggregate() can do this in one line:

collapsed_data<-aggregate(x=original_data, by=file_with_GLEAN_names_only, FUN=mean)

I used this to find the average expression levels of genes from a table that had the expression levels of each exon. Since some genes had one exon while others had many exons, aggregate was perfect for this situation. It did take a few minutes to compute, but I had over 57,000 rows and 8 columns, so that's understandable.

Virtualization with Virtual Box in Ubuntu

I copied some material from these links in doing this (there are one or two errors in them that I correct here):
http://www.ubuntu-unleashed.com/2008/04/howto-install-virtualbox-in-hardy-heron.html
http://www.linuxhaxor.net/2008/05/05/creating-seamless-virtual-machine-with-virtualbox-16/
  1. make sure you have the 'build-essential' package installed:
    sudo apt-get install build-essential
  2. Download your version of virtual box (probably i386 unless you have a 64 bit processor) and install it

    After download, right click the package and install with the GDeb package manager

  3. Add your user to the vboxusers group:
    sudo adduser $USER vboxusers

  4. Follow the Setup VirtualBox USB Support section here for USB support
    I did both of the things recommended. Note that the last step should read:
    sudo /etc/init.d/mountkernfs.sh start

  5. Install Guest Addons and turn on seamless mode
    after firing up the virtual OS, go to the 'Devices' window on the top and 'Install Guest Additions'
  6. Set up shared directories following this.

Wednesday, January 7, 2009

autotest with specs in a normal ruby library

Put this in a '.autotest' file in your project's base directory:

# -*- ruby -*-

# in .autotest file:

Autotest.add_hook :initialize do |at|
at.clear_mappings
end

Autotest.add_hook :initialize do |at|
at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
["spec/#{m[1]}_spec.rb"]
## for both specs and tests:
#["spec/#{m[1]}_spec.rb","test/#{m[1]}_test.rb"]
}
end

Friday, December 26, 2008

Smaller playlist.com music player for blog


Playlist.com is a popular source for getting free music on your blog. My problem was I didn't want it to be at the bottom of the blog, but on the sidebar. The code they give you makes a music player that is much too wide for a sidebar. Here is how you can edit the code to fit whatever width you want.

Your code should resemble the code below. Simply change the bold numbers from your code to smaller, or larger numbers, depending on the size you want (I only included the beginning of the code, where you need to make changes). For my sidebar I used 285 to replace 450 and then 275 to replace all the 435's.

div style="text-align: center; margin-left: auto; visibility:visible; margin-right: auto; width:450px;"embed style="width: 435px; visibility: visible; height: 270px;" allowscriptaccess="never" src="http://www.greatprofilemusic.com/mc/mp3player-othersite.swf?config=http://www.greatprofilemusic.com/mc/config/config_black.xml&mywidth=435&myheight=270&playlist_url=http://www.greatprofilemusic.com/loadplaylist.php?playlist=55939558" menu="false" quality="high" name="mp3player" width="435" height="270">

Sunday, November 30, 2008

Set Timex 1440 Sports watch

Couldn't find this anywhere on the web (the instruction manual for this watch does not match the watch). After many, many attempts I finally figured it out:

Press and hold the mode button for a few seconds, then, press the mode button again!

The 'set' button then changes the value while the 'start/stop' button will advance to the next thing to set.

Set the Timex 1440 Sports Watch (wr50m) Magnetism watch

hold down the "mode" button for 2 seconds. When the digits on the watch face start to blink, then press the "mode" button again. To change the hours, press the "adjust button". [instructions thanks to a comment below]

To turn the alarm off:

Press and hold "set."
At the same time press (and hold?) "start/stop."
You will see the alarm bell icon go away.

Also, see wiki.answers post for more details.

Thursday, October 23, 2008

Clean surfing on YouTube


YouTube is a great service. Unfortunately, it seems like dodgy promo videos (at least dodgy thumbnail images) are the norm for the site. Here's how to disable them (I'm assuming you are using Firefox):

  1. install the addon GreaseMonkey
  2. install the YouTube customization script
  3. on a video page, customize:


Now, all videos will have blocked Promotional Videos! Hooray! (Note: you can click on the little monkey in the bottom right hand of your browser to disable GreaseMonkey at any time)

Thursday, July 31, 2008

Installing emerald with Ubuntu 8.04

http://hacktivision.com/index.php/2008/06/07/how-to-enhance-ubuntu-8-04-hardy-heron-e?blog=2

Saturday, May 17, 2008

Export plots in R

In R exporting plots is easy:

jpeg("/home/Desktop/nameplot_here.jpg") #name the file and where to export it

hist(data) #this makes a histogram of your data

dev.off() #actually do the exporting

To do png or pdf just substitute it for jpeg.