Skip to content

Instantly share code, notes, and snippets.

@tuxmartin
tuxmartin / Test.py
Created June 10, 2015 21:54
Python ORM example (Python + SQLAlchemy + SQlite/MySQL)
from sqlalchemy.ext.declarative import declarative_base
#from sqlalchemy import *
#from sqlalchemy.orm import *
# Pro entity v podadresari. Podaresar *musi* obsahovat prazdny soubor __init__.py !
#from entity.User import User
'''
Zavislosti:
# apt-get install python-sqlalchemy
@tuxmartin
tuxmartin / socket_client.py
Last active April 11, 2020 20:38
Python socket - server and client example (push notifications)
import socket
host = 'localhost'
port = 1234
buf = 1024
clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
clientsocket.connect((host, port))
print "Sending 'test1\\n'"
@tuxmartin
tuxmartin / ESP8266.txt
Last active February 2, 2020 15:54
ESP8266 - co koupit + navod
# NodeMcu DevKit - doporucuji na pocatecni vyuku s ESP8266!!!
New Wireless module CH340 NodeMcu V3 Lua WIFI Internet of Things development board based ESP8266
http://www.aliexpress.com/item/NodeMcu-Lua-WIFI-development-board-based-on-the-ESP8266-Internet-of-things/32339203041.html
NodeMcu base ESP8266 testing DIY Breadboard
http://www.aliexpress.com/item/NodeMcu-base-ESP8266-testing-DIY-Breadboard/32457259665.html
#ESP8266 ESP07
@tuxmartin
tuxmartin / angee_kickstarter.py
Created September 23, 2015 13:16
Angee Kickstarter Notification
# http://raspi.tv/2014/programming-a-kickstarter-tracker-in-python-part-1
from urllib2 import Request, urlopen, URLError
from time import sleep
import subprocess
someurl = 'https://www.kickstarter.com/projects/tomtu/angee-the-first-truly-autonomous-home-security-sys'
old_percent= 0.0
@tuxmartin
tuxmartin / RFID_EEPROM.ino
Last active March 5, 2020 19:54
Arduino Mifare 13.56 MHz MFRC522 reader
/*
* Dump block 0 of a MIFARE RFID card using a RFID-RC522 reader
* Uses MFRC522 - Library to use ARDUINO RFID MODULE KIT 13.56 MHZ WITH TAGS SPI W AND R BY COOQROBOT.
-----------------------------------------------------------------------------
* Pin layout should be as follows:
* Signal Pin Pin Pin
* Arduino Uno Arduino Mega MFRC522 board
* ------------------------------------------------------------
* Reset 9 5 RST
* SPI SS 10 53 SDA
@tuxmartin
tuxmartin / googleTextToSpeech.py
Created December 4, 2015 16:18
echo "test 123" | python googleTextToSpeech.py cs
#! /usr/bin/python
# https://github.com/tuxmartin/google-translator-text-to-speech
# !!! Pouze pro vyukove ucely! Na 99,9% porusuje licenci Googlu !!!
"""
Pouziti:
$ echo "test 123" | python googleTextToSpeech.py cs
$ echo "test 123" | python googleTextToSpeech.py en
@tuxmartin
tuxmartin / gpio_reset.sh
Last active November 10, 2016 22:35
Angee GPIO factory reset
#!/bin/bash
export PATH=$PATH:/usr/local/bin
# Set up GPIO 3 and set to input
echo "3" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio3/direction
# Read from input
cat /sys/class/gpio/gpio3/value
@tuxmartin
tuxmartin / razeni_utf8.php
Created December 11, 2015 02:16
Razeni UTF-8 retezcu v PHP zacinajicich diakritickym znakem
<?php
setlocale(LC_COLLATE, 'cs_CZ.utf8');
$array = array("žragsg", "chodźić", "přidać", "ágščgš", "ćehnyć", "łopjeno");
usort($array, 'strcoll');
echo "<pre>";
print_r($array);
echo "/<pre>";
@tuxmartin
tuxmartin / poco_uri_parser.cpp
Created December 16, 2015 14:01
C++ POCO URI parser
// g++ -o poco_uri_parser poco_uri_parser.cpp -L/usr/local/lib -lPocoNet -lPocoFoundation
// http://pocoproject.org/slides/160-URIandUUID.pdf
#include "Poco/URI.h"
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
@tuxmartin
tuxmartin / Zdroj_DEB_balicku.md
Last active January 6, 2016 09:56
Vytvoreni DEB balicku, APT zdroje a jejich zprava

Vytvoreni a prace s APT zdrojem

Typ zdroje

Typ trivial archive ve tvaru deb http://example.org/debian ./ je deprecated, ale nicemu to nevadi.

Dnes se maji spravne pouzivat official archive ve tvaru deb http://example.org/debian unstable main.

Vytvoreni vlastniho zdroje DEB balicku pro APT