Skip to content

Instantly share code, notes, and snippets.

View kevinw's full-sized avatar

Kevin Watters kevinw

View GitHub Profile
@kevinw
kevinw / gist:3549855
Created August 31, 2012 07:22
Paul Graham on copyright and how "files move around like smells"

Paul Graham on copyright and how "files move around like smells"

from his PyCon 2012 Keynote video at http://www.youtube.com/watch?v=R9ITLdmfdLI&t=33m43s

Questioner:

"In one of your recent things online, you said "The answer for the music industry, for example, is probably to give up insisting on payment for recorded music, and focus on licensing and live shows.

Alright I've been talking to Vint Cerf and some people about this--licensing exactly WHAT when copyrights mean NOTHING? You know the internet and software are on a viable business train only because software enjoys these copyrights. So HOW can you just sort of throw away the music industries product and copyright, and yet tell ALL these people to work on things that must be protected by copyright--trademark, a form of copyright--and process patents?"

@kevinw
kevinw / gist:2839668
Created May 30, 2012 23:58
harsh php vibes
$ perl -e 'print "cool" && "bro"'; echo
bro
$ python -c 'print "cool" and "bro"'
bro
$ node -e 'console.log("cool" && "bro")'
bro
$ php -r 'print "cool" && "bro";'; echo
@kevinw
kevinw / gist:2364414
Created April 12, 2012 03:12
v8Js segfault with nested callbacks
<?php
$v8=new v8Js('SERVER');
$v8->serverCb = function($cb) { return call_user_func_array($cb, array(1,2,3))."42"; };
$v8->log = function($msg) { print $msg; };
for ($i =0; $i < 10; ++$i) {
$v8->executeString("var res = SERVER.serverCb(function() {return 'fromJSCB' }); SERVER.log(res); ");
}
bike to sausalito
Script started on Wed Apr 13 13:25:23 2011
bash-3.2$ tmux
7[?47h[?1l>[?1000l]0;4:0:reattach-to-user-namespace - "kevin-watterss-macbook-pro.local"








Twenty years after my own graduation, I have come gradually to understand that the liberal arts cliché about teaching you how to think is actually shorthand for a much deeper, more serious idea: learning how to think really means learning how to exercise some control over how and what you think. It means being conscious and aware enough to choose what you pay attention to and to choose how you construct meaning from experience. Because if you cannot exercise this kind of choice in adult life, you will be totally hosed.

I’d read Poul Henning Kamp’s amusing ‘what’s wrong with 1975 programming‘ rant (also, take a gander at this unrelated but good article by the same chap) and suddenly had a brainwave: linux implements ‘copy on write’ semantics for memory blocks when a process forks. That means that my database could just ‘fork’ when it wanted to save a checkpoint. The child process gets an unchanging copy of all of the memory, just for the cost of a page-table copy in the OS; any writes in the parent process just cause the OS to do all the work for us, and duplicate the pages that are changing. The child can checkpoint at its leisure.

>>> '%d' % 2.0
'2'
>>> '{0:d}'.format(2.0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Unknown format code 'd' for object of type 'float'
# -----------------------------------------------------------------------------
# f i l e B a s e O f ( ) -- Return base name of filename --
# ^^^^^^^^^^^^^^^^^^^^^^^
#
def fileBaseOf(filename,withPath=0) :
pos = filename.rfind('.')
if pos > 0:
def test_subthread_delete():
app = wx.GetApp()
t, t2 = wx.Timer(), wx.Timer()
t.t = t2
t2.t = t
timers = [t, t2]
del t, t2
from threading import Thread
def subthread():