This file contains hidden or 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 | |
SOCKDIR="/var/lib/qemu/sockets" | |
HOSTNAME="$1" | |
if [ -z "$HOSTNAME" ] | |
then | |
echo "usage: $0 HOSTNAME" >&2 | |
exit 1 | |
fi |
This file contains hidden or 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 functools import wraps | |
from types import FunctionType, GeneratorType | |
import logging | |
import time | |
def coroutine(f): | |
@wraps(f) | |
def wrapper(*args, **kwargs): | |
logging.debug('coroutine starting: {}'.format(f.__name__)) | |
return f(*args, **kwargs) |
This file contains hidden or 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 ipaddr import IPv4Network, IPv4Address | |
""" | |
A module to sort ip addresses according to the best-match | |
in an ip networks list. If no matching network is found, ip | |
is sorted last. | |
example: | |
>>> networks = ['10.0.0.0/8', '172.16.0.0/12', '172.16.9.0/24'] |
This file contains hidden or 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
import asyncio | |
import random | |
queue = asyncio.Queue() | |
@asyncio.coroutine | |
def feeder(): | |
try: | |
fid = random.randint(100, 999) | |
print('feeder {} activated'.format(fid)) |
This file contains hidden or 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
pip install git+https://github.com/USER/REPO.git |
This file contains hidden or 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/bash | |
name="$(basename $0)" | |
echo "$name" | |
if [[ "$name" =~ serialsh-(tty[a-zA-Z0-9]+)(-([0-9]+))? ]]; then | |
tty="${BASH_REMATCH[1]}" | |
speed="${BASH_REMATCH[3]}" | |
exec screen -dR "serialsh-${tty}" "/dev/${tty}" $speed | |
else | |
echo "usage: $0" | |
echo "symlink this file as serialsh-tty0 to access tty0" |
This file contains hidden or 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/bash -u | |
usage() | |
{ | |
echo "usage: $0 [OPTIONS] DEVICE [DEVICE...]" | |
echo | |
echo "Options:" | |
echo " -s|--smart do a smart short test" | |
echo " -e|--smarterrors do a smart errors test" | |
echo " -d|--devstat do a smart devstat test" |
This file contains hidden or 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
import re | |
def mac_to_int(mac): | |
res = re.match('^((?:(?:[0-9a-f]{2}):){5}[0-9a-f]{2})$', mac.lower()) | |
if res is None: | |
raise ValueError('invalid mac address') | |
return int(res.group(0).replace(':', ''), 16) | |
def int_to_mac(macint): | |
if type(macint) != int: |
This file contains hidden or 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
intermediate-state-file: | |
file.managed: | |
- name: /etc/.intermediate_state_file | |
- contents: {{ salt['hashutil.sha256_digest'](salt['pillar.get']('my_pillar')|string) }} | |
my-cmd-1: | |
cmd.wait: | |
- name: "echo a command you want to run only when a my_pillar changes, but without storing it raw on the host" | |
- watch: | |
- file: intermediate-state-file |
This file contains hidden or 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
#include <math.h> | |
/* PWM fan control for arduino */ | |
const int rlyPin = 3; // digital 3 (optional relay) | |
const int pwmPin = 4; // digital 4 (connected to fan pwm pin) | |
const int ctrPin = A5; // analog 5 (connected to potentiometer measurement pin) | |
const int tempPin = A6; // analog 6 (connceted to temperature probe) | |
const int runCycles = 10000; // check new value every 10k cycles (2/sec) | |
const uint32_t cycleDuration = 50; // 50us for 20kHz |
OlderNewer