Skip to content

Instantly share code, notes, and snippets.

View tildedave's full-sized avatar
🌮
Hungry

Dave King tildedave

🌮
Hungry
View GitHub Profile
@tildedave
tildedave / TooManyComments.java
Created April 27, 2011 01:21
Too much commented out code, Programmer Fail
/*
private boolean isSinkConstraint(LabelConstraint c) {
return containsPairLabel(getSinkLabelForConstraint(c));
}
private boolean isSourceConstraint(LabelConstraint c) {
return containsPairLabel(getSourceLabelForConstraint(c));
}
@tildedave
tildedave / ConstructorWtf.java
Created April 27, 2011 01:26
Incomprehensible Constructor
public JLiftCallHelper(Label receiverLabel,
Receiver receiver,
ReferenceType calleeContainer,
JifProcedureInstance pi,
List actualArgs,
Position position) {
super(receiverLabel, receiver, calleeContainer, pi, actualArgs, position);
this.receiverLabel = receiverLabel;
this.calleeContainer = calleeContainer;
if (receiver instanceof Expr) {
@tildedave
tildedave / CantSuperSuperInJava.java
Created April 27, 2011 01:31
Can't call super.super.typeCheck, so copy and paste code!
public class JLiftConstructorDecl_c extends JifConstructorDecl_c {
@Override
public Node typeCheck(TypeChecker tc) throws SemanticException {
if (!((JLiftTypeSystem) tc.typeSystem()).allowSmallLeaks())
return super.typeCheck(tc);
else {
// HACK: copy/pasted from ConstructorDecl_c
Context c = tc.context();
TypeSystem ts = tc.typeSystem();
@tildedave
tildedave / omg-end-the-function.ml
Created April 27, 2011 01:39
Function that's way, way, way too long
let constraint_set_to_flowgraph cl lattice =
match cl with
| [] -> G.create ()
| _ ->
let atoms = timeThunk (fun _ -> atoms_in_conslist cl) (SimpTimer.record_time "get atoms in constaint list") in
let _ =
begin
Printf.printf ("%d atoms\n") (LexpSet.cardinal atoms);
flush stdout
end
@tildedave
tildedave / calculator.js
Created June 8, 2011 04:00
Conditional probability calculator
// Intended use:
//
// Initialize with variableNames and variableMaxes.
// variableNames looks like {"A" : 0, "B": 1, "C" : 2, etc}
// variableMaxes looks like {"A": 3, "B": 6, "C": 2, etc}.
// These variables take on discrete values between 1 and their maximum.
// Data is parsed from a format like
// A B C P(A,B,C)
// where the final is a float. for example,
@tildedave
tildedave / algebra.v
Created June 15, 2011 04:12
abstract algebra from pinter's "A Book of Abstract Algebra"
Section Declaration.
Variable G : Set.
Variable op : G -> G -> G.
Variable inv : G -> G.
Variable e : G.
Notation "a * b" := (op a b).
Hypothesis assoc : forall a b c : G, a * (b * c) = (a * b) * c.
@tildedave
tildedave / continuous-deploy.py
Created June 17, 2011 12:43
Automated WAR Deployer (in Python)
#!/bin/python2.6
import os
import sys
import shutil
import subprocess
import time
from optparse import OptionParser
JAVA_HOME="/usr/lib/jvm/java-1.6.0-openjdk/"
@tildedave
tildedave / greenbar.py
Created August 17, 2011 10:41
nosetests from the browser for TDD heaven
#!/usr/bin/python26
import bottle
import sys
from StringIO import StringIO
from bottle import route, run
from optparse import OptionParser
from subprocess import Popen, PIPE
@tildedave
tildedave / hello.C
Created October 11, 2011 16:12
objdump of "hello world" in C
#include <stdio.h>
int main(void) {
printf("hello, world!\n");
return 0;
}
@tildedave
tildedave / who.mushcode
Created December 10, 2011 18:06
The +who function for one of my old MUSHes
FN_WHO [#1018]: [setq(1,words(lwho())%b[switch(words(lwho()),1,person,people)]%bconnected)][header(,%q1,,hw,hb)]%r%b%b[ljust(ansi(h,Player Name),20)][ljust(ansi(hw,Alias),10)][ljust([ansi(h,Status)],8)][ljust([ansi(hw,On For)],10)][ljust([ansi(h,Idle)],4)][iter(%0,%r[ifelse(orflags(##,WrJ),ansi(gh,\%)%b,%b%b)][ljust(ifelse(orflags(##,WrJ),ansi(yh,name(##)),name(##)),20)][ljust(alias(##),10)][ljust([xget(##,status)],8)][ljust([rjust(mod(div(conn(##),3600),100),2,0)]:[rjust(mod(div(conn(##),60),60),2,0)]:[rjust(mod(conn(##),60),2,0)],10)][ljust([first([timestring([idle(##)])])],4)])]%r[setq(0,[mudname()])][header(\% -- Staff,[mudname()],gh,yh,bh)]