Skip to content

Instantly share code, notes, and snippets.

View szolotykh's full-sized avatar
😀

Sergey Zolotykh szolotykh

😀
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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="";
from urllib2 import Request, urlopen, URLError
def findURL(page_srt, res):
try:
att = "url"+res
start_ind = page_srt.index(att)
end_ind = page_srt.index("?",start_ind)
url = page_srt[(start_ind+len(att)+1):end_ind]
return url
except:
@szolotykh
szolotykh / twitter-stream.py
Created May 23, 2014 05:22
Tweets streaming
import tweepy
import os
import json
# Consumer keys and access tokens
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
@szolotykh
szolotykh / twitter-post.py
Last active August 29, 2015 14:01
Python script is update status on twitter
import tweepy
import os
# Consumer keys and access tokens, used for OAuth
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
# OAuth process, using the keys and tokens
#include <iostream>
#include <string>
using namespace std;
bool BracketsInclusion(string str){
int length = str.length();
// Remove everything besides brackets
string bstr ="";
for(int i = 0; i<length; i++){