Skip to content

Instantly share code, notes, and snippets.

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
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;
// 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.
//
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"))
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
def repeater(str):
return str + str
def hello():
return repeater("Hello")
@pope
pope / mp
Created March 24, 2009 03:35
#!/usr/bin/env python
import mp
import multiprocessing
if __name__ == "__main__":
multiprocessing.freeze_support()
mp.main()
(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
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()
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