Skip to content

Instantly share code, notes, and snippets.

View jsdalton's full-sized avatar

Jim Dalton jsdalton

  • Contentful
  • Berlin, Germany
View GitHub Profile
@jsdalton
jsdalton / test_server.py
Created December 15, 2010 16:14
Simple http web test service
# python test_server.py
# e.g GET http://127.0.0.1:5000/404 returns a 404 http response
# e.g. GET http://127.0.0.1:5000/200?sleep=10 returns a 200 after 10 seconds
import time
from flask import Flask, make_response, request
app = Flask(__name__)
@app.route('/<int:status_code>')
def return_status(status_code):
response = make_response()
@jsdalton
jsdalton / gist:1045271
Created June 24, 2011 17:40
Find rows with bad referential integrity, demonstration
-- Create tables
CREATE TABLE `fixtures_regress_book` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`author_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `fixtures_regress_book_cc846901` (`author_id`),
CONSTRAINT `author_id_refs_id_7fdd0933` FOREIGN KEY (`author_id`) REFERENCES `fixtures_regress_person` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
// Variables.less
// Variables to customize the look and feel of Bootstrap
// -----------------------------------------------------
// GLOBAL VALUES
// --------------------------------------------------
// Links
/* site */
.padded-image {
padding: 4px;
background-color: @white;
border: 1px solid @grayLight;
}
body {
@jsdalton
jsdalton / gist:8339333
Created January 9, 2014 18:29
Email blast permission footer (plain text)
------------------------------------------------------------
You have received this email because you subscribed to an email newsletter publication at *|LIST:NAME|* (*|LIST:URL|*). You are subscribed to *|LIST:NAME|* with the email address: *|EMAIL|*
Click here to unsubscribe (*|UNSUB|*) from all *|LIST:NAME|* email newsletters and partner emails.
Please email *|ABUSE_EMAIL|* if you require any assistance with unsubscribing or managing your email subscriptions at *|LIST:NAME|*.
------------------------------------------------------------
ERE Media, Inc. | 217 Thompson Street, Suite 202 | New York, NY 10012 | (212) 671-1181 | www.ere.net
@jsdalton
jsdalton / gist:8339373
Created January 9, 2014 18:32
Email blast permission footer (HTML)
<table cellpadding="0" cellspacing="0" style="background-color: #fff; margin-top: 15px; padding: 15px 0; border-top: 1px solid #666" width="100%">
<tr>
<td align="center" width="100%">
<table cellpadding="0" cellspacing="0" style="" width="600">
<tr>
<td valign="top" align="center">
<p style="font: 13px Arial, sans-serif; color: #333; line-spacing: 1.3; margin: 15px 0;">
You have received this email because you subscribed to an email newsletter publication at *|LIST:NAME|* (<a href="*|LIST:URL|*">*|LIST:URL|*</a>).
You are subscribed to *|LIST:NAME|* with the email address: *|EMAIL|*
@jsdalton
jsdalton / toyaml.py
Last active August 29, 2015 13:56
Convert tabular data to YAMLular data.
#!/usr/bin/env python
import sys
import argparse
parser = argparse.ArgumentParser(description='Convert tabular data to YAMLular data.')
parser.add_argument("-d", "--delimiter", help="delimiter to use (defaults to \\t)", default="\t")
args = parser.parse_args()
header = sys.stdin.readline().strip().split(args.delimiter)
@jsdalton
jsdalton / keybase.md
Created February 4, 2016 22:49
Keybase proof

Keybase proof

I hereby claim:

  • I am jsdalton on github.
  • I am jsdalton (https://keybase.io/jsdalton) on keybase.
  • I have a public key ASBnBYcGyQK7cpcSSkv9FPk6EcppSgRTcA9_zm7eE82D0wo

To claim this, I am signing this object:

def unfold(start, &block)
Enumerator.new do |y|
next_item = start
loop do
y << next_item
next_item = block.call(next_item)
end
end
end