Skip to content

Instantly share code, notes, and snippets.

View andresdouglas's full-sized avatar

Andres Douglas andresdouglas

View GitHub Profile
@andresdouglas
andresdouglas / mongokit bug in find
Created March 18, 2011 05:38
mongokit is returning dictionaries instead of Document instances
(Pdb) p base_object_list
<mongokit.cursor.Cursor object at 0x101fc0dd0>
(Pdb) p base_object_list[0]
{u'rating': 7, u'_id': ObjectId('4d82eed3051df234ba000000'), u'name': u'andres'}
(Pdb) p type(base_object_list[0])
<type 'dict'>
(Pdb) p self
<bakodo.user_app.api.resources.MongokitTestResource object at 0x102314cd0>
(Pdb) p self._meta.object_class
<class 'user_app.mongokit_models.MongokitTestModel'>
cat Vagrantfile
user = ENV['OPSCODE_USER'] || ENV['USER']
base_box = ENV['VAGRANT_BOX'] || 'ubuntu-11.10-server-amd64'
Vagrant::Config.run do |config|
config.vm.define :web1dev do |config|
config.vm.box = base_box
config.vm.network('33.33.33.10')
config.vm.forward_port("http", 80, 8080)
config.vm.customize do |vm|
# Use a macro:
# https://gist.github.com/2149546
{% set deploy_path = '/var/django/reader.fm/revisions/' %}
# create deploy dir
{{ deploy_path }}:
file:
- directory
- makedirs: True

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