Skip to content

Instantly share code, notes, and snippets.

@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/*",

Rough cert-manager GKE install instructions:

export PROJECT_ID="cert-manager-$(openssl rand -hex 6)"
export EMAIL=abe@abevoelker.com

gcloud projects create --set-as-default $PROJECT_ID
gcloud compute addresses create ipv4-address --global --ip-version IPV4
gcloud services enable compute.googleapis.com
gcloud services enable container.googleapis.com
@abevoelker
abevoelker / one_signal.rb
Last active August 7, 2018 18:36
OneSignal Ruby notifications
require "typhoeus"
class OneSignal
class << self
[:app_id, :api_key, :timeout, :connecttimeout].each do |opt|
define_method(:"#{opt}=") {|val| instance_variable_set(:"@#{opt}", val)}
define_method(opt) { begin; instance_variable_get(:"@#{opt}"); rescue NameError; nil; end }
end
end
  • Constraints - super important for ensuring data integrity (bad data can't get into the DB)

  • Indexes - i

@abevoelker
abevoelker / PS3.plist
Created May 27, 2012 14:37
HandBrake Xbox 360 / PS3 preset from version 0.93
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>AudioList</key>
<array>
<dict>
<key>AudioBitrate</key>
<string>160</string>
import java.security._
import java.net.URL
import javax.net.ssl.{KeyManagerFactory, TrustManagerFactory}
import org.apache.http.conn.ssl.SSLSocketFactory
import org.apache.http.conn.scheme.Scheme
import dispatch._
// Gist trait for doing SSL with mutual certificate exchange using dispatch.
// This works without having to set up global JDK-wide keystore and truststore files.
//
@abevoelker
abevoelker / TypeFamily.hs
Created January 8, 2016 15:30 — forked from deech/TypeFamily.hs
Searching a type level list using typeclasses vs. closed type families.
{-
This code shows how to check if a type-level list contains a given type.
It first shows the approach required for older versions of GHC (< 7.6.x)
and then a version using closed type families supported in GHC 7.8.1 and greater.
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
@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.