Skip to content

Instantly share code, notes, and snippets.

View DmitryMyadzelets's full-sized avatar

Dmitry Myadzelets DmitryMyadzelets

View GitHub Profile
#!/usr/bin/python -O
from collections import defaultdict
from random import random, choice
from string import ascii_lowercase
from subprocess import Popen, PIPE
from time import time, sleep
# get a list of words with only ASCII characters
words = [w.strip().lower() for w in open("/usr/share/dict/words").readlines()]
words = [w for w in words if all([c in ascii_lowercase for c in w])]
@DmitryMyadzelets
DmitryMyadzelets / gist:21d071d88f2ec95d3487
Created September 5, 2014 14:12
Transliteration of cyrilic of Russian alphabet, GOST R 52535.1-2006 (Appendix A)
Транслитерация кириллицы для русского алфавита, ГОСТ Р 52535.1-2006 (Приложение А)
Transliteration of cyrilic of Russian alphabet, GOST R 52535.1-2006 (Appendix A)
1 А A
2 Б B
3 В V
4 Г G
5 Д D
6 Е E
7 Ё E
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Olivier Scherrer
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Installing Sublime Text 2
# Based on [https://gist.github.com/jansanchez/6202643]
# Download the latest version from: http://www.sublimetext.com/2
cd ~/downloads
# wget http://c758482.r82.cf2.rackcdn.com/Sublime%20Text%202.0.2.tar.bz2
# Unpack it
tar -xvf Sublime\ Text\ 2.0.2.tar.bz2
# Move the folder to "/opt"
sudo mv Sublime\ Text\ 2 /opt/
# Create a symbolic link in "/usr/bin":
@DmitryMyadzelets
DmitryMyadzelets / afterMethod.js
Last active August 29, 2015 14:15
Simple observer of object's methods
/**
* Sets a hook for a method call for the given object. Acts as a simple observer of object's methods.
* @param {Object} object An object.
* @param {Function} method A method of the object.
* @param {Function} hook A callback function which will be called after the call of object's method.
* @param {Function} [context] Context which will passed to the hook instead of `this`.
* @return {Function} after Returns itself for chained calls.
*/
function after(object, method, hook, that) {
var old = object[method];
@DmitryMyadzelets
DmitryMyadzelets / compress_js.sh
Created April 23, 2015 14:37
Compresses JS file using Google Closure Compiler's Web API
# usage: ./compress_js.sh file.js compressed/file.js
curl -d compilation_level=SIMPLE_OPTIMIZATIONS -d output_format=text -d output_info=compiled_code --data-urlencode "js_code@$1" http://closure-compiler.appspot.com/compile > $2
@DmitryMyadzelets
DmitryMyadzelets / eysenck_personality.json
Last active August 29, 2015 14:20
Eysenck's personality test in Cyrillic. Questions and Keys
{
"questions":[
{
"id":1,
"question":"Часто ли вы испытываете тягу к новым впечатлениям, к тому, чтобы «встряхнуться», испытать возбуждение?",
"value":true
},
{
"id":2,
"question":"Часто ли вы нуждаетесь в друзьях, которые вас понимают, могут ободрить или утешить?",
@DmitryMyadzelets
DmitryMyadzelets / nginx+php.md
Created May 15, 2015 17:45
Minimal setup of nginx and PHP locally

Minimal setup of nginx and PHP locally

nginx

Install and start nginx:

sudo apt-get update
sudo apt-get install nginx
sudo /etc/init.d/nginx start
@DmitryMyadzelets
DmitryMyadzelets / monitor.js
Last active August 29, 2015 14:21
Some function for web page view analysis
// Returns entire web page height
function page_height () {
return Math.max(
document.body.scrollHeight, document.documentElement.scrollHeight,
document.body.offsetHeight, document.documentElement.offsetHeight,
document.body.clientHeight, document.documentElement.clientHeight
);
}
// Returns visible web page height