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 java.util.List; | |
import java.util.ArrayList; | |
public class Bah { | |
public static void main(String[] args) { | |
final Foo foo = new Foo(); | |
final List<FunctionPointer<Object>> fps = new ArrayList<FunctionPointer<Object>>(); | |
fps.add(new FunctionPointer<String>() { | |
@Override |
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 java.io.BufferedReader; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import java.util.logging.Level; | |
import java.util.logging.Logger; | |
public class FileReadTest { | |
public static void main(String[] args) { | |
BufferedReader br = null; |
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
// tb.js | |
// TweetBackRedux 0.2 JS code | |
// Copyright (c) 2009 Jeremy Hilton < @jeremyhilton > | |
// This file is part of TweetBackRedux. | |
// | |
// TweetBackRedux is free software: you can redistribute it and/or modify | |
// it under the terms of the GNU General Public License as published by | |
// the Free Software Foundation, either version 3 of the License, or | |
// (at your option) any later version. | |
// |
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
from httplib.HTTPConnection | |
from urlparse import urlparse | |
def get_size_of_page(url): | |
o = urlparse(url) | |
conn = HTTPConnection(o.netloc) | |
conn.request("HEAD", o.path) | |
resp = conn.getresponse() | |
if resp.status == 200: | |
return long(resp.getheader("Content-Lenght")) |
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 | |
import gzip | |
import zlib | |
from urlparse import urlparse | |
from httplib import HTTPConnection | |
def workding_download_gzip_file(url, filename): | |
"""Download a gzip file and decompress it | |
Save the gzip file, then read it in and re-save it |
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
def repeater(str): | |
return str + str | |
def hello(): | |
return repeater("Hello") |
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 mp | |
import multiprocessing | |
if __name__ == "__main__": | |
multiprocessing.freeze_support() | |
mp.main() |
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
(mp) C:\Documents and Settings\pope\My Documents\mp\src\mp>python bin\mp | |
Traceback (most recent call last): | |
File "<string>", line 1, in <module> | |
File "C:\Python26\Lib\multiprocessing\forking.py", line 341, in main | |
prepare(preparation_data) | |
File "C:\Python26\Lib\multiprocessing\forking.py", line 450, in prepare | |
file, path_name, etc = imp.find_module(main_name, dirs) | |
ImportError: No module named mpTraceback (most recent call last): | |
File "<string>", line 1, in <module> | |
File "C:\Python26\Lib\multiprocessing\forking.py", line 341, in main |
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 time | |
import bisect | |
class PeriodicExecutor(object):#{{{ | |
def __init__(self, secs, callable): | |
self.callable = callable | |
self.secs = secs | |
self.next_time_to_run = time.time() |
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
require 'time' | |
class PeriodicExecutor | |
attr_reader :next_time_to_run | |
def initialize(secs, &block) | |
@secs = secs | |
@block = block | |
@next_time_to_run = Time.now.to_f |