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 / index_ocr.py
Created January 23, 2017 16:30
Read index with python cv2 and tesseract as OCR engine
#!/usr/bin/env python
import pytesseract
import Image
import cv2
# some func
def click_prt_pix_color(event, x, y, flags, param):
if event == cv2.EVENT_LBUTTONDOWN:
print('pixel(%d, %d) color is %s' % (x, y, img[y, x]))
@sourceperl
sourceperl / neural_1.py
Created January 16, 2017 14:29
Some neural network test with Python
#!/usr/bin/env python2
import numpy as np
# sigmoid function (return 0.0 to 1.0 for -inf to +inf value)
def sigmoid(x):
return 1 / (1 + np.exp(-x))
@sourceperl
sourceperl / echo.py
Created January 6, 2017 07:21
QR code tools
#!/usr/bin/env python3
import os
import sys
if __name__ == '__main__':
for line in sys.stdin:
sys.stdout.write(line)
if 'keyword1' in line:
print('play bip 1')
#!/usr/bin/env python3
# particle simulator on python3 with tk
import tkinter as tk
import math
class Particle(object):
def __init__(self, x, y, size=2, color='saddle brown'):
@sourceperl
sourceperl / detect_tones.py
Last active January 9, 2023 05:37
Display sound spectral view with scipy FFT and matplotlib
#!/usr/bin/python3
# detect tones in sound spectrum with scipy FFT
# here sound source is a USB microphone with ALSA (channel 1)
from collections import deque
import struct
import sys
import time
import threading
@sourceperl
sourceperl / tree_grow.py
Created December 19, 2016 12:37
Tree grow simulator on python3 with tk
#!/usr/bin/env python3
# tree grow simulator on python3 with tk
import tkinter as tk
from random import randint
from enum import Enum
class TreePart(Enum):
@sourceperl
sourceperl / check_tspeak.py
Last active December 7, 2016 09:56
Check a thingspeak feed is update
#!/usr/bin/env python3
import http.client
import dateutil.parser
import datetime
import time
import json
ZERO = datetime.timedelta(0)
@sourceperl
sourceperl / mygraph.py
Last active November 15, 2016 16:32
Python/Tk graph plotter test
#!/usr/bin/env python3
from tkinter import *
from random import randint
from collections import deque
from itertools import chain
class CanGraph(Canvas):
def __init__(self, master, **options):
@sourceperl
sourceperl / client.py
Last active March 18, 2022 20:22
Simple key/value store with json and python flask
#!/usr/bin/env python3
import http.client
import json
connection = http.client.HTTPConnection('localhost', port=5000)
headers = {'Content-type': 'application/json'}
connection.request('GET', '/set/foo?value=474', headers=headers)
response = connection.getresponse().read()
@sourceperl
sourceperl / redis_test.php
Created November 2, 2016 11:57
Simple example of Redis usage with PHP
<!DOCTYPE html>
<?php
require 'Predis/Autoloader.php';
Predis\Autoloader::register();
$r = new Predis\Client();
?>
<html>
<head>
<title>Test REDIS</title>
</head>