Skip to content

Instantly share code, notes, and snippets.

View RyanBalfanz's full-sized avatar
🎯
Focusing

Ryan Balfanz RyanBalfanz

🎯
Focusing
View GitHub Profile
@RyanBalfanz
RyanBalfanz / serve.py
Created July 8, 2016 07:47 — forked from Morreski/serve.py
Python SimpleHTTPServer for Static Serving (React / Angular / Ember) in HTML5 mode (a la mod_rewrite)
'''
Taken from:
http://stackoverflow.com/users/1074592/fakerainbrigand
http://stackoverflow.com/questions/15401815/python-simplehttpserver
'''
import sys
import os
if sys.version_info < (3,):
import SimpleHTTPServer as server
@RyanBalfanz
RyanBalfanz / upload.py
Last active July 26, 2022 16:07
[Heroku] Direct to S3 File Uploads in Python
"""
Fix for some issues with the original code from Heroku:
https://devcenter.heroku.com/articles/s3-upload-python
This example is also designed for use with Django, not Flask as in the original.
"""
import base64
import hashlib
import hmac
@RyanBalfanz
RyanBalfanz / Arch_Linux_Raspberry_Pi.md
Last active August 29, 2015 14:02
Arch Linux fresh install on Raspberry Pi

Prepare the SD Card:

➜  Downloads  time sudo dd bs=1m if=ArchLinuxARM-2014.06-rpi.img of=/dev/rdisk1
1870+0 records in
1870+0 records out
1960837120 bytes transferred in 132.563127 secs (14791723 bytes/sec)
sudo dd bs=1m if=ArchLinuxARM-2014.06-rpi.img of=/dev/rdisk1  0.01s user 0.90s system 0% cpu 2:12.58 total

Update and Install Additional Packages

@RyanBalfanz
RyanBalfanz / Makefile
Created July 30, 2013 19:27
Boggle Solver in Python
profile:
python -m cProfile foo.py < board_3.txt
@RyanBalfanz
RyanBalfanz / ico2cur.py
Created April 12, 2012 22:29
Convert an ICO file to a CUR file
#!/usr/bin/env python
# coding: utf-8
from optparse import OptionParser
import sys
usage = """%prog infile [options]
Reads an ICO file and writes a CUR file. The ICO file should contain a single
image. If no outfile name is provided, the infile name is used to create an
@RyanBalfanz
RyanBalfanz / pip_upgrade_all.py
Created April 9, 2012 23:13
pip install -U ALL_THE_THINGS
import pip
from subprocess import call
for dist in pip.get_installed_distributions():
try:
call("pip install --upgrade " + dist.project_name, shell=True)
except Exception as e:
print "Caught Exception: {error}".format(error=e)
print "Dunzo"
@RyanBalfanz
RyanBalfanz / chart.css
Created August 18, 2011 23:02
Goodbye-Mint
html {
height: 100%;
-webkit-box-shadow: inset 0 0 20px 0 rgba(0,0,0,0.2);
-moz-box-shadow: inset 0 0 20px 0 rgba(0,0,0,0.2);
-webkit-font-smoothing: antialiased;
padding: 0;
margin: 0;
font-family: 'HelveticaNeue', Helvetica, Arial Sans-serif;
font-size: 13px;
color: #555555;
@RyanBalfanz
RyanBalfanz / arduino-python.py
Created June 10, 2011 06:20
Arduino-Python
import logging
import random
import sys
import time
from arduino import Arduino
logging.basicConfig(level=logging.DEBUG)
def setup_board(device=None, outputPins=None):
#!/usr/bin/env python
# encoding: utf-8
"""
FileChunker.py
Created by Ryan Balfanz on 2009-11-19.
Copyright (c) 2009 Ryan Balfanz. All rights reserved.
"""
import fileinput
import random
class Markov(object):
def __init__(self, open_file):
self.cache = {}
self.open_file = open_file
self.words = self.file_to_words()
self.word_size = len(self.words)
self.database()