Skip to content

Instantly share code, notes, and snippets.

View danielevans's full-sized avatar

Daniel Evans danielevans

  • Anfract
  • Portland, OR
View GitHub Profile
@danielevans
danielevans / LPSN_parcer.rb
Last active January 1, 2016 22:11 — forked from jrslagle/LPSN_parcer.rb
a script to parse bacterial phylogeny from http://www.bacterio.net/-classifphyla.html and print it into a table format.
# original text is from http://www.bacterio.net/-classifphyla.html
# load hard-coded filename LPSN.txt into a string
# create a File object from LPSN.txt
line_array = File.readlines("LPSN.txt") or die "LPSN.txt not found."
# todo: parse lines your own way if it helps separate genuses.
# todo: grab this data directly from the website
# use the included date to report how old the current genus table is
# phylum = "no phylum"
@danielevans
danielevans / test_consumer.rb
Created December 28, 2015 17:35
MQTT Speed Test Consumer/Producer
require 'benchmark'
require 'rubygems'
require 'bundler/setup'
require 'mqtt'
MQTT::Client.connect('localhost') do |c|
message_count = -1 # ignore the first message because reasons.
start_time = nil
end_time = nil
@danielevans
danielevans / Suggested-Gems.markdown
Last active October 22, 2015 05:39
Suggested Gems
desc 'download all s3 files for a given bucket'
task :download_s3 do
s3 = AWS::S3::Client.new
bucket_name = ENV['AWS_S3_BUCKET']
FileUtils.mkdir_p('tmp/s3_dump')
next_marker = ''
begin
resp = s3.list_objects bucket_name: bucket_name, marker: next_marker
resp.contents.each do |f|
dest = Rails.root.join("tmp/s3_dump", f.key)
if @valid_networks == nil || @valid_networks == false
@valid_networks = []
end
@valid_networks = @valid_networks || []
@valid_networks ||= []
"Structure and Interpretation of Computer Programs" <- MITs CS text book for years. You will build a complete Scheme implementation by the end of the book.
"Confident Ruby" <- great book that has had a very positive effect on the way I use Ruby
"Practical Object-Oriented Design in Ruby" <- On my reading list, having a huge impact in the ruby community
"Smart and Gets Things Done" <- great book that has greatly affected how we hire
"The Pragmatic Programmer" <- Classic CS/SE text, heavily influential
"Cold as Ice" (and its series) <- Great hard science fiction novel (I have spare copies)
"Ender's Game" <- I despise the author from the bottom of my soul, but his books are good.
"The Mythical Man Month" <- Classic project management text, heavily influential
"Surely You are Joking Mr. Feynman" <- Richard Feynman's autobiography. Hilarious.
"1984" <- because 2016 will be like 1984.
@danielevans
danielevans / gist:99b40f30491d6412b4de
Created July 1, 2015 21:54
Delete ActiveJob jobs from resque failure which are not of a specific job class
failures = Resque::Failure.count
failures.times do |i|
print "#{i}."
failure_id = failures - 1 - i
begin
Resque::Failure.remove(failure_id) if Resque::Failure.all(failure_id)["payload"]["args"].first["job_class"] == "SyncOrders"
rescue JSON::ParserError
Resque::Failure.remove(failure_id)
end
end
class SimpleUploaded < ActiveRecord::Base
mount_uploader :uploaded_file, SomeUploader
end
@danielevans
danielevans / gist:1e723462525816736079
Created December 21, 2014 20:16
Molecular Transformer Configuration
##################################################################################################
# AdvancedSolarPanels Molecular Transformer Recipes #
##################################################################################################
# Format of recipe: "inputItem:stackSize;outputItem:outputStackSize;energy" #
# InputItem (outputItem) format: #
# "oredict:forgeOreDictName" or "minecraft:item_name-meta" or "modID:item_name-meta" #
# New line = new recipe. #
# Add "#" before line to skip parsing recipe #
##################################################################################################
version=1.0
@danielevans
danielevans / gist:157a6c4b6efdb2c25cd0
Last active August 29, 2015 14:01
Accessor Vs. Method Speed
class Foo
attr_accessor :accessord
def defd
@defd
end
end
foo = Foo.new
t = 10_000_000
result = Benchmark.bm do |b|