Skip to content

Instantly share code, notes, and snippets.

@abevoelker
abevoelker / README.md
Last active August 29, 2015 14:08
The docker-gc shell function I use to keep Docker from filling up my hard disk
@abevoelker
abevoelker / foo_spider.py
Last active August 29, 2015 13:59
scrapy Sidekiq pipeline (resque support shouldn't be too hard)
# project_name/spiders/foo_spider.py
from scrapy.contrib.spiders import CrawlSpider
class FooSpider(CrawlSpider):
post_process = dict(
klass = "Foo::Worker",
# queue = "default",
# retry = True,
)
@abevoelker
abevoelker / pipelines.py
Last active March 17, 2024 05:59
scrapy RabbitMQ pipeline
# project_name/pipelines.py
from scrapy import signals
from scrapy.utils.serialize import ScrapyJSONEncoder
from scrapy.xlib.pydispatch import dispatcher
from carrot.connection import BrokerConnection
from carrot.messaging import Publisher
from twisted.internet.threads import deferToThread
@abevoelker
abevoelker / policy.json
Created March 31, 2014 01:20
S3 bucket policy to whitelist access to CloudFlare (IPv6 addresses don't seem to be supported in bucket policies)
{
"Id": "Policy1234",
"Statement": [
{
"Sid": "Stmt1234",
"Action": [
"s3:GetObject"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::foo/*",
require 'nokogiri'
require 'open-uri'
r = open('http://en.wikipedia.org/wiki/List_of_The_Price_Is_Right_pricing_games').read
doc = Nokogiri::HTML(r)
name = doc.css('span.mw-headline').map(&:text).select{|name| name.size > 1}.sample
@abevoelker
abevoelker / after-locale-fix.txt
Created January 4, 2014 22:22
vagrant-lxc locale fix
$ sudo -E ./build-ubuntu-box.sh precise amd64
No config file specified, using the default config
debootstrap is /usr/sbin/debootstrap
Checking cache download in /var/cache/lxc/precise/rootfs-amd64 ...
Copy /var/cache/lxc/precise/rootfs-amd64 to /var/lib/lxc/precise-base/rootfs ...
Copying rootfs to /var/lib/lxc/precise-base/rootfs ...
##
# The default user is 'ubuntu' with password 'ubuntu'!
@abevoelker
abevoelker / README.md
Last active December 30, 2015 13:09 — forked from mbostock/.block
Prose (myforms) render times on 2013/12/06 (up until ~3:30pm)

Graph of prose (myforms) response times on 2013/12/06 gathered by the parsing the production.log file using this Ruby script.

D3 code was forked from this repo.

@abevoelker
abevoelker / rails_log_to_tsv.rb
Last active December 30, 2015 12:59
Hacky script to convert a Rails log file to timestamp-render time .tsv
IN = '/tmp/production.log'
OUT = '/tmp/render_time.tsv'
render_vals = File.read(IN).split("\n\n").map do |lines|
# render time
m = lines.match(/^Completed in (\d+)ms/)
next unless m
render_time = m.captures[0].to_i
# action and timestamp
m = lines.match(/^Processing (\S*) \(for \S* at ([^)]*)\)/)
# app/models/telecom/circuits.rb
module Telecom::Circuits
def self.table_name_prefix
'telecom_circuits_'
end
end
@abevoelker
abevoelker / NO to any intervention in Syria
Last active December 22, 2015 08:19
Open letter to my House Representative, Mark Pocan
Representative Pocan,
I'm writing to call on you to heed the words of our founding fathers, who warned us not to become entangled in foreign wars. I urge you to vote against any authorization for use of force in Syria.
Our history of choosing sides in revolutions has brought nothing but misery to all parties involved, particularly in the Middle East (except perhaps to Israel). One look no further than exactly one year ago when Libyans in Benghazi burned down our consulate and murdered multiple American citizens, including ambassador to Libya Chris Stevens. This was after we spent over $1 billion helping oust Moammar Gaddafi from power, when we thought that we had done right by the Libyan people.
Even if well-intentioned, Arab people are rightfully suspicious of American intervention into their affairs due to our nasty history in that region. Specifically in regards to Syria, this intervention began in 1949 when the CIA supported a coup that installed Husni al-Za'im as dictator (see BBC article "The Bab