Skip to content

Instantly share code, notes, and snippets.

View mjhea0's full-sized avatar

Michael Herman mjhea0

View GitHub Profile
anonymous
anonymous / peterspurepythonpicopdf.py
Created May 25, 2014 21:15
Peter's pure Python PicoPDF: Create a PDF in 100 lines of Python
from datetime import datetime
from zlib import compress
def serialize(x):
if isinstance(x, dict):
return '<<' + '\n'.join(serialize(k) + ' ' + serialize(v) for k, v in x.items()) + '>>'
if isinstance(x, list):
return '[' + ' '.join(serialize(it) for it in x) + ']'
return str(x)
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask.ext.httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
@mchail
mchail / Gemfile
Last active October 13, 2015 02:37
Zapier Webhooks in Rails with Resque
gem "resque", :require => 'resque/server'
gem 'resque-history'

Suriving Dev Bootcamp


Remember that Hard Work is more important than talent or intelligence.

Greatness is often misattributed to some finite level of ability. People assume others are ahead of them without accounting for the amount of work that person is putting in to achieve their success.

Persistence and Patience

- patience with yourself and persistence with this process. Learning over completion - You just paid over $12,000 to be here. It's not about checking boxes off of a list, it's about learning the material
@dannguyen
dannguyen / _README.md
Last active January 20, 2016 07:16
Scripts to autodownload and organize the California kindergarten immunization data files

Fetching and collating the California Kindergarten immunization data in Python and Bash

by Dan Nguyen @dancow

tl;dr: a quick example of practicing reproducible data journalism, and somewhat timely given the recent school vaccination law signed by California Gov. Jerry Brown

These are scripts that are part of the mundaneprogramming.github.io repo for SRCCON 2015 and will soon have their own entry/explanation on that site. They aren't meant to be best/canonical practices (e.g. I felt like using csv.DictWriter so there it is), nor do I guarantee that they work. But you're free to run them to see what happens. All they currently do is download the relevant spreadsheets and compile them into a file, which ends up being one of the most tedious parts of the entire investigation due to how the [files are organized on the home

@nicolasbernard
nicolasbernard / docker-k8s.sh
Created March 26, 2016 12:25
How to install Docker/k8s from scratch on OSX
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" # install HomeBrew
brew tap caskroom/cask # install Cask
brew cask install virtualbox # install VirtualBox
brew install docker docker-machine # install Docker and Docker-machine
docker-machine create --driver virtualbox default # create a Docker VM named "default"
eval $(docker-machine env default) # set env var to tell Docker client to talk to our VM
docker version # Docker works, yay!
brew tap redspread/spread # tell HomeBrew where Spread is
brew install kubectl spread # install Kubectl and Spread
spread cluster start # ask Spread to start a k8s cluster with Docker client settings
@ambv
ambv / post_iteration_deletion.py
Created May 21, 2016 23:52
Requires Python 3.3+
from contextlib import ExitStack
d = {index: str(index) for index in range(100)}
with ExitStack() as stack:
for key in d:
if key % 13 == 0:
stack.callback(d.pop, key)
print(d)
@nepsilon
nepsilon / python-timeit.md
Last active July 6, 2016 01:24
A simple way to benchmark your code in Python — First published in fullweb.io issue #50

A simple way to benchmark your code in Python

You’re working on your script and want to see how fast a function would be. Here’s how to do that with the timeit module, included in the standard library.

Let’s say you have the following script:

import random
@nepsilon
nepsilon / python-better-flow-control.md
Last active July 8, 2016 06:20
Better Flow Control with Python — First published in fullweb.io issue #32

Better Flow Control with Python

I recently interviewed 4 developers for a Python programming position They all knew how to use requests, call APIs and worked either with Django or Flask, but I saw all of them ignoring most of Python’s specific control flow.

Here are two of them, try/except/else/finally and for/else:

try: 
    # What you want to do, which might
@nepsilon
nepsilon / 3-hidden-python-tips.md
Last active October 20, 2016 02:11
3 hidden Python tips — First published in fullweb.io issue #60

3 hidden Python tips 🐍

Hidden from beginner tutorials and seldom found in books.

1. You can multiply a string to repeated it:

>>> "HOOLI-"*2
'HOOLI-HOOLI-'