Skip to content

Instantly share code, notes, and snippets.

View daanzu's full-sized avatar

David Zurow daanzu

View GitHub Profile
@n-st
n-st / view-on-archive-org.js
Created February 28, 2016 16:20
Bookmarklet to view current page on the Internet Archive Wayback Machine (https://archive.org/)
javascript:(function(){if(location.href.indexOf('http')!=0){input=prompt('URL:','http://');if(input!=null){location.href='http://web.archive.org/web/*/'+input}}else{location.href='http://web.archive.org/web/*/'+location.href;}})();
# dsnooped input
# dsnooped allows multiple applications to use an input device (microphone)
# without dsnoop, devices are exclusive, and the mic can only be used by one app at a time.
pcm.dsnooped {
type dsnoop
ipc_key 5978293 # must be unique for all dmix plugins!!!!
ipc_key_add_uid yes
slave {
pcm "hw:Microphone"
channels 2
@jordam
jordam / magiclight.py
Created August 13, 2015 12:59
A script to control MagicLight and other cheap wifi rgb lights
import socket, time
s = socket.socket()
address = ''
port = 5577
r = 0
g = 255
b = 0
keybit = "31".replace(':', '').decode('hex')
keybit += chr(r) + chr(g) + chr(b)
keybit += "00:f0:0f".replace(':', '').decode('hex')
@dalegaspi
dalegaspi / python27_on_centos65.md
Last active September 9, 2021 05:29
Installing Python 2.7 on CentOS 6.5

Installing Python 2.7 on Centos 6.5

Centos 6.* comes with Python 2.6, but we can't just replace it with v2.7 because it's used by the OS internally (apparently) so you will need to install v2.7 (or 3.x, for that matter) along with it. Fortunately, CentOS made this quite painless with their Software Collections Repository

sudo yum update # update yum
sudo yum install centos-release-scl # install SCL 
sudo yum install python27 # install Python 2.7

To use it, you essentially spawn another shell (or script) while enabling the newer version of Python:

@brentp
brentp / compare-wrappers.py
Last active May 2, 2024 08:11
compare call overhead of cffi and cython
"""
Compare speed of a cython wrapper vs a cffi wrapper to the same underlying
C-code with a fast function and a longer-running function.
This should run anywhere that has cffi and cython installed.
Ouput on my machine with python2.7:
brentp@liefless:/tmp$ python compare-wrappers.py
@todgru
todgru / starttmux.sh
Last active May 27, 2024 08:20
Start up tmux with custom windows, panes and applications running
#!/bin/sh
#
# Setup a work space called `work` with two windows
# first window has 3 panes.
# The first pane set at 65%, split horizontally, set to api root and running vim
# pane 2 is split at 25% and running redis-server
# pane 3 is set to api root and bash prompt.
# note: `api` aliased to `cd ~/path/to/work`
#
session="work"
@ChrisTM
ChrisTM / throttle.py
Created June 21, 2013 21:33
Python decorator for throttling function calls.
class throttle(object):
"""
Decorator that prevents a function from being called more than once every
time period.
To create a function that cannot be called more than once a minute:
@throttle(minutes=1)
def my_fun():
pass
@marcelom
marcelom / pysyslog.py
Created December 5, 2012 18:06
Tiny Python Syslog Server
#!/usr/bin/env python
## Tiny Syslog Server in Python.
##
## This is a tiny syslog server that is able to receive UDP based syslog
## entries on a specified port and save them to a file.
## That's it... it does nothing else...
## There are a few configuration parameters.
LOG_FILE = 'youlogfile.log'
@endolith
endolith / frequency_estimator.py
Last active May 8, 2024 17:59
Frequency estimation methods in Python
from __future__ import division
from numpy.fft import rfft
from numpy import argmax, mean, diff, log, nonzero
from scipy.signal import blackmanharris, correlate
from time import time
import sys
try:
import soundfile as sf
except ImportError:
from scikits.audiolab import flacread