This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from math import factorial | |
def sin(x): | |
val = np.float64(0) | |
for n in range(0, 25): | |
term = (((-1) ** n) * (x ** (2*n+1)) / factorial(2*n + 1)) | |
val += term | |
print("for x_{0}, term is {1}, sin({2}) approximation is {3}".format( | |
n, term, x, val)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew install python3 | |
brew install apple-gcc42 | |
brew unlink gcc | |
ln -sf /usr/local/bin/gfortran-4.2 /usr/local/bin/gfortran | |
#optional: create virtualenv | |
python3 -mvenv ~/venvs/my_venv | |
source ~/venvs/my_venv/bin/activate | |
#end optional |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
p = re.compile('\"([^\"]+)\"') | |
str = 'I said "Hello There." She replied "hi"' | |
matches = p.findall(str) | |
for m in matches: | |
print('found: {0}'.format(m)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iomanip> | |
#include "math.h" | |
using namespace std; | |
float pmf(int k, double lambda) { | |
// https://en.wikipedia.org/wiki/Poisson_distribution#Definition | |
return pow(M_E, k * log(lambda) - lambda - lgamma(k + 1.0)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto | |
import boto.s3 | |
from boto.s3.key import Key | |
from glob import glob | |
import sys | |
import argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument("-p","--pattern", help="pattern to upload") | |
args = parser.parse_args() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from math import pi, cos, sin | |
arc_size = pi / 2 | |
points = 20 | |
inner_ratio = .4 | |
theta = np.arange(0, arc_size, arc_size / points) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# start cmd.exe as admin | |
# start taskmanager and close explorer.exe | |
cd %userprofile%\appdata\local | |
del iconcache.db /a | |
# start explorer.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo yum -y install epel-release | |
sudo yum -y install gcc gcc-c++ python-pip python-devel atlas atlas-devel gcc-gfortran openssl-devel libffi-devel | |
# use pip or pip3 as you prefer for python or python3 | |
pip install --upgrade virtualenv | |
virtualenv --system-site-packages ~/venvs/tensorflow | |
source ~/venvs/tensorflow/bin/activate | |
pip install --upgrade numpy scipy wheel cryptography #optional | |
pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0rc0-cp35-cp35m-linux_x86_64.whl | |
# or below if you want gpu, support, but cuda and cudnn are required, see docs for more install instructions | |
pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.10.0rc0-cp35-cp35m-linux_x86_64.whl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
g <- qplot(c(0, 2 * pi), stat="function", fun=sin, | |
geom="line", color="sin", ylim=c(-2, 2), | |
ylab="ratio", xlab="radians") + | |
stat_function(fun=cos, aes(color="cos")) + | |
stat_function(fun=tan, aes(color="tan")) | |
print(g) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
skus = Dir.glob("*.jpg").collect do |file| | |
file.sub(".jpg","") | |
end | |
output = "final" | |
task :medium_images do | |
puts "creating medium images 250px wide..." | |
skus.each do |sku| | |
sh "convert #{sku}.jpg -strip -resize 250 -quality 100 #{output}/#{sku}_table.jpg" |