Skip to content

Instantly share code, notes, and snippets.

View foresmac's full-sized avatar

Chris Foresman foresmac

  • PayPal
  • East Tennessee
  • 14:19 (UTC -05:00)
View GitHub Profile
# just some sample code I made for demonstrating the turtle lib in Python
import turtle
import math
import random
turtle.colormode(255)
RGBCMY = [
# I found this on stack overflow but I forget where.
def is_prime(n):
""""pre-condition: n is a nonnegative integer
post-condition: return True if n is prime and False otherwise."""
if n < 2:
return False;
if n % 2 == 0:
return n == 2 # return False
k = 3
from sense_hat import SenseHat
import time
p = (128, 0, 255)
b = (0, 0, 0)
frame1 = [
b, b, b, b, b, b, b, b,
b, b, b, b, b, b, b, b,
b, b, b, b, b, b, b, b,
from sense_hat import SenseHat
import random
import time
hat = SenseHat()
o = (200, 128, 0)
r = (255, 0, 0)
y = (255, 255, 0)
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()
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: ')
UUID_REGEX = r'[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
"""
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])
@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)

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: