Skip to content

Instantly share code, notes, and snippets.

Chris Schomaker cshoe

Block or report user

Report or block cshoe

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
@cshoe
cshoe / datadog_ascii.py
Last active Feb 22, 2016
Datadog Python library doesn't seem to like Unicode.
View datadog_ascii.py
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from datadog import statsd
def main():
"""docstring for main"""
View stack_context.py
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.
View context.py
import time
from contextlib import contextmanager
@contextmanager
def timed(metric, tags=None):
start = time.time()
try:
yield tags
finally:
print tags
View keybase.md

Keybase proof

I hereby claim:

  • I am cshoe on github.
  • I am cshoe (https://keybase.io/cshoe) on keybase.
  • I have a public key whose fingerprint is 2DB5 0FC0 C3FF F9EF D3A9 76A2 1E0B 7699 6E4C 5D94

To claim this, I am signing this object:

View test_signals.py
# As mentioned, this is a bit verbose but I like the separation of concerns.
# Basically, you have two functions -- one that does meaningful work and
# another that just serves as the "glue" to connect the Django signal
# infrastructure to your function.
from django.dispatch import receiver
@receiver
def glue_funtion(sender, **kwargs):
"""
View keybase.md

Keybase proof

I hereby claim:

  • I am cshoe on github.
  • I am cshoe (https://keybase.io/cshoe) on keybase.
  • I have a public key whose fingerprint is C6FD 526A 4254 CC42 2427 0747 0862 C043 DAD3 9ACC

To claim this, I am signing this object:

@cshoe
cshoe / gist:83696dd39f12f3447ef5
Created May 14, 2014
Cleanup interviews for Mo.
View gist:83696dd39f12f3447ef5
import sys
from xml.etree import ElementTree
from jinja2 import Template
template_string = """{\\rtf1\\ansi\\ansicpg1252\cocoartf1265\cocoasubrtf190
{\\fonttbl\\f0\fswiss\\fcharset0 ArialMT;\\f1\\froman\\fcharset0 Times-Roman;}
{\colortbl;\\red255\green255\\blue255;}
View gist:10744045
FROM ubuntu:12.04
MAINTAINER Chris Schomaker <schomaker.c@gmail.com>
# add salt repository
RUN sudo apt-get update
RUN sudo apt-get install -y python-software-properties
RUN sudo add-apt-repository -y ppa:saltstack/salt
RUN sudo apt-get update
@cshoe
cshoe / reader_example
Created Jun 3, 2013
Quick ReaderClient example.
View reader_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 Dec 17, 2015
Example of POSTing content to Readability Parser API in Python.
View rdb_content_post.py
# -*- 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>
You can’t perform that action at this time.