Skip to content

Instantly share code, notes, and snippets.

View cablehead's full-sized avatar

Andy Gayton cablehead

View GitHub Profile
insert/s query/s update/s delete/s getmore/s command/s mapped vsize res % locked % idx miss conn time
1647 32 74 0 1 45 17050 116046 12357 1.7 0 9536 21:49:33
919 24 68 0 2 32 17050 116076 12357 0.853 0 9539 21:49:34
1118 15 76 0 2 53 17050 116116 12357 0.83 0 9542 21:49:35
865 13 38 0 2 25 17050 116106 12357 0.812 0 9540 21:49:36
2003 13 58 0 3 63 17050 116066 12357 0.913 0 9535 21:49:37
3949 26 68 0 1 84 17050 116006 12357 0.975 0 9532 21:49:38
1391 24 87 0 1 62 17050 116056 12357 0.812 0 9537 21:49:40
2908 30 89 0 0 87 17050 116086 12357 1.66 0 9540 21:49:41
import pymongo
import time
servers = ['mongo1', 'mongo2']
master = pymongo.Connection(servers)
print "MASTER is: %s" % master.host
slave = pymongo.Connection(
[x for x in servers if x != master.host][0], slave_okay=True)
<script id="tmpl_locations" type="text/x-jquery-tmpl">
{%templatetag openvariable%}each locations{%templatetag closevariable%}
<tr>
<td><a href="${slug}">${name}</a></td>
<td><a href="${slug}">${address}</a></td>
<td>${roundto2(latlng[0])}, ${roundto2(latlng[1])}</td>
<td>${roundto2(distance)}</td>
</tr>
{%templatetag openvariable%}/each{%templatetag closevariable%}
</script>
<script id="tmpl_locations" type="text/x-jquery-tmpl">
{%templatetag openvariable%}each locations{%templatetag closevariable%}
<tr>
<td><a href="${slug}">${name}</a></td>
<td><a href="${slug}">${address}</a></td>
<td>${roundto2(latlng[0])}, ${roundto2(latlng[1])}</td>
<td>${roundto2(distance)}</td>
</tr>
{%templatetag openvariable%}/each{%templatetag closevariable%}
</script>
<script type="text/javascript">
alert('running');
</script>
sudo defaults write com.apple.screencapture location $HOME/Desktop/Screenshots
killall -HUP SystemUIServer
[color]
branch = auto
diff = auto
status = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
# autoreconnect handling
def autoreconnect(f, *a, **kw):                                                                
   max_tries = 12                                                                              
   num_tries = 1                                                                              
   while True:                                                                                
       try:
           return f(*a, **kw)
       except pymongo.errors.AutoReconnect, e:                                                
           logging.warning(
               'MONGO-AUTORECONNECT attempt=%s' % num_tries, exc_info=True)                    
from diffmatchpatch import diff_match_patch
DMP = diff_match_patch()
def diff(a, b):
diffs = DMP.diff_main(a, b)
if len(diffs) > 2:
DMP.diff_cleanupEfficiency(diffs)
if len(diffs) > 0:
delta = DMP.diff_toDelta(diffs)
import base64
from diffmatchpatch import diff_match_patch
DMP = diff_match_patch()
def diff(a, b):
a = base64.b64encode(a.encode('utf-8'))
b = base64.b64encode(b.encode('utf-8'))
diffs = DMP.diff_main(a, b)
if len(diffs) > 2: