Skip to content

Instantly share code, notes, and snippets.

View styx's full-sized avatar
🌴
¯\_(ツ)_/¯

Mikhail S. Pabalavets styx

🌴
¯\_(ツ)_/¯
View GitHub Profile
@styx
styx / gist:e512d89217d922b8f7bb
Created November 12, 2014 11:36
Setup Jenkins user in Gerrit
#!/bin/bash
cat ./id_rsa.pub | ssh -p 29418 styx.mp@192.168.11.11 gerrit create-account --ssh-key - jenkins --full-name "Leeroy\ Jenkins" --email jenkins@domain.com
user www-data;
worker_processes 4;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
defmodule FibAgent do
defstruct cache: nil, highest_n: 0
def start_link do
initial_cache = Enum.into([ {0, 0}, {1, 1}], HashDict.new)
state = %__MODULE__{cache: initial_cache, highest_n: 1}
Agent.start_link(fn -> state end, name: __MODULE__)
end
@styx
styx / .vimrc
Created May 26, 2014 07:49 — forked from knewter/.vimrc
augroup elixir
au!
au BufNewFile,BufRead *.ex,*.exs noremap <buffer> <leader>t :!mix test %<cr>
au BufNewFile,BufRead *_test.exs noremap <buffer> <leader>t :!mix test %<cr>
augroup END
defmodule FibAgent do
def start_link do
cache = Enum.into([{0, 0}, {1, 1}], HashDict.new)
Agent.start_link(fn -> cache end)
end
def fib(pid, n) when n >= 0 do
Agent.get_and_update(pid, &do_fib(&1, n))
end
@styx
styx / glpr.sh
Last active June 20, 2019 05:39
Create Gitlab pull request from command line
#!/bin/bash
BROWSER='google-chrome'
#GITLAB_SECRET=''
ENDPOINT='http://gitlab.activeby.net/api/v3'
PROJECT='activebilling/core'
#curl --header "PRIVATE-TOKEN: xxx" "http://gitlab.activeby.net/api/v3/projects/activebilling%2Fcore" | awk '{match($1,"[0-9]+",a)}END{print a[0]}'
PROJECT_ID=177
ACTION="projects/$PROJECT_ID/merge_requests"
CURRENT_BRANCH=`git branch | grep '^\*' | awk '{ print $2; }'`
class Foo
def self.foo
"foo"
end
def foo
"ifoo"
end
def true_foo
Foo.foo
end
@styx
styx / gist:9187773
Created February 24, 2014 12:48 — forked from thijsc/gist:1391107
def select_from_chosen(item_text, options)
field = find_field(options[:from])
option_value = page.evaluate_script("$(\"##{field[:id]} option:contains('#{item_text}')\").val()")
page.execute_script("$('##{field[:id]}').val('#{option_value}')")
end
defmodule HttpRequester do
use GenServer.Behaviour
def start_link(_) do
:gen_server.start_link(__MODULE__, nil, [])
end
def fetch(server, url) do
:gen_server.cast(server, {:fetch, url})
end
@styx
styx / 0_reuse_code.js
Created January 10, 2014 12:43
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console