Skip to content

Instantly share code, notes, and snippets.

@zerc
zerc / plural.js
Last active December 18, 2015 20:29
var plural = function(number, one, two, five) {
var n = Math.abs(number);
n %= 100;
if (n >= 5 && n <= 20) return number + ' ' + five;
n %= 10;
if (n == 1) return number + ' ' + one;
if (n >= 2 && n <= 4) return number + ' ' + two;
@zerc
zerc / Backbone.Form.Validators.js
Created June 22, 2013 13:28
Some addition validators for Backbone.Form
(function (Form) {
Form.validators.errMessages = {
youtube: 'Enter link from YouTube',
positive_int: 'Enter positive integer'
};
Form.validators.youtube = function(options) {
options = _.extend({
type: 'youtube',
message: this.errMessages.youtube,
@zerc
zerc / log_1
Created September 11, 2013 20:47
(venv)zero13cool@gantzer:~/repos/allinway$ cafe --nologo build --app_root=resources/cs --build_root=static/js --formula=recipe.yaml -f
Cafe> resolve: package.json's main file not found in dir /home/zero13cool/repos/allinway/resources/cs/node_modules/genome-parser/index.js
Cafe> resolve: package.json's main file not found in dir /home/zero13cool/repos/allinway/resources/cs/node_modules/dna-lang/lib-js/dna.js
Cafe> [Error: Cannot find module 'console-logger']
npm WARN package.json [email protected] No repository field.
npm http GET https://registry.npmjs.org/genome-parser
npm http GET https://registry.npmjs.org/dna-lang
npm http GET https://registry.npmjs.org/console-logger
npm http 304 https://registry.npmjs.org/dna-lang
npm http 304 https://registry.npmjs.org/console-logger
@zerc
zerc / helper.py
Created September 17, 2013 16:12
Логирование трейсбека. И даже не спрашивайте зачем мне это :D
def D(fn):
import traceback
filename = 'trace'
def _(*args, **kwargs):
try:
return fn(*args, **kwargs)
except:
traceback.print_exc(5, open(filename, 'w'))
raise
return _
@zerc
zerc / example_git_filter_branch
Created September 28, 2013 18:16
Переписываем историю своего гит репозитория
git filter-branch --tree-filter "find . \( -name 'filename1.py' -o -name 'filename2.sh' \) -exec sed -e \"s/password/fake_password/g\" -e \"s/api_key_secret/fake_key/g\" -i {} \;" HEAD --all
@zerc
zerc / Preferences.sublime_settings
Last active August 29, 2015 13:57
sublime settings
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
"*.pyc",
"*.pyo",
"*.exe",
"*.dll",
"*.obj",
from collections import deque
import time
def timeit(method):
def timed(*args, **kw):
ts = time.time()
result = method(*args, **kw)
te = time.time()
print('{}, {}'.format(method.__name__, te-ts))
return result
@zerc
zerc / free_email_provider_domains.txt
Last active January 18, 2016 11:00 — forked from tbrianjones/free_email_provider_domains.txt
A list of free email provider domains. Some of these are probably not around anymore. I've combined a dozen lists from around the web. Current "major providers" should all be in here as of the date this is created.
1033edge.com
11mail.com
123.com
123box.net
123india.com
123mail.cl
123qwe.co.uk
150ml.com
15meg4free.com
163.com