Skip to content

Instantly share code, notes, and snippets.

View poporul's full-sized avatar

Alexey Pokhozhaev poporul

View GitHub Profile
@poporul
poporul / action_dispatch_middleware.rb
Created May 10, 2017 11:54
Example of using ActionDispatch::MiddlewareStack
require 'action_dispatch/middleware/stack'
class BaseMiddleware
def initialize(stack)
@stack = stack
end
def call(data)
processed = process(data)
@stack.call(processed)
function Tile() {
let origin = 0b00000000;
let weightBitMask = 0b1111;
let colorBitMask = 0b11;
let typeBitMask = 0b11;
this.setType = function(value) {
value &= typeBitMask;
origin &= ~typeBitMask;
@poporul
poporul / callback.rb
Created March 2, 2015 09:37
ActiveSupport::Callbacks example
require 'active_support/callbacks'
class Example
include ActiveSupport::Callbacks
define_callbacks :action
def do
run_callbacks :action do
puts "Run :action callback!"
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
@poporul
poporul / xcode_uninstall.sh
Last active October 13, 2015 19:57
Uninstall Mac OS X development tools
sudo /Developer/Library/uninstall-devtools -mode=all
@poporul
poporul / nokogiri.sh
Last active October 13, 2015 19:48 — forked from jocubeit/gist:1713910
Install Nokogiri on Mac OSX Lion including libiconv using Homebrew
# Install libxml2 using Homebrew
# If you don't have Homebrew, follow the instructions at:
# https://github.com/mxcl/homebrew/wiki/Installation
# -------------------------------------------------------
brew install libxml2
# Install libxslt from source code
# If you don't have wget, follow the instructions at:
# http://www.mactricksandtips.com/2008/07/installing-wget-on-your-mac-for-terminal.html
# Or use Homebrew:
@poporul
poporul / gist:4193644
Created December 3, 2012 08:28 — forked from sstephenson/gist:1120938
Quick guide to installing rbenv
# Clone rbenv into ~/.rbenv
git clone git@github.com:sstephenson/rbenv.git ~/.rbenv
# Add rbenv to your PATH
# NOTE: rbenv is *NOT* compatible with rvm, so you'll need to
# remove rvm from your profile if it's present. (This is because
# rvm overrides the `gem` command.)
echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"' >> ~/.bash_profile
exec $SHELL
@poporul
poporul / mpd.rb
Created October 5, 2012 12:03
Support ALAC for mpd
require 'formula'
class Mpd < Formula
homepage 'http://mpd.wikia.com'
url 'http://sourceforge.net/projects/musicpd/files/mpd/0.17.1/mpd-0.17.1.tar.bz2'
sha1 '11da36217d57d08010f309977a4a77cce6240f77'
head 'git://git.musicpd.org/master/mpd.git'
option 'lastfm', 'Compile with experimental support for Last.fm radio'