Skip to content

Instantly share code, notes, and snippets.

View neilfws's full-sized avatar

Neil Saunders neilfws

View GitHub Profile
@neilfws
neilfws / gxa-jsonp.haml
Created January 19, 2011 06:38
Corrected version of sample code from http://www.ebi.ac.uk/gxa/help/AtlasApis, using Haml
:javascript
function processData(data) {
if(data.error) {
alert(data.error);
return;
}
alert('Accession: ' + data.results[0].experimentInfo.accession + '\nDescription: ' +
data.results[0].experimentInfo.description);
}
@neilfws
neilfws / gantt.R
Created April 13, 2010 13:59
Gantt chart (per day) using ggplot2
library(ggplot2)
# read data file tasks.csv - it looks like this:
# task,date,start,end
# task1,2010-03-05,09:00:00,13:00:00
# task2,2010-03-06,10:00:00,15:00:00
# task3,2010-03-06,11:00:00,18:00:00
# task4,2010-03-07,08:00:00,11:00:00
# task5,2010-03-08,14:00:00,17:00:00
# task6,2010-03-09,12:00:00,16:00:00
#!/usr/bin/ruby
def collatz(n)
raise "#{n} does not compute" if n < 1
return n if n == 1
if n.odd?
n = 3 * n + 1
elsif n.even?
n = n/2
end
@neilfws
neilfws / boson-pubmed.txt
Created February 22, 2010 22:59
boson/pubmed issue
sau103@gymea-nh:~$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
sau103@gymea-nh:~$ boson -hv
boson [GLOBAL OPTIONS] [COMMAND] [ARGS] [COMMAND OPTIONS]
GLOBAL OPTIONS
+-------------------+-------+---------+-------------------------------------------------------------------+------------------+
| Name | Alias | Type | Desc | Values |
+-------------------+-------+---------+-------------------------------------------------------------------+------------------+
@neilfws
neilfws / Delayed::Job daemon script for delayed_job
Created January 31, 2010 14:52 — forked from lukeredpath/Delayed::Job daemon script for delayed_job
Daemon script with minor alteration to use Navvy instead of delayed_job
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
daemon_options = {
:multiple => false,
:dir_mode => :normal,
:dir => File.join(dir, 'tmp', 'pids'),
:backtrace => true
#! /bin/sh
### BEGIN INIT INFO
# Provides: mongodb
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the mongodb data-store
# Description: starts mongodb using start-stop-daemon
# install GEOmetadb
source("http://bioconductor.org/biocLite.R")
biocLite("GEOmetadb")
library(GEOmetadb)
# connect to database
getSQLiteFile()
con <- dbConnect(SQLite(), "GEOmetadb.sqlite")
# count samples per GDS
@neilfws
neilfws / friendfeed2mongodb.rb
Created January 6, 2010 11:59
Archive a FriendFeed feed in MongoDB
namespace :db do
require "mongo"
require "json/pure"
require "open-uri"
feed = ENV['feed']
db = Mongo::Connection.new.db('friendfeed')
col = db.collection('entries')
desc "Seed database with feed entries"
@neilfws
neilfws / gdsinfo.rb
Created September 1, 2009 03:16
Fetch field names and descriptions from NCBI GEO database
#!/usr/bin/ruby
require 'rubygems'
require 'hpricot'
require 'open-uri'
doc = Hpricot(open("http://eutils.ncbi.nlm.nih.gov/entrez/eutils/einfo.fcgi?db=gds"))
(doc/'//fieldlist/field').each do |f|
puts "#{(f/'/name').inner_html},#{(f/'/fullname').inner_html},#{(f/'description').inner_html}"
@neilfws
neilfws / mongodb.rake
Created August 14, 2009 03:15
Start/stop mongod for a Rails app.
# mongodb.rake for Rails
# assumes that mongodb installed in Rails.root/lib/mongodb
namespace :db do
namespace :mongo do
# start db server
task :start do
pr = get_pids
if pr.length == 0