Skip to content

Instantly share code, notes, and snippets.

View tshev's full-sized avatar
🇺🇦

Taras Shevchenko tshev

🇺🇦
View GitHub Profile
@tshev
tshev / Bash
Last active August 29, 2015 13:59
Bash commands for
# download http://api.rubyonrails.org
wget -r -k -p http://api.rubyonrails.org
# find in directory by pattern
grep --include={*.c,*.h} -r 'directory' -e "pattern"
grep --exclude={*.c,*.h} -r 'directory' -e "pattern"
# find files bigger then 32M
find . -type f +32M
@tshev
tshev / python Oz transformation
Last active August 29, 2015 14:00
Vector transforamtion between Oz. You shoult be attentive whith floating poing.
#!/usr/bin/python
import numpy
def transformOzVector(alpha, vector):
m = numpy.matrix([[numpy.math.cos(alpha), -numpy.math.sin(alpha), 0],
[numpy.math.sin(alpha), numpy.math.cos(alpha), 0],
[0, 0, 1]])
return m*vector
result = transformOzVector(numpy.math.pi*1, numpy.matrix([1,0,0]).T)
print result
#!/usr/bin/bash
file=`uuidgen`
cat "file" | while read v
do
read x;
if [ $x ]
then
echo $x >> $file
fi
echo $v >> $file
#!/usr/bin/python
import scipy
import scipy.linalg
def f(a):
s = 0
for i in range(len(a)):
s+= a[i]*x**i
return s
def check(roots):
for x in roots:
@tshev
tshev / gist:9eb87c594b157db06fac
Created May 25, 2014 12:29
Polynomial division.
import numpy as np
xPoly = [1, 2, 1]
yPoly = [-1, 1]
np.polydiv(xPoly, yPoly)
@tshev
tshev / gist:49c4e783159b7ba72c57
Created May 25, 2014 12:37
Calculate polynomial at point
import numpy as np
# P(x) = 3x^2 + 6x + 1
np.polyval([9, 6, 1], 0) # returns 1
@tshev
tshev / gist:bbeb418f1f63d888fa9e
Created May 29, 2014 19:28
Normal distribution. Python
%pylab inline
import matplotlib.pyplot as plt
import scipy
import scipy.stats
g = scipy.stats.norm(-3.5,0.05)
r = g.rvs(100)
r.sort()
print g.median()
plt.plot(r, np.array([g.pdf(i) for i in r]))
plt.show()
@tshev
tshev / gist:8e6eaeeedda6be5e3e26
Last active August 29, 2015 14:01
Siege visualisation
%pylab inline
import matplotlib.pylab as plt
import re
class Vs:
def __init__(self,fname):
self.fname = fname
self.readDate()
self.count = 0
self.time = []
def readDate(self):
@tshev
tshev / Git_server_shell_script
Last active August 29, 2015 14:03
Git repo creator
#!/bin/bash
echo "Enter your path to the repository without name"
read path
cd $path
echo "Enter the reponame"
read reponame
mkdir "$reponame"".git" && cd "$reponame"".git"
git init --bare
cd hooks
@tshev
tshev / gist:33e13897d5d844ade967
Last active August 29, 2015 14:03
std::move does not move
#include <iostream>
#include <vector>
#include <string>
int main() {
std::string str1 = "AA";
std::vector< std::string > v;
v.push_back(str1);
std::cout << str1 << "\n"; // AA
v.push_back(std::move(str1));
std::cout << str1 << "\n"; // AA