Skip to content

Instantly share code, notes, and snippets.

<html>
<body>
<ul>
<li>First</li>
<li>Second</li>
<li>Third</li>
<li>Fourth</li>
</ul>
</body>
@miku
miku / 4956984.py
Created February 10, 2011 12:59
How do you split a csv file into evenly sized chunks in Python?
#!/usr/bin/env python
# import csv
# reader = csv.reader(open('4956984.csv', 'rb'))
def gen_chunks(reader, chunksize=100):
"""
Chunk generator. Take a CSV `reader` and yield
`chunksize` sized slices.
"""
@miku
miku / 4956984-1.py
Created February 10, 2011 13:16
How do you split a csv file into evenly sized chunks in Python?
#!/usr/bin/env python
# import csv
# reader = csv.reader(open('4956984.csv', 'rb'))
def gen_chunks(reader, chunksize=100):
"""
Chunk generator. Take a CSV `reader` and yield
`chunksize` sized slices.
"""
@miku
miku / tsocks+ssh.txt
Created February 14, 2011 15:49
Using tsocks with macfusion sshfs (sshfs-static) on Mac OS X 10.6
There has been some trouble running magical tsocks with sshfs-static on Leopard.
$ tsocks sshfs user@example.com: /Volumes/example.com -oauto_cache,reconnect,volname=example.com
dyld: could not load inserted library: /usr/lib/libtsocks.dylib
Trace/BPT trap
Here, sshfs is just a symlink to the sshfs-static executable
(from a current build of https://github.com/mgorbach/macfusion2).
@miku
miku / ccjobs.py
Created February 15, 2011 00:29
Jobportal API Universität Leipzig, Beispielscript.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Beispielscript für Jobportal API
Siehe auch: http://wwwdup.uni-leipzig.de/jobportal/docs/embed.html
$ ccjobs.py [QUERY]
"""
@miku
miku / lambdashuttle
Created February 16, 2011 07:09
Imperial Lambda Shuttle
cat <<'LAMBDASHUTTLE'
.-----.
| |.-\ \
| ||_|\ \
| : : \
| :___\ \
| _| :___\
||_| \ \
||_| : \
||_| ____\____\
@miku
miku / vagrant-0.7.2-trace-on-vagrant-up.txt
Created February 22, 2011 22:03
Basically on `vagrant up`. After re-installation same behavior.
/Library/Ruby/Gems/1.8/gems/virtualbox-0.8.3/lib/virtualbox/com/implementer/ffi.rb:95:in `call_and_check': Error in API call to get_state_file_path: 2147942405 (VirtualBox::Exceptions::FFIException)
from /Library/Ruby/Gems/1.8/gems/virtualbox-0.8.3/lib/virtualbox/com/implementer/ffi.rb:69:in `call_vtbl_function'
from /Library/Ruby/Gems/1.8/gems/virtualbox-0.8.3/lib/virtualbox/com/implementer/ffi.rb:36:in `read_property'
from /Library/Ruby/Gems/1.8/gems/virtualbox-0.8.3/lib/virtualbox/com/abstract_interface.rb:122:in `read_property'
from /Library/Ruby/Gems/1.8/gems/virtualbox-0.8.3/lib/virtualbox/com/abstract_interface.rb:64:in `state_file_path'
from /Library/Ruby/Gems/1.8/gems/virtualbox-0.8.3/lib/virtualbox/abstract_model/interface_attributes.rb:93:in `send'
from /Library/Ruby/Gems/1.8/gems/virtualbox-0.8.3/lib/virtualbox/abstract_model/interface_attributes.rb:93:in `spec_to_proc'
from /Library/Ruby/Gems/1.8/gems/virtualbox-0.8.3/lib/virtualbox/abstract_model/interface_attributes.rb:32:in `call'
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# http://hyperpublic.com/challenge
# 2011-02-26
# ==== ~ Q1 ==== #
# Hyperpublic users can add their friends by emailing a photo of them to
# add@hyperpublic.com. We want to determine a user’s influence on the system by
@miku
miku / 5161461.html
Created March 1, 2011 23:39
Rough sketch.
<html><head></head>
<body>
<script type="text/javascript" src="https://www.google.com/jsapi?key=..."></script>
<script>google.load("jquery", "1.4.3");</script>
<script type="text/javascript">
$(document).ready(function()
{
$.ajax({
url: "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D'http%3A%2F%2Fapi.causes.com%2Fbeneficiaries%2F1239.xml'&format=json",
<?php
$start = microtime();
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, "www.google.com");