Skip to content

Instantly share code, notes, and snippets.

@guyromm
guyromm / rps.py
Created March 7, 2011 17:08
socket.io flask route
@app.route('/socket.io/websocket')
def socketio():
s = request.environ['socketio']
if s.on_connect():
#print 'CONNECTED', locals()
#s.send({'buffer': buffer})
#s.broadcast({'announcement': s.session.session_id + ' connected'})
pass
game_id=None;game=None;cook=None;i_am='spectator';rdsub = redis.Redis('localhost')
while True:
@victorbstan
victorbstan / .vimrc
Created September 22, 2011 17:01
My .vimrc setup
autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=700
@wolever
wolever / gevent_issues.md
Created May 28, 2012 18:24
Some issues we've encountered with gevent

Below are some issues we encountered during our first real deployment of gevent. It is being used on one host to communicate over ethernet (ie, using raw ethernet packets) with approximately 700 PIC32 microprocessors, and it is used for communication between all of the services we have built (approximately 15 unique services running on two hosts).

  • The majority of the issues we faced were caused by a particular service which communicates with a child process over stdin/stdout. Not all of the issues were gevent specific (for example, when the child wasn't properly selecting on stdout, the kernel was silently dropping data when its internal buffer filled up, even though fwrite reported that the data had been written).
  • We are using gevent-0.13.7 with libevent-2.0.x. I would like to be using gevent-1.0, but it was causing some issues (I don't recall exactly what they were) on OS X, so we rolled back to 0.13.7.
  • libevent-1.4.13-stable (packages with Debian stable 6.0.4) would, under moderate l
@jboner
jboner / latency.txt
Last active May 17, 2024 01:05
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@wolever
wolever / media_link.py
Created July 3, 2012 20:09
Links to Django media files, including mtime for cache busting
@josephwecker
josephwecker / new_bashrc.sh
Created August 11, 2012 04:36
Replace .bashrc, .bash_profile, .profile, etc. with something much more clean, consistent, and meaningful. Now a repo: https://github.com/josephwecker/bashrc_dispatch
#!/bin/bash
# License: Public Domain.
# Author: Joseph Wecker, 2012
#
# -- DEPRICATED --
# This gist is slow and is missing .bashrc_once
# Use the one in the repo instead! https://github.com/josephwecker/bashrc_dispatch
# (Thanks gioele)
#
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile?
@jaseg
jaseg / gist:3334991
Created August 12, 2012 22:32
Password manager without a password manager

Prelude

Since password managers are big and complicated and I currently am pretty bored since I am sitting in a car for a few hours, here is a simple algorithm to generate resource-specific, unique passwords using a master password and no password database.

WARNING

As pointed out here: http://news.ycombinator.com/item?id=4374888 this method is broken.

Usage

@aaronblohowiak
aaronblohowiak / gist:3932768
Created October 22, 2012 17:23
RedisConf Notes Part I
Redisconf Notes:
"We will begin this morning with a performance"
"Is this a key store..." Bohemian Rhapsody Key/Value Store ballad. Epic Win!
"Any way the data flows doesn't really matter to me... flushdb..."
"Lua killed a db by writing after calling a nondeterministic function..."
"Got to leave SQL behind and face the truth..."
"Redis, I don't want to join, sometimes I wish I'd never described a query..."
"The ZSET has some data set aside for me, for me, for MEEEEEEE"
@klange
klange / _.md
Last active December 2, 2023 20:36
It's a résumé, as a readable and compilable C source file. Since Hacker News got here, this has been updated to be most of my actual résumé. This isn't a serious document, just a concept to annoy people who talk about recruiting and the formats they accept résumés in. It's also relatively representative of my coding style.

Since this is on Hacker News and reddit...

  • No, I don't distribute my résumé like this. A friend of mine made a joke about me being the kind of person who would do this, so I did (the link on that page was added later). My actual résumé is a good bit crazier.
  • I apologize for the use of _t in my types. I spend a lot of time at a level where I can do that; "reserved for system libraries? I am the system libraries".
  • Since people kept complaining, I've fixed the assignments of string literals to non-const char *s.
  • My use of type * name, however, is entirely intentional.
  • If you're using an older compiler, you might have trouble with the anonymous unions and the designated initializers - I think gcc 4.4 requires some extra braces to get them working together. Anything reasonably recent should work fine. Clang and gcc (newer than 4.4, at le