Skip to content

Instantly share code, notes, and snippets.

Sam Stokes samstokes

Block or report user

Report or block samstokes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
samstokes /
Created May 6, 2016
Turning on SQL logging in SQLAlchemy
import logging

Keybase proof

I hereby claim:

  • I am samstokes on github.
  • I am samstokes ( on keybase.
  • I have a public key ASBjVCcl1P5w4m-tmbthV5BAb3AOcY4g2Uxu3v7G6e8kXAo

To claim this, I am signing this object:

samstokes / todo
Last active Nov 2, 2018
A todo management system in a gist
View todo
#!/bin/bash -e
if [[ $# > 0 ]]; then
case "$1" in
-h | -\? | --help )
echo "Add a todo:"
echo " todo Reformulate the widget plans."
echo "See what you have to do:"
echo " todo"
samstokes / stash
Created Nov 6, 2012
example git log with a stash
View stash
sstokes@sstokes-mba-ubuntu:gittest$ git log --all --decorate --graph --oneline
* 15e2132 (refs/stash) WIP on master: 2e83ed8 initial commit
| * 61442a1 index on master: 2e83ed8 initial commit
* 2e83ed8 (HEAD, master) initial commit
samstokes / test.rb
Created Apr 18, 2012
Test public Ruby gist
View test.rb
# This is a large amount of Ruby code
# No, really, it is
# Can't you tell?
def foo(bar)
# That was a large amount of Ruby code
# Wiffle bamble boo
samstokes / dg_example_bind.rb
Created Nov 14, 2011
DG example: bind: following links on a Google search
View dg_example_bind.rb do
fetch('').bind! do |doc|
fetch((doc / 'ol' / 'li' / 'a')[0][:href])
end.bind! do |doc|
fetch((doc / '#repository_homepage').at(:a)[:href])
end.callback do |doc|
# now the previous 'doc's aren't in scope, so I can't accidentally
# refer to them
end.errback do |error|
samstokes / dg_loop_syntaxen.rb
Created Nov 7, 2011
DG loop combinator thinking
View dg_loop_syntaxen.rb
# Hmmm
DG::loop_until { url.present? && chunks_done < 25 }.body do
make_http_request(stuff, things, other_things).safe_callback do |blah|
# Yum
DG::loop_until(lambda { url.present? && chunks_done < 25 }) do
make_http_request(stuff, things, other_things).safe_callback do |blah|
samstokes / methods_returning.rb
Created Oct 21, 2011
Stick this in your .irbrc and smoke it
View methods_returning.rb
def methods_returning(answer, *args)
# probably want to filter out some methods
# e.g. ones that mutate their receiver...
blacklist = %w()
(methods - blacklist).select do |method|
guinea_pig = begin
rescue TypeError => e
raise unless e.message =~ /can't clone/
samstokes /
Created Oct 17, 2011
One ISerialization to rule them all?
import backtype.storm.serialization.ISerialization;
public class SerializableSerialization<T extends Serializable> implements ISerialization<T> {
samstokes / it_should_include_such_that.patch
Created Oct 8, 2011
[].should include_such_that {|item| p(item) }
View it_should_include_such_that.patch
commit e5e4aebccc334809c355b7387dc1469e18be2377
Author: Sam Stokes <>
Date: Wed Oct 5 17:02:47 2011 -0700
[2, 4, 6].should_not include_such_that(&:odd?)
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index c6b006b..03aeec5 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
You can’t perform that action at this time.