Skip to content

Instantly share code, notes, and snippets.

View andriisoldatenko's full-sized avatar
🏠
Working from home

Andrii Soldatenko andriisoldatenko

🏠
Working from home
View GitHub Profile
import re
replacement_patterns = [
(r'won\'t', 'will not'),
(r'can\'t', 'can not'),
(r'i\'m', 'i am'),
(r'ain\'t', 'is not'),
(r'(\w+)\'ll', '\g<1> will'),
(r'(\w+)n\'t', '\g<1> not'),
(r'(\w+)\'ve', '\g<1> have'),
@andriisoldatenko
andriisoldatenko / collocations_example.py
Created September 3, 2016 07:38
Collocations example
import pprint
from nltk.corpus import stopwords
from nltk.corpus import webtext
from nltk.collocations import BigramCollocationFinder
from nltk.metrics import BigramAssocMeasures
stopset = set(stopwords.words('english'))
filter_stops = lambda w: len(w) < 3 or w in stopset
words = [w.lower() for w in webtext.words('grail.txt')]
@andriisoldatenko
andriisoldatenko / latency.txt
Last active February 18, 2018 07:16 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
#!/usr/bin/env ruby
# 1. Install hunspell
# $ brew install hunspell
# 2. Download a dictionary and install it in a path listed by `hunspell -D`
# $ open http://wiki.services.openoffice.org/wiki/Dictionaries
# 3. Move this file into your repository
# $ mv commit-msg /path/to/repo/.git/hooks
@andriisoldatenko
andriisoldatenko / commit-msg
Created October 30, 2015 10:24 — forked from remi/commit-msg
Git commit message spell check hook (kind of a proof of concept, but still usable)
#!/usr/bin/env ruby
# 1. Install hunspell
# $ brew install hunspell
# 2. Download a dictionary and install it in a path listed by `hunspell -D`
# $ open http://wiki.services.openoffice.org/wiki/Dictionaries
# 3. Move this file into your repository
# $ mv commit-msg /path/to/repo/.git/hooks
@andriisoldatenko
andriisoldatenko / load_test_data.sh
Created October 2, 2015 07:27 — forked from clintongormley/load_test_data.sh
Run these commands in your shell to setup the test data for Chapter 5
curl -XPUT 'http://localhost:9200/us/user/1?pretty=1' -d '
{
"email" : "john@smith.com",
"name" : "John Smith",
"username" : "@john"
}
'
curl -XPUT 'http://localhost:9200/gb/user/2?pretty=1' -d '
{
@andriisoldatenko
andriisoldatenko / pre-commit.py
Created September 9, 2015 14:46
PEP8 pre commit git hook
#!/usr/bin/env python
from __future__ import with_statement
import os
import re
import shutil
import subprocess
import sys
import tempfile
@andriisoldatenko
andriisoldatenko / teamcity_messages_decorator.py
Created September 7, 2015 15:48
Fabric decorator for build script interaction with TeamCity
from functools import wraps
def teamcity_messages(f):
"""
Decorator for Build Script Interaction with TeamCity
https://confluence.jetbrains.com/display/
TCD9/Build+Script+Interaction+with+TeamCity
"""
@wraps(f)
def wrapper(*args, **kwds):
@andriisoldatenko
andriisoldatenko / create_user_centos_7.sh
Created September 3, 2015 10:07
Create new user centos 7.1 and add to sudoers
# based on this
# https://wiki.centos.org/HowTos/Network/SecuringSSH
# https://www.digitalocean.com/community/tutorials/how-to-add-and-delete-users-on-a-centos-7-server
# Create user
sudo adduser newuser
sudo /usr/sbin/visudo
@andriisoldatenko
andriisoldatenko / mul.py
Created August 31, 2015 12:25
matrix_multiply
A = [[1, 2, 3],
[1, 2, 3],
[1, 2, 3],
[1, 2, 3]]
B = [[1, 2, 3, 4],
[1, 2, 3, 4],
[1, 2, 3, 4]]