Skip to content

Instantly share code, notes, and snippets.

@brenttheisen
brenttheisen / google_takeout_hangout_convo_to_csv.rb
Created June 20, 2016 05:26
Script for printing a CSV of a conversation in a Hangout JSON file from Google Takeout.
#!/usr/bin/env ruby
#
# Script for printing a CSV of a conversation in a Hangout JSON file from Google Takeout.
#
# Brent Theisen
#
require 'json'
require 'csv'
@brenttheisen
brenttheisen / create_csr.sh
Last active August 29, 2015 13:58
Script to generate a host key and CSR file when keying a SSL certificate.
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: `basename $0` domain"
exit 85
fi
DOMAIN=$1
HOST_KEY="$DOMAIN".key
CSR="$DOMAIN".csr
@brenttheisen
brenttheisen / lastline.sh
Created December 27, 2013 22:16
Outputs the contents of the file specified to stdout beginning at the line after the last line it saw.
#!/usr/bin/env bash
if [ "$#" -ne 3 ]; then
echo "Usage: `basename $0` file filtercmd outputcmd"
exit 85
fi
FILE=$1
FILTERCMD=$2
OUTPUTCMD=$3
@brenttheisen
brenttheisen / rack.rb
Created September 23, 2011 06:07 — forked from mironov/rack.rb
Fix for Rack requests showing up on ports 81 and 444 for apps hosted on a EngineYard AppCloud cluster
module Rack
class Request
def scheme
if @env['HTTPS'] == 'on'
'https'
elsif @env['HTTP_X_FORWARDED_SSL'] == 'on'
'https'
elsif @env['HTTP_X_FORWARDED_PROTO']
@env['HTTP_X_FORWARDED_PROTO'].split(',')[0]
else
@brenttheisen
brenttheisen / factory_girl.rake
Created June 24, 2011 20:17
Rake task that loads factories using factory_girl in to the current environment's database. Intended to be a replacement for Rail's rake db:fixtures:load.
#
# To install copy this file in to <RAILS_APP>/lib/tasks/factory_girl.rake.
# To use run: rake db:factory_girl_load
#
namespace :db do
namespace :factory_girl do
desc 'Load Factory Girl factories into the current environment\'s database.'
task :load => :environment do
FactoryGirl.registry.each do |(name, factory)|
FactoryGirl.build name
@brenttheisen
brenttheisen / spamhaus_check.sh
Created May 23, 2011 16:02
Bash script that I run in cron that emails me every time my Slicehost VMs get added back in to the Spamhaus PBL.
#!/bin/bash
usage()
{
cat << EOF
usage: $0 <ip> [blocklist]
ip The IP to check.
blocklist The Spamhaus block list to check. Defaults to zen but can be one of these: zen, sbl, xbl, pbl or dbl.
EOF
@brenttheisen
brenttheisen / subdomain.js
Created May 16, 2011 15:26 — forked from benvinegar/subdomain.js
Subdomain tunneling with jQuery and document.domain
/**
* Replace $.ajax on your subdomain with a copy taken
* from your base domain. All jQuery AJAX actions go
* through $.ajax (i.e. $.get, $.post), so it's all good.
*/
(function() {
var iframe,
onload,
queue = [],