Skip to content

Instantly share code, notes, and snippets.

@tompaton
tompaton / kdtree.py
Created March 10, 2011 00:15
Python kd-tree spatial index and nearest neighbour search
#!/usr/bin/env python
# kd-tree index and nearest neighbour search
# includes doctests, run with: python -m doctest kdtree.py
class KDTree(object):
"""
kd-tree spatial index and nearest neighbour search
http://en.wikipedia.org/wiki/Kd-tree
"""
@Munawwar
Munawwar / ExcelDataReader.cs
Last active January 14, 2020 12:19
C# - Excel Data Reader Library - Convert Excel (XLSX or XLS) to CSV
/*
* Dependency : Excel Data Reader from http://exceldatareader.codeplex.com/
* You must add the references to the Dlls (downloaded from the link above) with Visual Studio.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Excel;
@lentil
lentil / patch.py
Created April 18, 2011 21:09
Control monkey-patch scope with a context manager
from __future__ import with_statement
from types import ClassType, MethodType, TypeType
class Patch(object):
class Missing:
pass
def __init__(self, obj, **kwargs):
@chandlerprall
chandlerprall / threaded_download.py
Created June 9, 2011 17:41
Small Python multi-threaded file downloader
import urllib2
import threading
from Queue import Queue
import sys, os, re
class ThreadedDownload(object):
REGEX = {
'hostname_strip':re.compile('.*\..*?/', re.I)
}
@starenka
starenka / .gitignore
Created September 18, 2011 20:02
fabfile to deploy flask app to nginx/supervisor/uwsgi stack
.idea/*
*.pyc
@jmoiron
jmoiron / jsontest.py
Created November 2, 2011 02:00
json speed test
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Which json is the best json."""
import json
import simplejson as sjson
import ujson
import cjson
import bson
@jvanasco
jvanasco / app-models-__init__.py
Created January 3, 2012 20:21
Reflecting in Pyramid/SqlAlchemy
import logging
log = logging.getLogger(__name__)
from sqlalchemy import Table
from sqlalchemy import MetaData
from sqlalchemy.orm import mapper
from sqlalchemy.orm import scoped_session
from sqlalchemy.orm import sessionmaker
from zope.sqlalchemy import ZopeTransactionExtension
@hrldcpr
hrldcpr / tree.md
Last active April 26, 2024 08:53
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@brandonb927
brandonb927 / osx-for-hackers.sh
Last active March 27, 2024 06:33
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@mrluanma
mrluanma / requirements.txt
Created September 4, 2012 14:40
Python 登录新浪微博(requests 真的比 urllib2 强了 2^^32 倍 pip install requests)
requests==2.4.3
rsa==3.1.4