Skip to content

Instantly share code, notes, and snippets.

View kolo's full-sized avatar

Dmitry Maksimov kolo

View GitHub Profile
@kolo
kolo / Dockerfile
Created February 23, 2017 21:09
ruby:2.4-alpine + rails 5.0.1
FROM ruby:2.4-alpine
RUN apk --update add --virtual\
build-dependencies build-base libev libev-dev postgresql-dev nodejs bash tzdata
ADD ./.gemrc /tmp
ADD ./Gemfile /tmp
ADD ./Gemfile.lock /tmp
WORKDIR /tmp
package main
import (
"errors"
"fmt"
)
type ErrorLogger interface {
Log(error) error
}
@kolo
kolo / amboy_ex.go
Created January 6, 2017 08:23
Example of using amboy job queue.
package main
import (
"context"
"fmt"
"os"
"os/signal"
"time"
"golang.org/x/time/rate"
@kolo
kolo / .vimrc
Created November 29, 2016 15:32
Minimal vimrc
set nocompatible
" vim-plug
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall | source $MYVIMRC
endif
call plug#begin('~/.vim/bundle')
@kolo
kolo / register_ab_test.rb
Created July 14, 2016 09:40
Register A/B test
name = "foo" # name of A/B test
# load split config
Wimdu::AbTest::Registry.new
experiment = Split::Experiment.new(name)
experiment.new_record?
experiment.delete
experiment = Split::Experiment.new(name)
@kolo
kolo / diamond.rb
Created May 30, 2016 12:05
"Functional" approach to solve diamond kata
class Diamond
STARTING_CHARACTER = "A"
def initialize(letter)
@letter = letter
end
def to_s
lines.join("\n")
end
@kolo
kolo / .gitconfig
Created February 10, 2016 14:18
git -r
[alias]
l = "!. ~/.githelpers && pretty_git_log"
la = !git l --all
r = !git l -30
ra = !git r --all
@kolo
kolo / digest.go
Created July 23, 2015 05:56
digest implementation for http digest authentication
package main
import (
"crypto/md5"
"fmt"
"strings"
)
type digest struct {
username string
module Builds::Git
def self.check_sha(sha, treeish)
Dir.chdir(Settings.git.path) do
out = `git log #{treeish} | grep #{sha}`
if out.strip.empty?
out = `git rev-list --cherry-mark master...#{treeish} | grep '#{sha}'`
if out.strip == "=#{sha}"
return true
@kolo
kolo / jsonrpc-http.go
Created August 5, 2013 12:00
Example of proxy for using JSON-RPC in Go via HTTP.
package main
import (
"bufio"
"bytes"
"fmt"
"log"
"net/http"
"net/rpc/jsonrpc"
)