This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: class O(object): | |
...: def _neco(self, param): | |
...: return param | |
...: def __init__(self, *args, **kwargs): | |
...: self.something = s = {} | |
...: for a,b in [(1,10),(2,20),(3,30)]: | |
...: s[a] = lambda: self._neco(b) | |
...: | |
In [2]: o = O() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
class MyFirstTest < Test::Unit::TestCase | |
def test_for_truth | |
assert true | |
end | |
def test_multiplying | |
assert_equal 4, 2*2 | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
H=192.168.1.10 | |
[[ $1 ]] && H=$1 | |
while true; do | |
sleep 5 | |
ping -W3 -c1 $H &>/dev/null && continue | |
echo "`date` - restarting wifi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TMP_HUBOT=/tmp/blah | |
MY_HUBOT=/tmp/realhubot | |
# temporary hubot | |
mkdir $TMP_HUBOT | |
cd $TMP_HUBOT | |
npm install hubot coffee-script | |
# init custom hubot | |
./node_modules/.bin/coffee ./node_modules/.bin/hubot --create $MY_HUBOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dump_utc_datetime(x): | |
return ( | |
x.year, x.month, x.day, | |
x.hour, x.minute, x.second, | |
x.microsecond | |
) | |
def load_utc_datetime(x): | |
d = datetime.datetime(*x) | |
return d.replace(tzinfo=pytz.utc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bb = require('./bonescript'); | |
var ledPin0 = bone.USR3; | |
var ledPin1 = bone.P8_3; | |
var ledPin2 = bone.P8_5; | |
var ledPin3 = bone.P8_7; | |
setup = function() { | |
pinMode(ledPin0, OUTPUT); | |
pinMode(ledPin1, OUTPUT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in `seq 0 3`; do | |
echo 0 > /sys/devices/platform/leds-gpio/leds/beaglebone::usr$i/brightness | |
done | |
echo 1 > /sys/devices/platform/leds-gpio/leds/beaglebone::usr0/brightness | |
sleep 0.2s | |
echo 0 > /sys/devices/platform/leds-gpio/leds/beaglebone::usr0/brightness | |
echo 1 > /sys/devices/platform/leds-gpio/leds/beaglebone::usr2/brightness | |
sleep 0.3s | |
echo 0 > /sys/devices/platform/leds-gpio/leds/beaglebone::usr2/brightness |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import time | |
LED = '/sys/devices/platform/leds-gpio/leds/beaglebone::usr%d/%s' | |
def _write(dev, mode='brightness', val=1, sleep=0): | |
s = open(LED % (dev, mode), 'w') | |
s.write(str(val)) | |
s.close() | |
time.sleep(sleep) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ! [[ $EXPORTED_SSH_AUTH_SOCK ]]; then | |
# save ssh vars on connection to the box | |
echo "export SSH_AUTH_SOCK=$SSH_AUTH_SOCK" > ~/ssh-export-agent | |
echo 'export EXPORTED_SSH_AUTH_SOCK=$SSH_AUTH_SOCK' >> ~/ssh-export-agent | |
export EXPORTED_SSH_AUTH_SOCK=$SSH_AUTH_SOCK | |
else | |
# or just include already saved values | |
source ~/ssh-export-agent | |
fi |