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 dict_diff1(first, second, NO_KEY='<KEYNOTFOUND>'): | |
""" Return a dict of keys that differ with another config object. If a value is | |
not found in one fo the configs, it will be represented by NO_KEY. | |
@param first: Fist dictionary to diff. | |
@param second: Second dicationary to diff. | |
@return diff: Dict of Key => (first.val, second.val) | |
""" | |
diff = {} | |
# Check all keys in first dict | |
for key in first.keys(): |
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
import crcmod.predefined | |
def _crc16(crc, c): | |
crc ^= ord(c) | |
for i in range(8): | |
if crc & 0x1: | |
crc = (crc >> 1) ^ 0xA001 | |
else: | |
crc = (crc >> 1) | |
return crc |
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
import re | |
import socket | |
import struct | |
import logging | |
import subprocess | |
from fcntl import ioctl | |
SIOCGIFMTU = 0x8921 | |
SIOCSIFMTU = 0x8922 |
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
class ConnectPythonLoggingToROS(logging.Handler): | |
MAP = { | |
logging.DEBUG:rospy.logdebug, | |
logging.INFO:rospy.loginfo, | |
logging.WARNING:rospy.logwarn, | |
logging.ERROR:rospy.logerr, | |
logging.CRITICAL:rospy.logfatal | |
} |
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
## | |
## http://emilics.com/blog/article/python_time.html | |
## http://www.saltycrane.com/blog/2008/11/python-datetime-time-conversions/ | |
###################################################################### | |
# CURRENT AWARE LOCAL DATETIME | |
###################################################################### | |
from datetime import datetime |
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
import argparse | |
import random | |
import glob | |
import os.path | |
import time | |
from gi.repository import Gio | |
class Changer: | |
def __init__(self, directory, interval): | |
self._pics = glob.glob(os.path.join(directory,"*.jpg")) |
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
#get the current directory. from | |
#http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in | |
pushd . > /dev/null | |
DIR="${BASH_SOURCE[0]}"; | |
if ([ -h "${DIR}" ]) then | |
while([ -h "${DIR}" ]) do cd `dirname "$DIR"`; DIR=`readlink "${DIR}"`; done | |
fi | |
cd `dirname ${DIR}` > /dev/null | |
DIR=`pwd`; | |
popd > /dev/null |
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/perl -w | |
#Salvaged from archive.org | |
#http://web.archive.org/web/20100309204315/http://www.lysium.de/blog/index.php?/archives/234-Plotting-data-with-gnuplot-in-real-time.html | |
#The input (on stdin or from a file) looks like this, as for the original version: | |
#0:0.09983 | |
#1:0.99500 | |
#2:0.69314 |
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
gst-launch-0.10 videotestsrc ! video/x-raw-yuv,format=\(fourcc\)I420,width=640,height=480,framerate=25/1 ! x264enc byte-stream=true ! filesink location=foo.mp4 |
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
import cv2 | |
import numpy as np | |
import scipy.ndimage.measurements | |
cv2.startWindowThread() | |
for iname,t in (("img",45),("img2",230), ("img3",230), ("img4",250)): | |
i = cv2.imread("%s.png" % iname) | |
cv2.namedWindow(iname) |
NewerOlder