Skip to content

Instantly share code, notes, and snippets.

View foresmac's full-sized avatar

Chris Foresman foresmac

  • Analyte Health
  • Chicago
View GitHub Profile
@foresmac
foresmac / Git branch bash prompt
Created March 27, 2013 20:58
Shows current working git branch in you bash prompt.
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /'
}
PS1="\[\e[32m\]\$(parse_git_branch)\[\e[34m\]\h:\W \$ \[\e[m\]"
export PS1
@foresmac
foresmac / solarized.theme
Created May 3, 2013 16:31
This is designed to map Solarized Dark colors to BPython, using ANSI colors configured for OS X's Terminal via [Solarized Dark.ML.settings](https://github.com/foresmac/terminal-solarized).
# This theme attempts to map Solarized Dark colors to bpython similar to
# SublimeText 2. Requires Solarized Dark.ML.settings for Terminal.app.
# Copy to ~/.bpython/solarized.theme and
# set "color_scheme = solarized" in ~/bpython/config
[syntax]
keyword = g
name = d
comment = G
@foresmac
foresmac / get_instagram_tag.py
Last active December 28, 2021 08:09
Download a particular hashtag from InstagramThis script will download all the images with a particular hashtag from Instagram. It's not very clever, and will try to suck down every image it can find; if you use a particularly popular tag, it will take a **long time** to run. Simply run it from the command line like so:`./get_instagram_tag.py <ta…
#! /usr/bin/python
## get_instagram_tag
## by Chris Foresman
## @foresmac
##
## Instagram API: http://instagram.com/developer/
## Requires the requests Python library
## (sudo) pip install requests

Keybase proof

I hereby claim:

  • I am foresmac on github.
  • I am foresmac (https://keybase.io/foresmac) on keybase.
  • I have a public key whose fingerprint is 1A8A 378F 3DC9 20D1 4A1C 726B 8D4A B9B4 5F15 B873

To claim this, I am signing this object:

@foresmac
foresmac / mock_object.py
Last active August 29, 2015 14:13
Mock objects for testing
class MockObject(object):
'''Just pass a dict to create test attributes'''
def __init__(self, params):
for key, value in params.items():
setattr(self, key, value)
"""
Pseudo-random django secret key generator.
- Does print SECRET key to terminal which can be seen as unsafe.
"""
import string
import random
# Just use letters and digits to simplfy setting values from user_data.txt
chars = ''.join([string.ascii_letters, string.digits])
UUID_REGEX = r'[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
import random
number_list = [i + 1 for i in range(100)]
pick = random.choice(number_list)
print 'I am thinking of a number from 1 to 100'
turn = 1
while turn < 6:
guess = raw_input('Type your guess: ')
import json
import urllib.request
hashtag = '' # Choose any hashtag
ACCESS_TOKEN = '' # Get a token from https://instagram.com/developer
start_url_string = 'https://api.instagram.com/v1/tags/{0}/media/recent?access_token={1}'
start_url = start_url_string.format(hashtag, ACCESS_TOKEN)
response = urllib.request.urlopen(start_url)
raw_data = response.read()
from sense_hat import SenseHat
import random
import time
hat = SenseHat()
o = (200, 128, 0)
r = (255, 0, 0)
y = (255, 255, 0)