Skip to content

Instantly share code, notes, and snippets.

View rndD's full-sized avatar
🌽

Alexey Kalmakov rndD

🌽
View GitHub Profile
@rndD
rndD / go_binary_tree_ex
Created January 6, 2015 06:37
A tour of go: Exercise: Equivalent Binary Trees
package main
import (
"code.google.com/p/go-tour/tree"
"fmt"
"reflect"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
@rndD
rndD / parent_helper.html
Created February 15, 2015 11:38
parenthelper meteor example
{{deck}}
{{#each cards}}
{{#each brothers}}
{{> tmpl bro=this card=parentHelper deck=parentHelper.parentHelper.deck}}
{{/each}}
{{/each}}
#!/bin/bash
set -e
FROM=/home/media/Downloads/complete
TO=/home/media/Video
for file in $FROM/*; do
echo "Where move file :$file"
select item in Shows Films Skip; do
case "$item" in
@rndD
rndD / overlap_substrings.py
Created March 3, 2015 17:04
Поиск подстроки внахлест
# -*- coding: utf-8 -*-
import re
def count_substrings_re(string, substring):
substring_re = '(?=(%s))' % re.escape(substring)
return len(re.findall(substring_re, string))
def count_substrings(s, f):
ind = 1
count = 0
@rndD
rndD / shortest_bash_variable.bash
Created March 11, 2015 08:37
print shortest env variable by key (work only in bash, not sh)
for i in `env`; do
key=${i%=*}
[[ -z $short_env ]] && short_env=$key;
[[ ${#key} -lt ${#short_env} ]] && short_env=$key;
done
echo "Shortest env variable: $short_env"
@rndD
rndD / GNUmakefile
Last active December 16, 2015 12:12
gist to show make autovars
dist/libs.js: app/bower_components/lodash/lodash.min.js node_modules/react/dist/react.min.js node_modules/redux/dist/redux.min.js
cat $? > $@
libs: dist/libs.js
.PHONY: libs
@rndD
rndD / .gitconfig
Last active February 1, 2016 19:28
tmp save my gitconfig
[core]
autocrlf = true
mergeoptions = --no-ff
[user]
email = [email protected]
name = Alex Kalmakov
[help]
autocorrect = 1
[alias]
# Shortcuts
@rndD
rndD / .js
Created April 19, 2016 22:38
findCellsInRadius
const findCellsInRadius = (w, h, center, radius) => {
let cellsInRadius = [];
let [centerX, centerY] = center;
_.range(w).forEach((x) => {
let rangeX = Math.abs(centerX - x);
(rangeX < radius) && _.range(h).forEach((y) => {
let rangeY = Math.abs(centerY - y);
@rndD
rndD / npm
Created July 9, 2016 12:19
Npm inject для кеширования папки node_modules
#!/usr/bin/env bash
# Фейковый npm
# Нужен для кэширования папки node_modules
# Кэш находится в папке ~/.cache/npm-inject/[sha1 хэш файла package.json]/node_modules
#
# В PATH надо добавить путь папки с фейковым npm, таким образом при выполнении команды `npm install`
# bash вызовет фейковый npm c параметром `install`.
# Фейк проверяет наличие папки [sha1 хэш файла package.json] в кэше.
# Если она в кэше, создаем на неё симлинк node_modules
version: '2'
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
ports:
- "5433:5433"
# Redis
redis:
image: redis:2.8.19
hostname: redis