Skip to content

Instantly share code, notes, and snippets.

View tomleo's full-sized avatar
:shipit:
Hacking into the mainframe

Tom Leo tomleo

:shipit:
Hacking into the mainframe
View GitHub Profile
@tomleo
tomleo / BF.java
Created August 7, 2012 01:10 — forked from lawrancej/BF.java
Brainf**
import java.io.IOException;
import java.util.LinkedList;
public class BF {
private interface Visitor {
void visit (Loop loop);
void visit (Left left);
void visit (Right right);
void visit (Increment increment);
void visit (Decrement decrement);
@tomleo
tomleo / gist:4420889
Created December 31, 2012 16:01
Add a file of numbers togeather
int getTotal(char *nameOfFile)
{
FILE * fin = fopen(nameOfFile, "r"); //this can be done in one line
int total=0;
int c;
if(fin == NULL)
perror("Error opeining file");
while((c = fgetc(fin)) != EOF)
""""Create "The Matrix" of binary numbers scrolling vertically in your terminal.
original code adapted from juancarlospaco:
- http://ubuntuforums.org/showpost.php?p=10306676
Inspired by the movie: The Matrix
- Corey Goldberg (2013)
Requires:
def divide(a, b):
return a/b
def calculate(a, b):
try:
result = divide(a, b)
except:
raise Exception('You Done Goofed')
return result
@tomleo
tomleo / gist:4958325
Last active December 13, 2015 18:49
A better UX for python tracebacks (The tracebacks) http://tomleos.tumblr.com/post/43123575189/a-better-ux-for-python-tracebacks
In [12]: calculate(4,0)
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
/home/tom/<ipython-input-12-4fcddf188333> in <module>()
----> 1 calculate(4,0)
/home/tom/<ipython-input-10-ea74cc892d2c> in calculate(a, b)
6 result = divide(a, b)
7 except:
----> 8 raise Exception('You Done Goofed')
@tomleo
tomleo / mergesort.cpp
Last active December 13, 2015 20:19
Implementation of merge sort in C++
CPPFLAGS=-g -c -std=c++0x
LDFLAGS=-g
RM=rm -f
SOURCES=merge-sort.cc
OBJECTS=merge-sort.o
all: merge-sort
@tomleo
tomleo / type-notes.rst
Last active May 6, 2019 00:59
Opensource Fonts

Serif

Libre Caslon:

http://www.impallari.com/projects/overview/libre-caslon-display-and-text

Domine:

http://www.google.com/fonts/specimen/Domine
@tomleo
tomleo / htmlit.py
Created June 9, 2013 22:29
A quick utility script to generate HTML from haml files
# This is my adhoc build script because I'm to lazy to relearn make
# and i'm bad at shell scripting, and sed is confusing to me
import os
import subprocess
OUT_PATH = os.path.realpath('.')
HAML_PATH = '{0}/{1}'.format(OUT_PATH, 'haml')
SKIP = ['.swp']
def skip(f):
for s in SKIP:
if f.endswith(s):
@tomleo
tomleo / django-notes.rst
Last active January 12, 2017 12:04
Notes about the Django Framework

Django ORM

pet_set is a lazy object that only makes a call to the dtabase when you begin to iterate over it. When the queryset is evaluated it will caches the results so latter calls to pet_set will not also call the database.

pet_set = Pet.objects.filter(species="Dog")
@tomleo
tomleo / gist:8000231
Created December 17, 2013 04:53
Turn on different colored LED's in Arduino
int i;
int redPin = 9;
int greenPin = 11;
int bluePin = 10;
int pins[3] = {redPin, greenPin, bluePin};
void setup()
{