Skip to content

Instantly share code, notes, and snippets.

View antunderwood's full-sized avatar

Anthony Underwood antunderwood

View GitHub Profile
module AdminFormHelper
##
# All helpers related to form.
#
def build_form(fields = @item_fields)
returning(String.new) do |html|
html << "#{error_messages_for :item, :header_tag => "h3"}"
html << "<ul>"
@antunderwood
antunderwood / starling
Created February 28, 2009 13:24 — forked from sikachu/starling
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: starling
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop starling server
### END INIT INFO
#
# starling This init.d script is used to start starling.
# It basically just calls starling.
# http://gist.github.com/10524
# Prevents autotest from running your entire test suite after fixing a failed test.
# Works with ZenTest 3.10.0
# Place this in your .autotest file:
require 'rubygems'
require 'active_support'
class Autotest
def run_with_not_rerunning_everything
hook :initialize
# RAILSLOVE.com template
#
# with help and ideas from:
# http://gist.github.com/33337 By Peter Cooper
# http://github.com/jeremymcanally/rails-templates/tree/master/suspenders.rb Suspenders by Thoughtbot Nathan Esquenazi
if yes?("symlink local rails copy to vendor?")
path = ask("what's the directory of your local rails copy?")
inside('vendor') { run "ln -s #{path} rails" }
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
include Clearance::Authentication
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details
# Scrub sensitive parameters from your log
filter_parameter_logging :password
class User < ActiveRecord::Base
include Roleify::RoleifyableModel
include Clearance::User
attr_accessible :username
validates_presence_of :username
validates_uniqueness_of :username
def self.authenticate(email, password)
@antunderwood
antunderwood / gist:209308
Created October 13, 2009 15:55
crowd server action
# Splits up alignemnt into block sized chunks and then render them as html
class RenderAlignment < CloudCrowd::Action
require 'rubygems'
require 'bio'
# Split up alignment
def split
fasta_sequences = Bio::FlatFile.open(input_path).to_a
alignment = Bio::Alignment.new(fasta_sequences)
block_size = options['block_size']
number_of_blocks = (alignment.alignment_length/block_size.to_f).ceil
# Author:: Anthony Underwood
# Date:: 2008-07-04
require 'rubygems'
require 'bio'
# Method to perform a remote blast
# input:: a sequence object , a string specifiying the program (blastn, blastp, blastx etc), a remote database (e.g nr-nt for non-redundant) and options (e.g -e 0.0001)
# output:: a Bio::Blast::Report object
def remote_blast(seq_obj, program, db = 'nr-nt', options = '', server = 'genomenet')
number_of_strains = 500
k = 900 # number of variant sites in the alignment, i.e all non-consrved columns
harmonic_number = (1...number_of_strains).inject{|sum, n| sum + 1.0/n} # note ... so that this will calculate harmonic of n-1
theta = k/harmonic_number
[passenger@s0 ~]$ rvm --trace install 1.9.2 -C --with-openssl-dir=$HOME/.rvm/usr
+ [[ -z '' ]]
+ export 'PS4=+${BASH_SOURCE} : ${LINENO} : ${FUNCNAME[0]:+${FUNCNAME[0]}() : }'
+ PS4='+${BASH_SOURCE} : ${LINENO} : ${FUNCNAME[0]:+${FUNCNAME[0]}() : }'
+/home/passenger/.rvm/scripts/cli : 568 : __rvm_parse_args() : [[ -z '' ]]
+/home/passenger/.rvm/scripts/cli : 568 : __rvm_parse_args() : [[ -n '' ]]
+/home/passenger/.rvm/scripts/cli : 570 : __rvm_parse_args() : [[ 0 -eq 1 ]]
+/home/passenger/.rvm/scripts/cli : 570 : __rvm_parse_args() : [[ -n '' ]]
+/home/passenger/.rvm/scripts/cli : 14 : __rvm_parse_args() : [[ -n install ]]
+/home/passenger/.rvm/scripts/cli : 15 : __rvm_parse_args() : rvm_token=install