Skip to content

Instantly share code, notes, and snippets.

View sourceperl's full-sized avatar

l.lefebvre sourceperl

  • Hauts-de-France
View GitHub Profile
@sourceperl
sourceperl / propfind_request.py
Last active January 10, 2023 13:49
Python custom WebDAV PROPFIND on an owncloud server with requests HTTP library
#!/usr/bin/env python3
from xml.dom import minidom
import requests
# some consts
HTTP_MULTI_STATUS = 207
PROPFIND_REQUEST = '''<?xml version="1.0" encoding="utf-8" ?>
<d:propfind xmlns:d="DAV:">
<d:prop xmlns:oc="http://owncloud.org/ns">
<d:getlastmodified/>
@sourceperl
sourceperl / co2_view.py
Last active November 15, 2019 14:37
CO2 concentrations view and polynomial predict with matplotlib, pandas and numpy
#!/usr/bin/env python3
# pandas example with CSV data from atmospheric CO2 concentrations (ppm) at Mauna Loa, Observatory, Hawaii
# display current value with matplotlib
# try to predict future values with 2nd order polynomial coefficients auto-adjust
# test with numpy==1.16.2, pandas==0.19.2
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
@sourceperl
sourceperl / pure_py_dft.py
Last active June 21, 2019 14:51
Sample compute of a DFT (Discrete Fourier Transform) with pure python code (without numpy usage)
#!/usr/bin/env python3
# sample compute of a DFT (Discrete Fourier Transform) with pure python code (without numpy usage)
from cmath import exp
from math import pi, sin
import random
def dft(samples):
xl = [0.0] * len(samples)
@sourceperl
sourceperl / surface3d_valve_flow.py
Created June 10, 2019 13:21
3d graph of control valve dynamic (flow vs pressure/valve travel)
#!/usr/bin/env python3
# play with cv ( coefficient of flow) of control valve
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
# some const (see http://www.idealvalve.com/pdf/Flow-Calculation-for-Gases.pdf)
SG = 0.554
@sourceperl
sourceperl / fly-build-csv
Last active April 11, 2019 14:56
flyspray CSV export tool
#!/bin/sh
# populate pub/ http directory with flyspray CSV export
# copy this script to /etc/cron.weekly
# csv file build name
YEAR=$(date +%Y)
CSV_FILE=export_$YEAR.csv
/usr/local/bin/flyspray2csv > /var/www/html/pub/flyspray/$CSV_FILE
@sourceperl
sourceperl / ttn-build-key
Last active October 30, 2018 10:49
TTN utils
#!/usr/bin/env python3
import random
key8 = ''.join(random.choice('0123456789ABCDEF') for n in range(16))
key16 = ''.join(random.choice('0123456789ABCDEF') for n in range(32))
print("generate 8 bytes key: %s" % key8)
print("generate 16 bytes key: %s" % key16)
@sourceperl
sourceperl / square_fft.py
Last active April 2, 2018 12:34
Square wave FFT
#!/usr/bin/env python3
# build a square signal from sum of sin
import matplotlib.pyplot as plt
import numpy as np
from scipy import signal
# number of samples
Ns = 2000
@sourceperl
sourceperl / pi-desktop-manager
Last active March 29, 2018 17:50
Pi Desktop manager
#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
import os, sys
import signal
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(31, GPIO.OUT)
@sourceperl
sourceperl / lille_view_park.py
Created February 9, 2018 14:44
Python request of parking availability of the city of Lille (from MEL opendata platform)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import dateutil.parser
import requests
import pandas as pd
import datetime
# some consts
NAN = float('nan')
@sourceperl
sourceperl / rn2483_rx.py
Created January 24, 2018 16:41
RN2483 LoRa point to point test
#!/usr/bin/env python3
# RN2483 point to point test
# open serial link, init and display rx frames
import argparse
import serial
# some functions
def send_cmd(cmd):