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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
''' | |
longqi 13/Feb/16 17:35 | |
Discription: | |
''' | |
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 subprocess import check_output | |
import sys | |
import re | |
if sys.platform == 'darwin': | |
ip0 = check_output(['ip', 'addr', 'show', 'en0']) | |
else: | |
ip0 = check_output(['ip', 'addr', 'show', 'eth0']) | |
ip1 = re.search('inet\s.*(?=/)', str(ip0)) |
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 socket | |
import struct | |
import select | |
# CAN frame packing/unpacking (see 'struct can_frame' in <linux/can.h>) | |
can_frame_fmt = "=IB3x8s" | |
can_frame_size = struct.calcsize(can_frame_fmt) | |
def build_can_frame(can_id, data): |
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 socket, select | |
EOL1 = b'/n/n' | |
EOL2 = b'/n/r/n' | |
response = b'HTTP/1.0 200 OK/r/nDate: Mon, 1 Jan 1996 01:01:01 GMT/r/n' | |
response += b'Content-Type: text/plain/r/nContent-Length: 13/r/n/r/n' | |
response += b'Hello, world!' | |
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
serversocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import errno | |
import functools | |
import tornado.ioloop | |
import socket | |
import struct | |
can_frame_fmt = "=IB3x8s" |
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 multiprocessing import Process | |
# import os | |
# | |
# | |
# def info(title): | |
# print(title) | |
# print('module name:', __name__) | |
# print('parent process:', os.getppid()) | |
# print('process id:', os.getpid()) | |
# |
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
# !/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
from PyQt4.QtCore import * | |
from PyQt4.QtGui import * | |
class overlay(QWidget): | |
def __init__(self, parent=None): | |
super(overlay, self).__init__(parent) |
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
# !/usr/bin/env python | |
# embedding_in_qt4.py --- Simple Qt4 application embedding matplotlib canvases | |
# | |
# Copyright (C) 2005 Florent Rougon | |
# 2006 Darren Dale | |
# | |
# This file is an example program for matplotlib. It may be used and | |
# modified with no restriction; raw copies as well as modified versions | |
# may be distributed without limitation. |
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
# !/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
import numpy as np | |
import random | |
import matplotlib | |
matplotlib.use("Qt4Agg") | |
from matplotlib.backends import qt_compat |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from PyQt4 import QtGui | |
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas | |
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar | |
import matplotlib.pyplot as plt | |
import sys | |
import random |