Skip to content

Instantly share code, notes, and snippets.

View fish2000's full-sized avatar
👉
My Python work is on the Mars helicopter, and ubiquitous on earth, and more!!!!

Alexander Böhn fish2000

👉
My Python work is on the Mars helicopter, and ubiquitous on earth, and more!!!!
  • Objects in Space and Time, LLC
  • Baltimore, MD
  • 01:08 (UTC -04:00)
  • X @fish2000
View GitHub Profile
@luispedro
luispedro / bloomfilter.py
Created August 7, 2010 22:07
Bloom filter in python
import numpy as np
def insert_bit(array, index):
inner = (index % 64)
index //= 64
array[index] |= (1 << inner)
def is_set(array, index):
inner = (index % 64)
index //= 64
# as we’re going to use Unicorn as the application server
# we’re not going to use common sockets
# but Unix sockets for faster communication
upstream shop {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
# for UNIX domain socket setups:
server unix:/tmp/shop.socket fail_timeout=0;
@paulfarning
paulfarning / gist:609330
Created October 4, 2010 06:58
CSS3 rolled corners
.section {
border: 4px solid #fff;
margin: 100px;
padding: 10px 20px;
overflow: hidden;
width: 310px;
background-image: -moz-linear-gradient(top, #f6f2ec, #e2dbce); /* FF3.6 */
background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, #f6f2ec),color-stop(1, #e2dbce)); /* Saf4+, Chrome */
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#f6f2ec', EndColorStr='#e2dbce'); /* IE6,IE7 */
@mikelikespie
mikelikespie / refresh_css.js
Created October 27, 2010 18:31
This refreshes all the css on a page by changing the query string
/*
Add a bookmark to this
javascript:(function(){var c=document.getElementsByTagName("link");for(var d=0;d<c.length;d++){var a=c[d];if(a.rel=='stylesheet'||a.type=="text/css"){var e="css_buster_"+Math.floor(Math.random()*1000000000);var g=a.href.split("?",2);var f;if(g.length>1){var b=g[1].indexOf("&")==-1;if(b){f=e}else{f=g[1]+"&"+e}}else{f=e}a.href=g[0]+"?"+f}}})();
*/
(function() {
var links = document.getElementsByTagName('link');
for (var i = 0; i < links.length; i++) {
var l = links[i];
if (l.rel == 'stylesheet' || l.type == 'text/css') {
@igrigorik
igrigorik / webapp.rb
Created November 13, 2010 21:28
Inspired by @JEG2's talk at Rubyconf... Any ruby object, as a webapp! 'Cause we can. :-)
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
@fiee
fiee / colors.py
Created November 16, 2010 10:48
Color conversion helpers, see also fiee/fiee-coloree
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def HtmlColorCode_to_strings(value):
"Convert a HTML color code like '#FFCC00' or 'FFCC00' to a list of strings ['FF', 'CC', '00']"
x = 1 * value.startswith('#')
return [value[x:x+2],value[x+2:x+4],value[x+4:x+6]]
def HtmlColorCode_to_ints(value):
"Convert a HTML color code like '#FFCC00' or 'FFCC00' to a list of integers [255, 204, 0]"
@tswicegood
tswicegood / fabfile.py
Created December 27, 2010 23:45
Fabric file for compiling CoffeeScript for use with CouchApp
# This requires a few configuration values to be set in order to know what
# parameters to provide to ``couchapp``.
# The default value to be sent as ``--docid`` to ``couchapp push``
DEFAULT_DOCID = "_design/awesome"
# The default destination to be sent to ``couchapp push``
DEFAULT_DEST = "some_db"
# Actual fabfile script
@robcowie
robcowie / eventriloquist.py
Created January 20, 2011 17:16
Supervisor --> AMQP event listener
# -*- coding: utf-8 -*-
"""
Run as a supervisor event listener process. See http://supervisord.org/events.html for more info.
An example eventlistener config block looks like:
[eventlistener:myeventhandler]
command=python /path/to/eventriloquist.py
events=EVENT
@jpwatts
jpwatts / mac-homebrew-pyexiv2.sh
Created February 10, 2011 00:33
In which I finally get pyexiv2 working on my Mac using Homebrew and a series of disgusting hacks
#!/bin/sh
brew install python boost exiv2
curl -O http://launchpadlibrarian.net/61465005/pyexiv2-0.3.0.tar.bz2
tar xjvf pyexiv2-0.3.0.tar.bz2
cd pyexiv2-0.3.0
# https://answers.launchpad.net/pyexiv2/+question/140742
echo "env['FRAMEWORKS'] += ['Python']" >> src/SConscript
@parente
parente / runinenv.sh
Created February 15, 2011 01:54
run a command in virtualenv, useful for supervisord
#!/bin/bash
VENV=$1
if [ -z $VENV ]; then
echo "usage: runinenv [virtualenv_path] CMDS"
exit 1
fi
. ${VENV}/bin/activate
shift 1
echo "Executing $@ in ${VENV}"
exec "$@"