Skip to content

Instantly share code, notes, and snippets.

View av-ast's full-sized avatar

Alexey Astafyev av-ast

View GitHub Profile
@av-ast
av-ast / polish_calc.rb
Created July 18, 2012 22:05
Calculator and converter for Reverse Polish Notation
module PolishCalc
OPERATORS = {
"+" => {:priority => 0, :arity => 2},
"-" => {:priority => 0, :arity => 2},
"*" => {:priority => 1, :arity => 2},
"/" => {:priority => 1, :arity => 2}
}
class Stack
@av-ast
av-ast / gist:4156678
Created November 27, 2012 20:05
ES FilteredQuery
$ curl -X GET "http://localhost:9200/videos/_search?from=0&load=true&size=10&pretty=true" -d '
{
"query" :
{
"filtered" :
{
"query":
{
"match_all":{}
},
" Ignore some folders and files for CtrlP indexing
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.sass-cache$|\.hg$\|\.svn$\|\.yardoc\|public$|log\|tmp$',
\ 'file': '\.so$\|\.dat$|\.DS_Store$'
\ }
@av-ast
av-ast / M.hs
Last active December 24, 2015 16:59
Function to count sum of squares
module M where
sum_of_squares :: Int -> Int
sum_of_squares n = sum . filter odd . map(^2) $ take n [1..]
sum_of_squares_dotless :: Int -> Int
sum_of_squares_dotless = sum . filter odd . map(^2) . (enumFromTo 1)
main :: IO()
main = do
-module(benchmark).
-author('cooldaemon@gmail.com').
-export([run/1]).
run(Count) ->
Keys = lists:seq(1, Count),
lists:foreach(
fun ({F, TargetName}) ->
{[SetRunTime, SetWallClock], [GetRunTime, GetWallClock]} = F(Keys),
@av-ast
av-ast / reltool_howto.txt
Last active December 28, 2015 18:09
Release Erlang app
mkdir sample && cd sample/
rebar create-app appid=sample
mkdir rel && cd rel/
rebar create-node nodeid=sample
cd ..
Дальше создаём rebar.config (если его ещё нет):
cat rebar.config
@av-ast
av-ast / hbase.rb
Last active August 29, 2015 14:17
Hbase homebrew formula
class Hbase < Formula
homepage "http://hbase.apache.org"
url "http://apache-mirror.rbc.ru/pub/apache/hbase/hbase-0.98.11/hbase-0.98.11-hadoop2-bin.tar.gz"
sha1 "f44551ed7f1e078e6d1fc17385ffb762c815f14a"
depends_on "hadoop"
def install
rm_f Dir["bin/*.cmd", "conf/*.cmd"]
libexec.install %w[bin conf docs lib hbase-webapps]
@av-ast
av-ast / raspbian.md
Last active August 29, 2015 14:21
raspbian tuning
  • Disable screen sleep
  • In order to set proper screen resolution set your /boot/config.txt content as following:
    disable_overscan=1
    hdmi_group=1
    hdmi_mode=16
@av-ast
av-ast / forward_ports.sh
Created May 26, 2015 08:49
Forward VM ports to localhost
#!/bin/bash
if [ "$#" -eq 0 ]; then
echo "USAGE: ./forward_ports.sh 1234 5678"
exit 1
fi
for port; do
echo "Forwarded port $port"
VBoxManage controlvm boot2docker-vm natpf1 "tcp-port$port,tcp,127.0.0.1,$port,,$port"
@av-ast
av-ast / postgresql-9.6.rb
Last active November 11, 2016 09:07
Homebrew formula for postgresql-9.6.0
class Postgresql96 < Formula
desc "Relational database management system"
homepage "https://www.postgresql.org/"
version = "9.6.0"
url "https://ftp.postgresql.org/pub/source/v#{version}/postgresql-#{version}.tar.bz2"
sha256 "3b5fe9634b80a4511aac1832a087586a7caa8c3413619562bdda009a015863ce"
head do
url "https://git.postgresql.org/git/postgresql.git", :branch => "REL9_6_STABLE"