Skip to content

Instantly share code, notes, and snippets.

Avatar

viewpointsa

  • ViewPoint
  • Lyon - France
View GitHub Profile
View undistortPoints.py
import cv2
import numpy as np
cameraMatrix = np.array([
2117.598861472505,
0.0,
517.602819121056,
0.0,
2117.6945788309686,
647.6170255017,
View publish.py
import paho.mqtt.client as mqtt
import sys
import json
from random import random
import ssl
import os
# This is the Publisher
data = json.dumps({
'temperature' : random() * 20.0,
View checksymlink
View mygzip.py
import struct, time, zlib
def generate_gzip():
# Migration Python2 to 3 https://stackoverflow.com/a/44387566/2137364
# Yield a gzip file header first.
yield (
b'\037\213\010\000' + # Gzip file, deflate, no filename
struct.pack('<L', int(time.time())) + # compression start time
b'\002\377' # maximum compression, no OS specified
)
@viewpointsa
viewpointsa / ArduinoMkrfox1200RTC3231.uno
Created Apr 16, 2019
Dialog Arduino Mkrfox 1200 with RTC3231
View ArduinoMkrfox1200RTC3231.uno
/*
^ DS3231 ^Arduino ^
| SCL | 12 SCL |
| SDA | 11 SDA |
| VCC | VCC |
| GND | GND |
*/
#include "Wire.h"
#define DS3231_I2C_ADDRESS 0x68
View gist:4f7cea0cdb969fadc038adab0f3cf0eb
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Validation CalcDiffMean"
]
},
{
@viewpointsa
viewpointsa / xslt.py
Created Mar 1, 2019
python XSLT processing XML
View xslt.py
import lxml.etree as ET
import argparse
parser = argparse.ArgumentParser(description='XSLT Transform XML file.')
parser.add_argument('xml', help='input xml file')
parser.add_argument('xsl', help='input xslt file')
parser.add_argument('-o', '--output', help='Output file')
args = parser.parse_args()
@viewpointsa
viewpointsa / bd_copy_table.py
Created Feb 27, 2019
Copy table from postgresql database to another
View bd_copy_table.py
import psycopg2
import argparse
def copy_table( connectionStringSrc, connectionStringDst, table_name, verbose=False, condition="" ):
with psycopg2.connect(connectionStringSrc) as connSrc:
with psycopg2.connect(connectionStringDst) as connDst:
query = "SELECT * FROM {} {};".format(table_name,condition)
with connSrc.cursor() as curSrc:
curSrc.execute( query )
print "Source number of rows =", curSrc.rowcount
View postgres import sql
#/bin/bash
if [ $# -ne 2 ]; then
echo $0: usage: myscript databasename zipfile
exit 1
fi
dbname=$1
psql --command "select pg_terminate_backend(procpid) from pg_stat_activity where datname = '$dbname';"
View gist:a3a1e42ea6809a1aabf208a8dd97128c
s = "0e59f1d5-1fbe-11d0-8ff2-00a0d10038bc"
#DEFINE_GUID(IID_IScriptControl, 0x8b167d60, 0x8605, 0x11d0,
# 0xab, 0xcb, 0x00, 0xa0, 0xc9, 0x0f, 0xff, 0xc0);
#"0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s" % ( s[0:8], s[9:13], s[14:18], s[19:21]
arr = [8,4,4,2,2,2,2,2,2,2,2]
print "DEFINE_GUID(IID_IXXX," + ','.join( map( lambda kv: '0x' + s.replace('-','')[ sum(arr[:kv[0]]) : sum(arr[:kv[0]]) + kv[1] ], enumerate(arr) ) ) + ");"