Skip to content

Instantly share code, notes, and snippets.

Avatar

Neil Saunders neilfws

View GitHub Profile
@neilfws
neilfws / bioruby-pubmed-demo
Created Aug 10, 2009
Search PubMed using esearch, return results as BibTeX
View bioruby-pubmed-demo
#!/usr/bin/ruby
# save as pubmed.rb and test using 'ruby pubmed.rb 19662644'
# keyword search may return > 1 record due to retmax bug
# http://github.com/bioruby/bioruby/commit/51c3223e033b2992a7bd95da282f88164406ff92
require 'rubygems'
require 'bio'
keywords = ARGV.join(' ')
View gist:165724
require 'open-uri'
require 'json'
require 'mongo'
class FriendFeed
attr_accessor :user, :database, :collection
def initialize(user, database, collection)
@user = user
@database = XGen::Mongo::Driver::Mongo.new.db(database)
@neilfws
neilfws / mongodb.rake
Created Aug 14, 2009
Start/stop mongod for a Rails app.
View mongodb.rake
# 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
@neilfws
neilfws / gdsinfo.rb
Created Sep 1, 2009
Fetch field names and descriptions from NCBI GEO database
View gdsinfo.rb
#!/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 / friendfeed2mongodb.rb
Created Jan 6, 2010
Archive a FriendFeed feed in MongoDB
View friendfeed2mongodb.rb
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"
View GEOmetadb.R
# 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
View init.d for MongoDB
#! /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
@neilfws
neilfws / Delayed::Job daemon script for delayed_job
Created Jan 31, 2010 — forked from lukeredpath/Delayed::Job daemon script for delayed_job
Daemon script with minor alteration to use Navvy instead of delayed_job
View Delayed::Job daemon script for 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
@neilfws
neilfws / boson-pubmed.txt
Created Feb 22, 2010
boson/pubmed issue
View boson-pubmed.txt
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 |
+-------------------+-------+---------+-------------------------------------------------------------------+------------------+
View collatz.rb
#!/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