This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Caveat, the dates included are Julian but PyEphem and Python only really know about Gregorian. | |
# Additionally, not all of these performances were at The Globe so we should be moving the Observer | |
# accordingly. It still largely proves the hypothesis. | |
import argparse | |
from datetime import datetime | |
import ephem | |
from prettytable import PrettyTable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@patch('twilio.rest.resources.SmsMessages') | |
def test_send_sms_valid_args(self, MockClass): | |
instance = MockClass.return_value | |
instance.create.return_value = None | |
to_number = 5555555555 | |
msg = 'Hello world' | |
send_sms(to_number, msg) | |
instance.create.assert_called_once_with(to='+1' + str(to_number), | |
body=msg, from_=settings.TWILIO_FROM_NUM) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PHP code | |
function create_nonce() | |
{ | |
$mt = microtime(); | |
$rand = mt_rand(); | |
return preg_replace('/[^a-zA-Z0-9]/', '', base64_encode(sha1($mt . $rand, true))); | |
} | |
# Python code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SqlAlchemyMiddleware: | |
""" | |
A simple SA middleware class that creates a global scoped session from the | |
DATABASE_URL parameter in the settings file. | |
""" | |
def process_view(self, request, view_func, view_args, view_kwargs): | |
from django.conf import settings | |
from django.http import HttpResponseRedirect | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
jQuery templates use constructs like: | |
{{if condition}} print something{{/if}} | |
This, of course, completely screws up Django templates, | |
because Django thinks {{ and }} mean something. | |
Wrap {% verbatim %} and {% endverbatim %} around those | |
blocks of jQuery templates and this will try its best |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = app || {}; | |
$(function(){ | |
var app.Signature = Backbone.Model.extend({ | |
initialize: function(){ | |
return $.ajax({ | |
url: '/auth/' | |
}); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# stolen from http://stackoverflow.com/a/7276556/64266 | |
def countChar(word): | |
return dict((item, word.count(item)) for item in set(word)) | |
>>> countChar('google') | |
{'e': 1, 'g': 2, 'o': 2, 'l': 1} | |
>>> countChar('apple') | |
{'a': 1, 'p': 2, 'e': 1, 'l': 1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// found here http://stackoverflow.com/a/2673229/64266 | |
function isEmptyObject(obj) { | |
for(var prop in obj) { | |
if (Object.prototype.hasOwnProperty.call(obj, prop)) { | |
return false; | |
} | |
} | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: fab provision:type=cache_server | |
from fabric.api import task, run | |
import boto | |
@task | |
def provision(type="cache_server"): | |
# do some boto stuff | |
if type == "app_server": | |
# build an app server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
An elder was teaching his grandchildren about life. He said to them, | |
"A fight is going on inside me.. it is a terrible fight and it is | |
between two wolves. One wolf represents fear, anger, envy, sorrow, | |
regret, greed, arrogance, self-pity, guilt, resentment, inferiority, | |
lies, false pride, superiority, and ego. | |
The other stands for joy, peace, love, hope, sharing, serenity, | |
humility, kindness, benevolence, friendship, empathy, generosity, | |
truth, compassion, and faith." |