Skip to content

Instantly share code, notes, and snippets.

View emmettbutler's full-sized avatar

Emmett Butler emmettbutler

View GitHub Profile
@emmettbutler
emmettbutler / poem
Last active October 8, 2015 07:47
emmett9001 and hentaiphd COLLAB!!!!!!111!!!!!one!
panties in the desk drawer by the water and the bed and the books
i doubt that this qualifies as "a" "poem" but that
is probably not the right way to think about it
this bed is amazingly soft and the air conditioner makes me jealous
in the dark in the dark in the dark in the dark
it would be cool to have a different animal's ears, like a beagle or a bug (????)
do you want a ricola or no
does liking the gore in dead space ii make me a bad person
this is line 316 and you're not a line actually
i think at this point i'm probably my own dad
@emmettbutler
emmettbutler / linkedlist.py
Created January 10, 2013 01:47
jan 2 Coding for Interviews challenge
class LinkedList(object):
def __init__(self):
self.head = None
self.tail = None
self.count = 0
def prettyprint(self):
"""iterate and print from head to taill"""
node = self.head
while node:
@emmettbutler
emmettbutler / yammer.py
Last active December 11, 2015 17:59
bash and python scripts for posting standups and sitdowns to Yammer via their REST API
#!/usr/bin/python
import argparse
import json
import os
from os.path import expanduser
import urllib
import urllib2
args = None
@emmettbutler
emmettbutler / gist:4953497
Created February 14, 2013 15:20
The movement code producing this beautiful periodic spiral pattern http://i.imgur.com/3Si1Ki5.gif
// ttime is the global timer, a floating point number of seconds
for(int i = 0; i < numSprites; i++){
sprites[i]->SetAngle(sprites[i]->GetAngle() + .04);
sprites[i]->SetPosition(spm::vec2(
anchorPoint.m[0] + 20 * i * sin(i * .01f * ttime),
anchorPoint.m[1] + 20 * i * cos(i * .01f * ttime)
));
sprites[i]->Draw(frame);
}
private String JsonEncode(Map<String, Object> map){
ObjectMapper mapper = new ObjectMapper();
String ret = null;
try {
StringWriter strWriter = new StringWriter();
mapper.writeValue(strWriter, map);
ret = strWriter.toString();
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
static int iter = 0;
for(int j = 0; j < 6; j++){
for(int i = 0; i < texture->getContentSize().width; i++){
float width = 127;
float red = sin(.05*i*PerlinNoise::noise(i*.005+iter*.005*j, i*.01) + 0) * width + 128;
float grn = sin(.05*i*PerlinNoise::noise(i*.005+iter*.005*j, i*.01) + 2) * width + 128;
float blu = sin(.05*i*PerlinNoise::noise(i*.005+iter*.005*j, i*.01) + 4) * width + 128;
ccColor4B color = ccc4(red, grn, blu, 255);
texture->setPixelAt(CCPoint(i+.03*(texture->getContentSize().width-i)*PerlinNoise::noise((i+iter)*.03, 10*j),
lineHeight+(j*(texture->getContentSize().height/6))+((texture->getContentSize().width-i)*.4)*
@emmettbutler
emmettbutler / cached_testcase.py
Created June 14, 2013 20:29
Tornado TestCase subclass that caches responses in memory. Useful when you need multiple test methods testing a single response and that response takes a long time to generate.
import datetime as dt
from tornado.testing import AsyncHTTPTestCase
class CachedTestCase(AsyncHTTPTestCase):
responses = {}
def cache_response(self, key, response):
self.responses[key] = {}
@emmettbutler
emmettbutler / ZoomCamera.as
Created July 6, 2013 21:15
Zoom Camera implementation - fixes the FlxCamera issue where zooming a follow camera doesn't zoom directly onto the follow target. Same as http://bullettimeninja.blogspot.com/2011/09/zoom-camera.html , except this zooms to the exact center of the target, rather than the top left.
/**
* You will need to change the package name to fit your game
*/
package
{
import org.flixel.FlxCamera;
import org.flixel.FlxG;
/**
* ZoomCamera: A FlxCamera that centers its zoom on the target that it follows
@emmettbutler
emmettbutler / rest.py
Created February 17, 2014 17:18
Script that wraps jedie's python-creole for the command line
# coding: utf-8
# https://github.com/jedie/python-creole
# convert a rest file to HTML (for blog)
import sys
import os.path
import re
from creole.rest2html.clean_writer import rest2html
@emmettbutler
emmettbutler / urltools.py
Last active August 29, 2015 13:57
Example solution to introductory python exercise
"""urltools.py - parse and format web URLs.
HINT:
>>> "http://google.com".split("://")
["http", "google"]
>>> "google.com/hangout/parsely.com/am".split("/")
["google.com", "hangout", "parsely.com", "am"]