Skip to content

Instantly share code, notes, and snippets.

View tychoish's full-sized avatar

Sam Kleinman tychoish

View GitHub Profile
.. code-block:: javascript
db.runCommand( { aggregate: "records",
pipeline: [ { $project: { amount:
{ $eq: [ "$42", { $literal: "$42" } ] } }
} ] } )
from unittest import TestCase
from core import ApplicationStage, ApplicationStageAlternate
class StagesBuildStepMultiAddTests(object):
def test_valid_test_harness(self):
self.assertEqual( self.jobs[0][1], 42 )
class TestStagesBuildStageMultiAdd(StagesBuildStepMultiAddTests, TestCase):
@classmethod
@tychoish
tychoish / gist:6064329
Created July 23, 2013 17:30
os x shell helpers for emacs daemon
EMACS_DAEMON=ed
emacs(){ /Applications/Emacs.app/Contents/MacOS/Emacs }
emacs-daemon(){ /Applications/Emacs.app/Contents/MacOS/Emacs --daemon=$EMACS_DAEMON }
eg(){ /Applications/Emacs.app/Contents/MacOS/bin/emacsclient -n -c --server-file=$EMACS_DAEMON $@ }
egt(){ /Applications/Emacs.app/Contents/MacOS/bin/emacsclient -t --server-file=$EMACS_DAEMON $@ }
@tychoish
tychoish / functions.lisp
Created July 6, 2013 17:57
stumpwm: notification function and dispay toggling
(defun notify (msg)
(run-shell-command (format nil "notify-send 'StumpWM' '~a'" msg)))
(defcommand conditional-restore-layout () ()
(when (> (list-length (screen-heads (current-screen))) 1)
(restore-desktop-office)
(notify "changed to multihead mode"))
(when (> (list-length (screen-heads (current-screen)) 1)
(restore-desktop-laptop)
(notify "changed to laptop mode"))))
replica-set-primary-with-two-secondaries
alt: "Diagram of default 3-member replica set architecture."
output:
- type: print
tag: '-print.png'
dpi: 300
width: 2100
- type: web
tag: '.png'
dpi: 72
BSONObj isWindows(const BSONObj& a, void* data) {
uassert( 13006, "isWindows accepts no arguments", a.nFields() == 0 );
#ifdef _WIN32
return BSON( "" << true );
#else
return BSON( "" << false );
#endif
}
@tychoish
tychoish / gist:1760608
Created February 7, 2012 16:42
stumpwm error
The index 1 is too large.
0: (SB-DEBUG::MAP-BACKTRACE
#<CLOSURE (LAMBDA # :IN SB-DEBUG:BACKTRACE) {B9DB265}>
:START
0
:COUNT
100)
1: (SB-DEBUG:BACKTRACE 100 #<SB-IMPL::STRING-OUTPUT-STREAM {B9DB211}>)
2: (STUMPWM::BACKTRACE-STRING)
3: (STUMPWM::PERFORM-TOP-LEVEL-ERROR-ACTION
ssh you@yourlinode "wget -O - -q https://api.linode.com/?api_key=$LINODE_API_KEY\&api_action=domain.resource.update\&domainid=$DOMAINID\&resourceid=$RESOURCEID\&target=\`echo \$SSH_CLIENT | cut -d' ' -f1\`"