Skip to content

Instantly share code, notes, and snippets.

View gorkunov's full-sized avatar

Alex Gorkunov gorkunov

  • proSapient
  • London, UK
View GitHub Profile
@gorkunov
gorkunov / params.ex
Last active February 26, 2018 12:15
defmodule Params do
@moduledoc """
Provides Ecto.Schema for params parsing.
Example:
defmodule SearchParams do
use Params
params do
field(:text, :string)
field(:user_id, :integer)
field(:team_ids, {:array, :integer})
@gorkunov
gorkunov / config.yml
Created January 5, 2018 10:55
Phoenix, node.js (webpack), postgres - linting + tests - circleCI (2.0)
version: 2
jobs:
build:
docker:
- image: bitwalker/alpine-elixir-phoenix:1.5.2
- image: postgres:9.4.1
environment:
POSTGRES_USER: ubuntu
working_directory: ~/repo
steps:
@gorkunov
gorkunov / gist:5171198
Created March 15, 2013 16:37
circleci + github + fish
function circle
set -l project (git config --get remote.origin.url | sed "s/.*:\(.*\).git/\1/")
if test -n $project
set -l git_branch (git symbolic-ref HEAD 2> /dev/null | sed -e 's/refs\/heads\///')
set -l url "https://circleci.com/gh/$project/tree/$git_branch"
open $url
end
end
@gorkunov
gorkunov / README.md
Last active September 25, 2018 18:13
My Fish config

Put aliases.fish, config.fish to ~/.config/fish/

Put fish_prompt.fish, fish_right_prompt.fish, fish_title.fish to ~/.config/fish/functions/

fish-shell

@gorkunov
gorkunov / gist:4225560
Created December 6, 2012 15:57
Smart Selection for VIM
" About:
"
" How often do you forget which keys you should use to select/modify strings
" in the ' or " or in other pairs? I often use viw/ciw instead of vi'/vi" for
" the first time because it easier for my fingers (but after that I remember
" about vi'). This script allows you always use the same shortcut for all
" cases. When you want to select string in the ' use viv. Do you want to
" select all in the '()'? Use viv. All in the '[]'? Use viv.
"
" How it works:
@gorkunov
gorkunov / gist:4059352
Created November 12, 2012 13:19
Speedup ruby loading

RBENV:

  1. Create file 'fast-require':

install_git 1.9.3-p194-price-fast-require https://github.com/gnprice/ruby fast-require-1.9.3p194 autoconf standard

  1. Run rbenv install /path/to/fast-require

  2. Comment lines 60-62 (hide psych warning) ~/.rbenv/versions/fast-require/lib/ruby/1.9.1/yaml.rb

d = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
d[:a][:b][:c][:d][:e] = 1
puts d
@gorkunov
gorkunov / gist:2319900
Created April 6, 2012 13:43
objective-c bro
[4/6/12 5:24:04 PM] ziryanov.ivan
мне надо строку типа "SepiaTone" сделать "Sepia Tone"
как это регуляркой сделать?
[4/6/12 5:29:04 PM] Alexander Gorkunov:
вот так на js "SepiaTone".replace(/([A-Z][a-z]+)/g, "$1 ")
ну можно еще trim сделать в конце
[4/6/12 5:40:53 PM] ziryanov.ivan:
вот так это получилось на обжектив си)
@gorkunov
gorkunov / gist:1416405
Created December 1, 2011 12:35
Nodejs adapter for ExtJS (collection extjs dependencies)
var appFolder = process.argv[2];
var prefix = process.argv[3];
var idle = false;
//emulate several browser objects for correct loading ext-core
navigator = {
userAgent: 'nodejs',
platform: 'linux'
};
document = {
getElementsByTagName: function(tag) {
@gorkunov
gorkunov / gist:1131694
Created August 8, 2011 12:51
defining preprocessors for extjs4
//add set default xtype preprocessor
Ext.Class.registerPreprocessor('default_xtype', function(cls, data) {
var className = data.$className;
var re = new RegExp(/^cl.view./);
if (re.test(className) && !data.alias) {
data.alias = 'widget.' + className.replace(re, '').replace(/\./g, '_').toLowerCase();
/*
* Overide default initComponent for defining component config by cloning
* this section from component class body (componentConfig property).
* WARNING: you can define component configuration in class body but this configuration