Skip to content

Instantly share code, notes, and snippets.

View cshoe's full-sized avatar
🚵

Chris Schomaker cshoe

🚵
View GitHub Profile
@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):
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 / 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>
@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': … }
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 / gist:83696dd39f12f3447ef5
Created May 14, 2014 18:51
Cleanup interviews for Mo.
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;}

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:

# 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):
"""

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:

import time
from contextlib import contextmanager
@contextmanager
def timed(metric, tags=None):
start = time.time()
try:
yield tags
finally:
print tags