Skip to content

Instantly share code, notes, and snippets.

View ramsey's full-sized avatar

Ben Ramsey ramsey

View GitHub Profile

Keybase proof

I hereby claim:

  • I am ramsey on github.
  • I am ramsey (https://keybase.io/ramsey) on keybase.
  • I have a public key whose fingerprint is E85D 0311 DDFA 5BAC F3A6 10E7 B02D 9798 9C8C 071B

To claim this, I am signing this object:

@ramsey
ramsey / test_rollback_proc.sql
Created October 28, 2014 20:43
Example of declaring a continue handler in MySQL and rolling back or committing, based on status of _rollback
DROP PROCEDURE IF EXISTS test_rollback_proc;
DELIMITER //
CREATE PROCEDURE test_rollback_proc()
BEGIN
DECLARE `_rollback` BOOL DEFAULT 0;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET `_rollback` = 1;
/* Solarized Dark
For use with Jekyll and Pygments
http://ethanschoonover.com/solarized
SOLARIZED HEX ROLE
--------- -------- ------------------------------------------
base03 #002b36 background
base01 #586e75 comments / secondary content
@ramsey
ramsey / README.md
Last active August 29, 2015 14:18 — forked from vanto/README.md

OEmbed Liquid Tag for Jekyll

This is a simple liquid tag that helps to easily embed images, videos or slides from OEmbed enabled providers. It uses Magnus Holm's great oembed gem which connects to the OEmbed endpoint of the link's provider and retrieves the HTML code to embed the content properly (i.e. an in-place YouTube player, Image tag for Flickr, in-place slideshare viewer etc.). By default it supports the following OEmbed providers (but can fallback to Embed.ly or OoEmbed for other providers):

  • Youtube
  • Flickr
  • Viddler
  • Qik
  • Revision3
  • Hulu
  • Vimeo
@ramsey
ramsey / trapmail.sh
Created June 23, 2009 19:47
Script to redirect mail in a staging environment
#!/bin/sh
################################################################################
# Script to redirect mail in a staging environment
#
# Set this script to executable (chmod 755), and modify php.ini in the staging
# environment to use this script instead of sendmail:
#
# sendmail_path = /path/to/trapmail.sh
#
################################################################################
@ramsey
ramsey / consistent-hashing.php
Created June 9, 2010 19:17
A consistent hashing algorithm implemented in PHP
<?php
$cont = 0;
foreach ($servers AS $ip)
{
for ($k = 0; $k < 40; $k++) {
$ss = "$ip-$k";
$digest = md5($ss, true);
for ($h = 0; $h < 4; $h++) {
$continuum[$cont]['point'] =
(ord($digest[3+$h*4]) << 24 )
@ramsey
ramsey / generate-opml.php
Created November 16, 2011 20:00
Generate OPML file from Delicious blogroll tag
#!/usr/local/bin/php
<?php
include_once('getRSSLocation.php');
// del.icio.us username and password
$username = 'your_username';
$password = 'your_password';
$cache_file = '/tmp/delicious-blogroll.xml';
$blogs = array();
@ramsey
ramsey / xmlentities.php
Created November 16, 2011 20:04
xmlentities() implemented in PHP (provides functionality similar to htmlentities())
<?php
function xmlentities($s)
{
static $patterns = null;
static $replacements = null;
static $translation = null;
if ($translation === null) {
$translation = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
@ramsey
ramsey / zanshin.zsh-theme
Created February 4, 2012 06:15 — forked from zanshin/zanshin.zsh-theme
My oh-my-zsh theme, a derivative of the Soliah theme
# Shows little symbol '±' if you're currently at a git repo and '○' all other times
function prompt_char {
git branch >/dev/null 2>/dev/null && echo '±' && return
echo '$'
}
PROMPT='
%{$fg[blue]%}%n%{$reset_color%} on %{$fg[yellow]%}%m%{$reset_color%} in %{$fg[green]%}%~%b%{$reset_color%} $(git_time_since_commit)$(check_git_prompt_info)
${vcs_info_msg_0_}$(prompt_char) '
@ramsey
ramsey / csvtosqlite.py
Created September 12, 2012 17:40 — forked from bycoffe/csvtosqlite.py
Creates a sqlite database and table from a CSV file for easier querying
"""
Copyright (c) 2009, Aaron Bycoffe
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright