Skip to content

Instantly share code, notes, and snippets.

View viewpointsa's full-sized avatar

viewpointsa

  • ViewPoint
  • Lyon - France
View GitHub Profile
@viewpointsa
viewpointsa / xsltproc.vbs
Created May 4, 2022 13:54
VBscript XLST process
' https://stackoverflow.com/a/56497728/2137364
Sub XSLTransform( inputXml, inputXsl )
' REFERENCE Microsoct XML, v6.0
Set xmlDoc = CreateObject("Msxml2.DOMDocument.6.0")
Set xslDoc = CreateObject("Msxml2.FreeThreadedDOMDocument.6.0")
Set xslTemp = CreateObject("Msxml2.XSLTemplate.6.0")
Dim xslProc
' LOAD XML AND XSL FILES
import cv2
import numpy as np
cameraMatrix = np.array([
2117.598861472505,
0.0,
517.602819121056,
0.0,
2117.6945788309686,
647.6170255017,
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,
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 April 16, 2019 12:38
Dialog Arduino Mkrfox 1200 with RTC3231
/*
^ DS3231 ^Arduino ^
| SCL | 12 SCL |
| SDA | 11 SDA |
| VCC | VCC |
| GND | GND |
*/
#include "Wire.h"
#define DS3231_I2C_ADDRESS 0x68
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Validation CalcDiffMean"
]
},
{
@viewpointsa
viewpointsa / xslt.py
Created March 1, 2019 09:45
python XSLT processing XML
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 February 27, 2019 10:37
Copy table from postgresql database to another
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
#/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';"