Skip to content

Instantly share code, notes, and snippets.

View catwell's full-sized avatar

Pierre Chapuis catwell

View GitHub Profile
@catwell
catwell / lua-global-lookups.lua
Created May 2, 2011 11:26
Lua global lookups overhead
-- do global lookups matter?
require "os"
f = function() return end
run = function(n)
start = os.clock()
for i=1,n do f() end
stop = os.clock()
return (stop - start)
@catwell
catwell / unix-tools.txt
Created May 6, 2011 14:40
Every Unix machine should have...
tree
moreutils
most
slurm
htop
mtr
multitail
iftop
ack
@catwell
catwell / about.md
Created August 9, 2011 14:58 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@catwell
catwell / ktlk
Created August 26, 2011 14:23
Karl talk
Le Web est un système complexe. Certaines erreurs d'implémentation se propagent vite, les développeurs les utilisant. Les implémenteurs de clients Web (navigateurs inclus) doivent hacker pour coller à la réalité du Web tel que pratiqué. Nous verrons ensemble pourquoi les navigateurs implémentent parfois différement de ce que préconise le standard, comment les standards ont évolué pour être plus proches de la réalité et ce que les développeurs peuvent faire pour éviter que les bugs se propagent avec quelques techniques de développement.
@catwell
catwell / bench.lua
Created October 18, 2011 20:11
Redis Scripting speed
require "redis"
local WMAX = 100000
local rc = Redis.connect("unix:///tmp/redis.sock")
local rs_mhset = [[
local keys,argv,rcall = KEYS,ARGV,redis.call
local n,f = 0,argv[#keys+1]
for i,k in ipairs(keys) do n = n + rcall("hset",k,f,argv[i]) end
return n
@catwell
catwell / gist:1316396
Created October 26, 2011 13:47
Tokyo Cabinet Makefile extract
check-forever :
while true ; \
do \
make check || break ; \
make check || break ; \
make check-thread || break ; \
make check-race || break ; \
make check-race || break ; \
make check-compare || break ; \
make check-compare || break ; \
@catwell
catwell / cmso.js
Created November 20, 2011 19:47
CMSO script
function resize() {
try {
var hauteur=450;
var doc="";
if(nav.indexOf('Opera')==-1) {
if(document.all) {
doc=document.all.mainframe;
if(nav.indexOf('Mac')!=-1) {
@catwell
catwell / as-black-magic
Created January 25, 2012 18:27
ActiveSupport Black Magic
[~ 19:35] irb -r'active_support/core_ext'
ruby-1.9.2-p136 :001 > "x".as_json
NoMethodError: undefined method `as_json' for "x":String
from (irb):1
from /Users/pierre/.rvm/rubies/ruby-1.9.2-p136/bin/irb:16:in `<main>'
ruby-1.9.2-p136 :002 > "y".to_json
=> ""y""
ruby-1.9.2-p136 :003 > "x".as_json
=> "x"
@catwell
catwell / listzip.py
Created March 19, 2012 10:58
List parts of Zip file (Python)
from zipfile import ZipFile,ZIP_DEFLATED,ZIP_STORED
from sys import argv
with ZipFile(argv[1],"r") as x:
for y in x.infolist():
if y.compress_type == ZIP_DEFLATED:
print y.filename + " deflated"
elif y.compress_type == ZIP_STORED:
print y.filename + " stored"
else:
@catwell
catwell / gist:2237358
Created March 29, 2012 13:12
ESR quote
Constantly asking for confirmation where the answer is almost always
“yes” conditions the user to press “yes” without thinking about it, a
habit that can have very unfortunate consequences. Programs should
request confirmation only when there is good reason to suspect that the
answer might be “no no no!” A confirmation request that is not a
surprise is a strong hint of bad design. Any confirmation prompts at all
may be a sign that what your interface really needs is an undo command.
-- Eric S. Raymond