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
c:\users>pokus.py | |
128 | |
c:\users>pokus.bat | |
128 | |
c:\users>run.py | |
c:\users> |
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
from django.core.management.base import BaseCommand | |
from optparse import make_option | |
class Command(BaseCommand): | |
help = 'load all the data and do stuff to make site work' | |
option_list = BaseCommand.option_list + ( | |
make_option('--input', action='store_true', dest='interactive', default=False, | |
help='force Django to prompt the user for input of any kind'), |
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
# this is example from raymond, it is because LoggingDict and OrderedDict both subclasses dict:: | |
>>> import pprint, collections | |
>>> class LoggingDict(dict): pass | |
>>> class LoggingOD(LoggingDict, collections.OrderedDict): pass | |
>>> pprint.pprint(LoggingOD.__mro__) | |
(<class '__main__.LoggingOD'>, | |
<class '__main__.LoggingDict'>, | |
<class 'collections.OrderedDict'>, |
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 |
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
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
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
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
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
#!/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" |
OlderNewer