Skip to content

Instantly share code, notes, and snippets.

View pcomans's full-sized avatar
🙈

Philipp Comans pcomans

🙈
  • Software Engineer at @1debit
  • Sacramento
View GitHub Profile
f = File.open("A-large-practice.in")
num_testcases = f.readline.strip.to_i
casenumber = 1
num_testcases.times do
credit = f.readline.strip.to_i
num_items = f.readline.strip.to_i
prices = f.readline.split(' ').collect {|x| x.to_i}
@pcomans
pcomans / gist:903852
Created April 5, 2011 15:40
Problem B. Reverse Words
f = File.open("B-large-practice.in")
num_testcases = f.readline.to_i
(1..num_testcases).each do |casenumber|
words = f.readline.split(' ')
print "Case #" + casenumber.to_s + ": "
words.reverse.each { |word| print word + " "}
print "\n"
@pcomans
pcomans / MergerTest.java
Created April 20, 2011 19:03
MergerTest
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.junit.Test;
class Merger {
require 'rubygems'
require 'bio'
seq = Bio::Sequence::NA.new("atgcagctctttgtccgcgcccaggagctacacaccttcgaggtgaccggccaggaaacggtcgcccagatcaaggctcatgtagcctcactggagggcattgccccggaagatcaagtcgtgctcctggcaggcgcgcccctggaggatgaggccactctgggccagtgcggggtggaggccctgactaccctggaagtagcaggccgcatgcttggaggtaaagtccatggttccctggcccgtgctggaaaagtgagaggtcagactcctaaggtggccaaacaggagaagaagaagaagaagacaggtcgggctaagcggcggatgcagtacaaccggcgctttgtcaacgttgtgcccacctttggcaagaagaagggccccaatgccaactcttaa")
remote = Bio::Blast.remote('blastn', 'genes-nt', '-e 0.01')
blobj = remote.query(seq)
blobj.each_hit do |hit|
puts "#{hit.target_def} #{hit.evalue}"
end
@pcomans
pcomans / gist:985332
Created May 22, 2011 10:22
Bio::FastaFormat bug
require 'rubygems'
require 'bio'
blaster = Bio::Blast.local("tblastx", "/Users/philipp/Dropbox/IDP/ESTs/Ephydatia_muelleri/Ephydatia_muelleri", "", "/Users/philipp/Downloads/blast-2.2.25/bin/blastall")
sequence = ">EM1c1_molpal [Ephydatia_muelleri]\nGTTTTGTACAAGAAGACCATTCATAAGAACAATATTGATGACCACACAGTACACTAGAAG"
fasta = Bio::FastaFormat.new(sequence)
result = fasta.query(blaster)
puts result.hits.length
fasta.entry()
result = fasta.query(blaster)
#!/usr/bin/bash
echo $*
RUBY_VERSION=/usr/bin/env ruby -v
echo $RUBY_VERSION
if [[ $RUBY_VERSION == "jruby*" ]];
then
echo "JRUBY\!"
else
if RUBY_PLATFORM =~ /java/
puts "JRUBY!"
command = "ruby -J-Xmx2g " + File.join(File.dirname(__FILE__), '..', 'lib/hello.rb')
system(command)
else
puts "MRI"
command = "ruby " + File.join(File.dirname(__FILE__), '..', 'lib/hello.rb')
system(command)
end
JRUBY!
warning: -J-Xmx2g argument ignored (launched in same VM?)
Hello
Still there?
#!/usr/bin/bash
params=$*
ruby_version=$(ruby -v)
echo $ruby_version
dir=$(dirname $0)
if [[ $ruby_version == jruby* ]];
then
ruby "-J-Xmx2g" "${dir}/lib/annotate-gff.rb" ${params}
else
#!/Users/philipp/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'annotate-gff' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'