Skip to content

Instantly share code, notes, and snippets.

View delagoya's full-sized avatar

Angel Pizarro delagoya

View GitHub Profile
@delagoya
delagoya / example.out.txt
Created January 18, 2012 20:29
Emailing reports about bad drive from Promise Pegasus
$ promiseutil -C phydrv
===============================================================================
PdId Model Type Capacity Location OpStatus ConfigStatus
===============================================================================
1 Hitachi HDS7 SATA HDD 2TB Encl1 Slot1 OK Array0 Seq. No.0
2 Hitachi HDS7 SATA HDD 2TB Encl1 Slot2 OK Array0 Seq. No.1
3 Hitachi HDS7 SATA HDD 2TB Encl1 Slot3 OK Array0 Seq. No.2
4 Hitachi HDS7 SATA HDD 2TB Encl1 Slot4 OK Array0 Seq. No.3
5 Hitachi HDS7 SATA HDD 2TB Encl1 Slot5 OK Array0 Seq. No.4
6 Hitachi HDS7 SATA HDD 2TB Encl1 Slot6 OK Array0 Seq. No.5
@delagoya
delagoya / my_fasta.rb
Created October 14, 2011 14:09
Example for each() Enumerable
class MyFasta
include Enumerable
attr :fh
def initialize(f)
@fh = File.open(f)
end
def self.open(f)
MyFasta.new(f)
@delagoya
delagoya / example.fabric.html
Created September 23, 2011 01:52
Example of problem with fabric.js
<html>
<head>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/fabric.js" type="text/javascript"></script>
</head>
<body>
<canvas id="canvas" width="300" height="300" style="border: 1px solid #222" ></canvas>
<script type='text/javascript'>
var cnv;
cnv = fabric.Canvas("canvas");
Ruby 1.9.2
Ruby Koans for exercises http://github.com/edgecase/ruby_koans
Ruby for Developers
Text Editors only
Ruby 1.9.2 only
h1. Basics
1 + 2
@delagoya
delagoya / two_bit_format_parsing_example.rb
Created October 12, 2010 20:11
Example of parsing 2bit formatted genome files with Ruby BinData gem
require 'rubygems'
require "bindata"
# A .2bit file stores multiple DNA sequences (up to 4 Gb total) in a compact
# randomly-accessible format. The file contains masking information as well as
# the DNA itself.
#
# The file begins with a 16-byte header containing the following fields:
#
# signature - the number 0x1A412743 in the architecture of the machine that
require 'rubygems'
require 'sequel'
require 'sequel/extensions/pagination'
DB.create_table :projects do
primary_key :id
String :name
String :description, :text => true
DateTime :created_at
DateTime :updated_at
require 'rubygems'
require 'curb'
url = 'http://localhost:3000/workflows/new'
c = Curl::Easy.new(url)
c.multipart_form_post = true
post_data = []
post_data << Curl::PostField.file('FILE', 'test.txt')
# was this
require 'open-uri'
require 'hpricot'
result = Hpricot.parse(open(ARGV[0]))
STDERR.puts "ERROR: #{ARGV[0]}" unless result.root.name == "html"
class Blat < CloudCrowd::Action
# Run BLAT on the input against a database with some options.
def process
#download the query DB to local disk
query_db = download(options[:db],File.basename(options[:db]))
#run blat search
`blat #{query_db} #{input_path} #{file_name}.result #{option[:args]}`
# gzip the file
`gzip #{file_name}.result`
#save the file to S3 and return the S3 URL as the result a
# assume you have a file with lots if dates
d <- read.delim('datafile.txt')
# plot the values on Y dates on X
plot(d$webhits, type='l', xaxt='n', xlab='', ylab='', xlim=c(1,length(d$date)))
# draw the x axis
date.labels <- d$date[pretty(1:length(d$date),10) + 1 ]
axis(1,at=pretty(1:length(d$date),10),labels=date.labels)