Skip to content

Instantly share code, notes, and snippets.

A D A M D E R E W E C K I
1456 Jones St. Apt 32, San Francisco, CA 94109 740-502-3073
derewecki@gmail.com @derwiki
linkedin.com/in/derewecki derwiki.tumblr.com
news.ycombinator.com/user?id=derwiki github.com/derwiki
== P R O F E S S I O N A L E X P E R I E N C E ==
Causes, Hacker (3/2011 - Present)
* Web Development
mainframe:~/causes[master %]$ cat perf.rb
#!/usr/bin/ruby
PASSENGER_LOG_REGEX = /(\w+)\s(\d+)\s(\d+).*Completed in (\d+\.\d+).*Rendering: (\d+\.\d+)/
File.open('jan-17-action-render-samples.log').each do |line|
PASSENGER_LOG_REGEX =~ line
puts {
:month => $1,
:day => $2,
:hour => $3,
Delivered-To: derewecki@gmail.com
Received: by 10.231.28.36 with SMTP id k36cs65105ibc;
Mon, 6 Feb 2012 11:13:02 -0800 (PST)
Received: by 10.236.191.35 with SMTP id f23mr26582784yhn.29.1328555582482;
Mon, 06 Feb 2012 11:13:02 -0800 (PST)
Return-Path: <bounces-708-1846396@causesmail.com>
Received: from outbound37.causesmail.com (outbound37.causesmail.com. [74.116.69.237])
by mx.google.com with ESMTP id v42si17300696yhl.53.2012.02.06.11.13.02;
Mon, 06 Feb 2012 11:13:02 -0800 (PST)
=> {:suppress_urgent_oops_exceptions=>["FacebookUser::MogliExtension::MogliRuntimeException"], :rate_monitored_exceptions=>{:simple_opengraph_request=>{:interval=>600, :threshold=>100}}}
>> newconfig = config
=> {:suppress_urgent_oops_exceptions=>["FacebookUser::MogliExtension::MogliRuntimeException"], :rate_monitored_exceptions=>{:simple_opengraph_request=>{:interval=>600, :threshold=>100}}}
>> newconfig = config[:suppress_urgent_oops_exceptions]
=> ["FacebookUser::MogliExtension::MogliRuntimeException"]
>> newconfig = config[:rate_monitored_exceptions]
=> {:simple_opengraph_request=>{:interval=>600, :threshold=>100}}
>>
@derwiki
derwiki / load.sh
Created June 4, 2012 22:31
Bulk loading 500m rows into MySQL
for month_table in action*.txt; do
echo "$(date) splitting $month_table..."
split -l 1000000 $month_table curmonth_
for segment in curmonth_*; do
echo "On segment $segment"
time mysql -hlocalhost action_credit_silo <<-SQL
SET FOREIGN_KEY_CHECKS = 0;
SET UNIQUE_CHECKS = 0;
SET SESSION tx_iso
I didn't read your email closely the first time around -- I actually blazed through most of it, only really picking up on your asking for a code sample (which I was fine sending as I already had something handy). I don't know who Jimmy Kittyachavatil is nor do I particularly care. The truth is, you received my resume via some automation software I wrote; if I'd seen your ad myself, I would have ignored it. I've earned a computer science degree from a tier 1 school and you think you're justified in asking me to waste my time, proving I can solve problems (I guess that's what you think you're doing) by asking me to solve some trivial little toy problem so I can be granted an audience with your VP of Engineering? Thanks. But I'd just as soon pass.
#!/usr/bin/env ruby
def file_variable(filename)
File.readlines(filename, 'r').first.to_i
end
TARGET_TABLE = 'action_credits'
SCHEMA = <<-SQL
CREATE TABLE IF NOT EXISTS `action_credits` (
.. omitted for brevity ..
class Item < ActiveRecord::Base
attr_accessible :description, :owner_id, :title, :image_url, :weekly, :daily,
:amazon_url, :image, :brand, :component
belongs_to :owner, class_name: 'User'
COMPONENTS = [:lens, :body, :accessory].each do |component|
scope component.to_sym, where(component: component)
end
BRANDS = [:canon, :nikon, :sony, :olympus, :other].each do |brand|
scope brand.to_sym, where(brand: brand)
@derwiki
derwiki / generate-swarm.sh
Created February 15, 2013 23:11
Series of commands (not an executable script per se) to get you from a git repository to a Code Swarm AVI (tested on Linux and OS X).
CODESWARM_DIR="/home/user/src/code_swarm/"
# extract from your git repo
git log --name-status --pretty=format:'%n------------------------------------------------------------------------%nr%h | %ae | %ai (%aD) | x lines%nChanged paths:' > $CODESWARM_DIR/data/activity.log
# convert to XML for CodeSwarm
python convert_logs/convert_logs.py \
-g $CODESWARM_DIR/data/activity.log -o $CODESWARM_DIR/data/activity.xml
# create a new config that points to the correct input XML and saves snapshots