Skip to content

Instantly share code, notes, and snippets.

Richard Kiss richardkiss

View GitHub Profile
@richardkiss
richardkiss / sl
Created Mar 30, 2018
A "mirror-image" ls in python, as discussed at https://news.ycombinator.com/item?id=16716150
View sl
#!/usr/bin/env python
import subprocess
import sys
output = subprocess.check_output(["ls"] + sys.argv[1:])
lines = output.split("\n")
View faq.md

Chia FAQ

Q: Where does the name "Chia" come from?

A: See Wikipedia.

View keybase.md

Keybase proof

I hereby claim:

  • I am richardkiss on github.
  • I am richardkiss (https://keybase.io/richardkiss) on keybase.
  • I have a public key whose fingerprint is 1BE0 3D39 4138 A2C2 E2EF 64D4 E0F4 3326 DBD8 AB6A

To claim this, I am signing this object:

View put_get_bug.py
#!/usr/bin/env python
"""
When PYTHONASYNCIODEBUG is set to 1, this causes a strange error:
TypeError: send() takes 2 positional arguments but 7 were given
Invoke as follows:
$ PYTHONASYNCIODEBUG=1 python3 put_get_bug.py
View Python 3.4 asyncio gc bug
#!/usr/bin/env python
"""
This is an example of what seems to be a garbage collection bug in Python 3.4.0
that does not exist in Python 3.3.3.
The example uses asyncio to create a producer that multiplexes to N consumers.
On my Mac, with N=100, 38 consumers are incorrectly garbage collected and only execute
once, dropping the surviving consumer count to 62.
View Python 3.4 asyncio bug
#!/usr/bin/env python
"""
This works fine in Python 3.3, but causes a strange error in Python 3.4.0:
TypeError: send() takes 2 positional arguments but 3 were given
"""
import asyncio
View f(f(n)) = -n.py
#!/usr/bin/env python
"""
The obvious way is to do it with complex numbers.
"""
def f(x):
# remember, in Python 1j means sqrt(-1)
return 1j * x
View Secure Pi
PROCESS
- install Raspian
- expand filesystem
- get on wifi
(zfec dependencies)
$ sudo apt-get install python-dev
$ curl http://python-distribute.org/distribute_setup.py | sudo python
View f(f(n)) = -n
#!/usr/bin/env python
"""
The obvious way is to do it with complex numbers.
"""
def f(x):
# remember, in Python 1j means sqrt(-1)
return 1j * x
@richardkiss
richardkiss / time_picker.js
Created Feb 16, 2013
jQuery extension for a time picker that has a small <select> menu with a small number of times that should handle 90% of cases, plus an "other time" option that allows any time to be entered.
View time_picker.js
/*global $ */
(function( $ ){
$.fn.time_picker = function( method ) {
if ( methods[method] ) {
return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if ( typeof method === 'object' || ! method ) {
return methods.init.apply( this, arguments );
} else {
You can’t perform that action at this time.