Skip to content

Instantly share code, notes, and snippets.

View borisaka's full-sized avatar

Boris Kraportov borisaka

View GitHub Profile
@borisaka
borisaka / create_chrootjail.sh
Created August 6, 2017 05:57 — forked from schnell18/create_chrootjail.sh
Script to automate the creation of chroot jail w/ minimal executables to run git.
#!/bin/sh
# script to automate the creation of chroot jail
# w/ minimal executables to run git
export CHROOT=/var/chroot
function copy_binary() {
for i in $(ldd $*|grep -v dynamic|cut -d " " -f 3|sed 's/://'|sort|uniq)
do
cp --parents $i $CHROOT
@borisaka
borisaka / README.md
Created July 6, 2017 03:56 — forked from Lazza/README.md
VPNGate Python script

vpngate.py

This script allows to use the free VPN service provided by VPNGate in an easy way. The user just needs to provide the desidered output country, and the script automatically chooses the best server.

After this step, OpenVPN is launched with the proper configuration. The VPN can be terminated by pressing Ctrl+C.

Usage

Run the script by providing the desired output country:

@borisaka
borisaka / gist:65d1d0d92a9dcbd04a1bc6f494837be4
Created May 29, 2017 17:54 — forked from jfreeze/gist:8894279
Get VI bindings in IEX (Elixir REPL)
# VI bindings in iex:
brew install rlwrap # on OSX
echo "alias iex='rlwrap -a foo iex'" >> ~/.bash_profile
echo "set editing-mode vi" >> ~/.inputrc
source ~/.bash_profile
# To run iex WITHOUT rlwrap
\iex
@borisaka
borisaka / build-boost-libc++
Created April 18, 2017 11:30 — forked from jimporter/build-boost-libc++
Build Boost against libc++
#!/bin/sh
# First, build libc++ See <http://libcxx.llvm.org/>, "Build on Linux using CMake
# and libsupc++." and substitute libsupc++ for libstdc++. NOTE: You'll probably
# need to explicitly link libsupc++ when you compile your own code!
#
# Next, download Boost and extract it somewhere. Set SRC_DIR to that location.
SRC_DIR=$HOME/src/boost_1_55_0
# Set this to be the install prefix. "/usr" is also a good choice.
require 'rom/memory'
class BlenderRelation < ROM::Relation[:memory]
repository :memory
register_as :blender
forward :join
end
class PostWithTagsMapper < ROM::Mapper
@borisaka
borisaka / custom_processor.rb
Created February 4, 2017 10:28 — forked from davidpelaez/custom_processor.rb
How to add custom steps to rom-mapper default Transproc processor. Useful to enhance the mapper with custom functionality and data transformations, e.g: lazy evaluation as presented in http://solnic.eu/2015/07/15/importing-data-with-rom-and-transproc.html
module Dataops
module Processors
class EnhancedAttributes < TransprocWithHook
BlockWrapper = Struct.new(:block) do
def call(*args)
self.block.call *args
end
end
@borisaka
borisaka / rom-mapper.rb
Created February 4, 2017 10:28 — forked from pjg/rom-mapper.rb
rom-mapper problem with reverse relationship
require 'rom-mapper'
class BigDecimal
def inspect
format("#<BigDecimal:%x %s>", object_id, to_s('F'))
end
end
class Gateway
def get_authors
command_builder = rom.command # no relation given, so get builder
nested_command = command_builder.create(user: :users) do |user|
user.create(:books)
end
# equivalent:
nested_command = rom.command({user: :users}, [:create, [:books, [:create]]])
# equivalent
require 'pathname'
ROOT = Pathname(__FILE__).expand_path.join('../..')
require 'rom'
class Post
include Equalizer.new :id, :title, :body, :comments
attr_accessor :id, :title, :body, :comments
end
@borisaka
borisaka / command_composition_in_rom.rb
Last active February 4, 2017 10:17 — forked from solnic/command_composition_in_rom.rb
Upcoming command composition in ROM
require 'rom'
ROM.setup(:memory)
class Users < ROM::Relation[:memory]
end
class Tasks < ROM::Relation[:memory]
end