View TypedCsvDict.py
from csv import DictReader,DictWriter
# originally from pygramel
class TypedDictReader(DictReader):
"""A class for iterating a CSV file and type cast the values."""
def __init__(self, csvfile, casts, fieldnames=None, restkey=None,
restval=None, dialect='excel', *args, **kwds):
"""Arguments:
- f: An iterable object such as as file. Passed on to
View plot2terminal.py
import sys
import numpy as np
import json
import base64
import StringIO
import matplotlib.pyplot as plt
import sys
#https://www.iterm2.com/utilities/imgls
def encode_iterm2_image(data,height=None):
View catls.py
import base64
import sys
#https://www.iterm2.com/utilities/imgls
def encode_iterm2_image(data,height=None):
if height is None:
height = "auto"
else:
height = "%spx" % height
return ("\x1B]1337;File=loss.jpg;width=auto;height=%s;inline=1;size=%dpreserveAspectRatio=1:" % (height,len(data))) + base64.b64encode(data)
View udptunnel.sh
# Only for remote UDP https://stackpointer.io/network/ssh-port-forwarding-tcp-udp/365/
# Local UDP server to Remote UDP server
ssh -L 9999:127.0.0.1:9999 percro@alientelecom socat tcp4-listen:9999,reuseaddr,fork udp:target:9999
socat -T15 udp4-recvfrom:9999,reuseaddr,fork tcp:localhost:9999
# Remote UDP server to Local UDP server
ssh -R 9999:127.0.0.1:9999 percro@alientelecom socat udp4-recvfrom:9999,reuseaddr,fork tcp:localhost:9999
socat -T15 tcp4-listen:9999,reuseaddr,fork udp:localhost:9999
View ws2udp_bridge.py
# WS Server - UDP Server
# Taken online, refactored
#
# Emanuele Ruffaldi 2017
import time, sys, os, pkg_resources
import SocketServer
from twisted.python import log
from twisted.internet import reactor
View datawithpayload.cpp
#include <stdint.h>
#include <boost/interprocess/sync/interprocess_mutex.hpp>
#include <boost/interprocess/sync/interprocess_condition.hpp>
#include <vector>
#include <iostream>
#include <tuple>
// header
struct ImageHeader
{
View videocapture_cvimageio.py
import cv2
import sys
try:
import imageio
except:
print "missing imageio"
imageio = None
try:
View build
#updated from https://gist.github.com/kilfu0701/47b74a17a70b43549985
brew install qt5
brew install pyqt5 # for python 3.6
## download SIP source code
wget http://sourceforge.net/projects/pyqt/files/sip/sip-4.19.3/sip-4.19.3.tar.gz
tar zxf sip-4.19.3.tar.gz
cd sip-4.19.3
python configure.py
make
View extract_pdf_annotations_two.py
from pdfminer.pdfparser import PDFParser
from pdfminer.pdfdocument import PDFDocument
from pdfminer.pdftypes import PDFObjectNotFound
import sys
def extract(objid, obj,pages,anno,marked):
if isinstance(obj, dict):
# 'Type' is PDFObjRef type
if obj.has_key('Type') and obj['Type'].name == 'Page':
pages.append(objid)
elif obj.has_key('C'):
View pypdf_sidebyside.py
from PyPDF2 import PdfFileWriter, PdfFileReader
import sys
in1,in2,out = sys.argv[1:]
output = PdfFileWriter()
input1 = PdfFileReader(file(in1, "rb"))
input2 = PdfFileReader(file(in2, "rb"))
m = min(input1.getNumPages(),input2.getNumPages())