Skip to content

Instantly share code, notes, and snippets.

View szolotykh's full-sized avatar
😀

Sergey Zolotykh szolotykh

😀
View GitHub Profile
@szolotykh
szolotykh / expression-analysis.php
Created July 9, 2014 02:03
Expression analysis
<?php
$operators=array("+","-","*","/");
$numbers=array("0","1","2","3","4","5","6","7","8","9");
$a=array();
function findNodesFirst($exp,&$buff,&$nums,&$op){
//Check $exp is empty?
$newExp="";
@szolotykh
szolotykh / pyttsx-example.py
Created October 16, 2014 22:35
Init exampe of pyttsx
import pyttsx
engine = pyttsx.init()
engine.setProperty('rate', 100)
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
engine.say("A robot is a mechanical or virtual artificial agent, usually an electro-mechanical machine that is guided by a computer program or electronic circuitry.")
engine.runAndWait()
@szolotykh
szolotykh / nn-int.py
Created October 16, 2014 22:58
Neural network test: Integer classification
from pybrain.tools.shortcuts import buildNetwork
from pybrain.structure import FeedForwardNetwork
from pybrain.datasets import SupervisedDataSet
from pybrain.supervised.trainers import BackpropTrainer
from pybrain.structure import LinearLayer, SigmoidLayer, TanhLayer
from pybrain.structure import FullConnection
import random
def int2bin(a):
@szolotykh
szolotykh / nn-binary.py
Created October 16, 2014 22:59
Neural network test: Binary
from pybrain.tools.shortcuts import buildNetwork
from pybrain.structure import FeedForwardNetwork
from pybrain.datasets import SupervisedDataSet
from pybrain.supervised.trainers import BackpropTrainer
from pybrain.structure import LinearLayer, SigmoidLayer, TanhLayer
from pybrain.structure import FullConnection
import random
def int2bin(a):
@szolotykh
szolotykh / map2png.py
Last active August 29, 2015 14:07
PyPNG: Map to PNG function (array to PNG)
#https://pythonhosted.org/pypng/ex.html
import png
import time
def map2png(name, amap, w, h):
amap2 = list(amap)
for i in range(len(amap2)):
@szolotykh
szolotykh / onpress.py
Created October 16, 2014 23:07
Python: onpress
import getch
while True:
# ...
char = getch.getch() # User input, but not displayed on the screen
# or
#char = getch.getche() # also displayed on the screen
print char
@szolotykh
szolotykh / LegoNXTSerial.js
Created December 22, 2014 16:27
Send tone command to Lego NXT
var SerialPort = require("serialport").SerialPort
var serialPort = new SerialPort("COM4", {
baudrate: 9600
});
serialPort.on("open", function () {
console.log('open');
serialPort.on('data', function(data) {
@szolotykh
szolotykh / JSCameraTest.html
Created December 26, 2014 16:09
HTML5 Camera test
<html>
<script>
var errorCallback = function(e) {
console.log('Rejected', e);
};
function init(){
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
@szolotykh
szolotykh / FullScreenTest.html
Created January 7, 2015 20:57
Web page (div) fullscreen mode
<html>
<head>
<script>
function goFullScreen(elem){
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.msRequestFullscreen) {
elem.msRequestFullscreen();
} else if (elem.mozRequestFullScreen) {
elem.mozRequestFullScreen();
@szolotykh
szolotykh / speech2text.html
Created January 22, 2015 23:17
HTML5 Speech to text example
<html>
<head>
<script>
var recognition = new webkitSpeechRecognition();
recognition.continuous = true;
//recognition.interimResults = true;
function start(){
recognition.onresult = function(event) {
console.log(event);
var output = document.getElementById("output");