This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
sys.setrecursionlimit(10000) | |
max = 1000 | |
memo = {} | |
def collatz(x): | |
global memo | |
if x in memo: pass | |
elif x % 2: memo[x] = x * 3 + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys, os, os.path | |
def match(query, item): | |
for c in query: | |
if c in item: item = item[item.find(c)+1:] | |
else: return False | |
return True | |
def finder(query, items): | |
return [ item for item in items if match(query, item) ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys | |
class Newquitter(object): | |
def __call__(s, v): | |
sys.exit(v) | |
def __repr__(s): | |
if os.isatty(sys.stdout.fileno()): sys.exit(0) | |
else: return "Use exit() or Ctrl-D (i.e. EOF) to exit" | |
__str__ = __repr__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Child(Parent): | |
def __init__(self, x): | |
# This is crap, Python. | |
super(Child, self).__init__(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.someplace.projname.Ingester; | |
import org.someplace.projname.Processor; | |
import org.someplace.projname.OutputCleaner; | |
import org.someplace.projname.Formatter; | |
public class Test { | |
public static void main(String[] args){ | |
MifPipeline pipeline = new MifPipeline(); | |
pipeline.addMifModule(Ingester.class.getname(), "stdio://stdin", "vm://one"); | |
pipeline.addMifModule(Processor.class.getname(), "vm://one", "vm://two"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.someplace.projname.{Ingester,Processor,OutputCleaner,Formatter}; | |
object MifPipeline extends MifPipelineBuilder { | |
def main(args: String[]) { | |
"stdio://in" -> Ingester -> Processor -> OutputCleaner -> Formatter -> "stdio://out" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <string> | |
#include <set> | |
#include <stdlib.h> | |
using namespace std; | |
int main(int argc, char** argv) { | |
if(argc != 2) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <sstream> | |
#include <string> | |
#include <set> | |
#include <stdlib.h> | |
using namespace std; | |
int main(int argc, char** argv) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//submit a new message to the server | |
function send(msg) { | |
if (CONFIG.debug === false) { | |
// XXX should be POST | |
// XXX should add to messages immediately | |
jQuery.get("/send", {id: CONFIG.id, text: msg}, function (data) { }, "json"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Vector | |
def normalize | |
sum_of_squares = to_a.inject(0) { |s, x| s + x*x } | |
if sum_of_squares == 0 | |
self | |
else | |
self * (1 / Math.sqrt(sum_of_squares)) | |
end | |
end | |
end |
OlderNewer