Skip to content

Instantly share code, notes, and snippets.

View hallfox's full-sized avatar

Taylor Foxhall hallfox

  • Bloomberg LP
View GitHub Profile
@hallfox
hallfox / Godwin.py
Created November 2, 2013 01:15
Quick implementation of Godwin's Law for text files in Python. Kind of tounge-in-cheek. Basically made it up on the spot.
# Reads a file and searches for the word "Hitler" or "Nazi"
# It then prints "the Godwin Ratio" which I have defined as the ratio
# between the nubmer of the line the word "Hitler" or "nazi" was first
# found and the total number of lines in the file plus one. (The reason
# for the plus one is because in the definition below the probability
# approaches 1, but implies that it never reaches 1.)
#
# Godwin's law- as the duration of an argument on the Internet increases,
# the probability that a comparison to Nazis or Hitler will be made approaches 1.
@hallfox
hallfox / bin.txt
Last active December 28, 2015 06:19
Takes an input of binary characters with every eight bits of binary (a byte) separated by a space and converts it into its ASCII representation.
01001001 00100000 01100001 01101101 00100000 01101000 01100101 01110010 01100101 00100000 01110100 01101111 00100000 01110111 01101001 01110011 01101000 00100000 01111001 01101111 01110101 00100000 01100001 00100000 01001000 01100001 01110000 01110000 01111001 00100000 01000010 01101001 01110010 01110100 01101000 01100100 01100001 01111001 00101110 00100000 01010100 01100101 01100011 01101000 01101110 01101001 01100011 01100001 01101100 01101100 01111001 00100000 01101001 01110100 00100111 01110011 00100000 01101110 01101111 01110100 00100000 01111001 01101111 01110101 01110010 00100000 01100001 01100011 01110100 01110101 01100001 01101100 00100000 01100100 01100001 01111001 00100000 01101111 01100110 00100000 01100010 01101001 01110010 01110100 01101000 00100000 01100001 01101110 01100100 00100000 01111001 01101111 01110101 00100000 01110010 01100101 01101101 01100101 01101101 01100010 01100101 01110010 00100000 01101110 01101111 01110100 01101000 01101001 01101110 01100111 00100000 01100001 01101111 0110001
from kivy.app import App
from kivy.uix.scatter import Scatter
from kivy.uix.label import Label
from kivy.uix.floatlayout import FloatLayout
class TestApp(App):
def build(self):
f = FloatLayout()
s = Scatter()
@hallfox
hallfox / ex18.py
Last active August 29, 2015 14:03
My style applied to Ex17 of LPTHW.
from sys import argv
from os.path import exists
script, from_file, to_file = argv
#so much of this printing is incredibly uneccessary
with open(from_file) as src:
with open(to_file, 'w') as dest:
print("Copying from {} to {}".format(from_file, to_file)
data = src.read();
#include <iostream>
using namespace std;
int main()
{
cout << "hello, world";
return 0;
}
@hallfox
hallfox / ex33_hack.py
Last active August 29, 2015 14:04
Practice with breaking code.
#the function from the exercise, modified
def loop_list(n, inc=1):
numbers = []
for i in range(0, n, inc):
print("At the top i is %d" % i)
numbers.append(i)
print("Numbers now:", numbers)
print("At the bottom i is %d" % i)
@hallfox
hallfox / index.html
Last active August 29, 2015 14:04
Something like this...
<!--The rest of your page -->
<div id="banner-wrap">
<a href="path/to/java/page"><img src="path/to/java/img" /></a>
<a href="path/to/python/page"><img src="path/to/python/img" /></a>
<a href="path/to/html/page"><img src="path/to/html/img" /></a>
</div>
<!--Other part of your page -->
@hallfox
hallfox / hack5.c
Created July 31, 2014 02:30
It's easier to do in C.
#include <stdio.h>
int main()
{
int x;
printf("Enter a number: ");
scanf("%d", &x);
printf("You input: %d", x);
CC=#complier
CFLAGS=-c -Wall -g
LDFLAGS=
SOURCES=#source files
OBJECTS=$(SOURCES:.cpp=.o)
TARGET=#build target
all: $(SOURCES) $(TARGET)
$(TARGET): $(OBJECTS)
set nocompatible " Relinquish vi support
filetype off
set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#rc()
" Plugin 'githubUsername/repoName'
" Let vundle manage itself:
Plugin 'gmarik/vundle'