Skip to content

Instantly share code, notes, and snippets.

View cshoe's full-sized avatar
🚵

Chris Schomaker cshoe

🚵
View GitHub Profile
@cshoe
cshoe / gist:2772000
Created May 22, 2012 22:15
Python Logging DictConfig
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'basic': {
'format': '%(asctime)-6s: %(name)s - %(levelname)s - %(message)s',
}
},
'handlers': {
'console': {
@cshoe
cshoe / logging.py
Created May 23, 2012 20:55
Python dictConfig Logging
DEV_LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'basic': {
'format': '%(asctime)-6s: %(name)s - %(levelname)s - %(message)s',
}
},
'handlers': {
'console': {
@cshoe
cshoe / datadog_ascii.py
Last active February 22, 2016 19:55
Datadog Python library doesn't seem to like Unicode.
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from datadog import statsd
def main():
"""docstring for main"""
import functools
import threading
from tornado import gen, httpserver, ioloop, stack_context, web
class ThreadRequestContext(object):
"""
A context manager that saves some per-thread state globally.
Intended for use with Tornado's StackContext.
import time
from contextlib import contextmanager
@contextmanager
def timed(metric, tags=None):
start = time.time()
try:
yield tags
finally:
print tags
@cshoe
cshoe / reader_example
Created June 3, 2013 19:42
Quick ReaderClient example.
from readability import ReaderClient
rdb_client = ReaderClient('my_reader_token', 'my_reader_secret', 'user_key', 'user_secret')
bookmarks_response = rdb_client.get_bookmarks(favorite=True)
print bookmarks_response.content
>>> {'bookmarks': [{'user_id': 1039419, 'read_percent': u'0.00', u'tags': [], u'date_updated': u'2013-05-31 08:22:57', u'favorite': True, u'archive': False, u'date_archived': None, u'date_opened': None, u'article': … }
@cshoe
cshoe / rdb_content_post.py
Last active December 17, 2015 21:19
Example of POSTing content to Readability Parser API in Python.
# -*- coding: utf-8 -*-
import json
import urllib
import requests
CONTENT = """
<html lang="en" dir="ltr" class="client-js"><head>
<title>Cryptography - Wikipedia, the free encyclopedia</title>
import timeit
def symmetric_difference_test():
"""
"""
requested = set([1,3,5,7,9,11,13,15,17,19,21])
found = set([1,3,5,11,13,15,17,19])
sym_diff = found.symmetric_difference(requested)
@cshoe
cshoe / oop_can_be_the_suck.py
Created March 6, 2013 18:58
It's this kind of stuff...
class Foo(object):
def __init__(self, some_value):
# this is proof that your setter is worthless.
# you're not even using it...
self.some_value = some_value
# If you're getters/setters add no real value
# i.e. a default, stop it.
def set_some_value(self, val):
@cshoe
cshoe / gist:5092303
Last active December 14, 2015 13:19
Thoughts on samhuntphoto.com

Homepage

Seems a bit happhazard. Of all the photos on the site, I'd say the vodka one is one of the least strong. I'm curious as to why you picked it.

The mouse over copywrite thing is unneccessary. Just put "All Images Copywrite Sam Hunt" somewhere in the footer. Better typography needed but here's the idea: http://i.imgur.com/XpMDEMN.png.

Navigation