Skip to content

Instantly share code, notes, and snippets.

View pirj's full-sized avatar
🚜
Relentless

Phil Pirozhkov pirj

🚜
Relentless
View GitHub Profile
@pirj
pirj / 001_create_account.rb
Created July 4, 2012 08:30
Padrino authentication
migration 1, :create_accounts do
up do
create_table :accounts do
column :id, Integer, :serial => true
column :name, String
column :surname, String
column :email, String
column :crypted_password, String, :length => 64
column :role, String
end
@pirj
pirj / Gemfile
Created July 31, 2012 13:49
Sinatra stream + Redis PubSub
source 'https://rubygems.org'
gem 'sinatra'
gem 'rack-fiber_pool', :require => 'rack/fiber_pool'
group :development do
gem 'thin'
gem 'pry-rails'
end
@pirj
pirj / Gemfile
Created August 16, 2012 15:38
Sinatra + Omniauth
source 'https://rubygems.org'
gem 'thin'
gem 'eventmachine', '1.0.0.rc.4'
gem 'sinatra'
gem 'sinatra-contrib', :require => 'sinatra/contrib'
gem 'sinatra-flash', :require => 'sinatra/flash'
gem 'rack-protection'
@pirj
pirj / Gemfile
Created August 17, 2012 10:13
Sinatra streaming + Redis PubSub
source 'https://rubygems.org'
gem 'sinatra'
gem 'sinatra-contrib', require: 'sinatra/streaming'
group :development do
gem 'thin'
gem 'pry-rails'
end
@pirj
pirj / fibquence.rb
Created September 5, 2012 20:26 — forked from egoholic/fibquence.rb
Oneline fibonacci sequence generator
def fib n;n==0?[0]:n==1?[0,1]:(2..n-1).inject([0,1]){|a|a<<(a[-1]+a[-2])};end
@pirj
pirj / fibonacci.rb
Created September 5, 2012 21:25 — forked from NILID/fibonacci.rb
fibonacci
def fib(n)a,b,s=0,1,[];n.times{s<<a;c=b;b=a+b;a=c};s end
p fib(33)
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, ...]
@pirj
pirj / time_travel.rb
Created September 11, 2012 18:39
Eventmachine & Delorean time travel thing
require 'em/pure_ruby'
require 'eventmachine'
require 'delorean'
require 'benchmark'
Benchmark.measure do
EM.run do
ticks = 0
timer = EM.add_periodic_timer 10 do
print '.'
@pirj
pirj / gist:6152272
Created August 4, 2013 22:47
Template module
class BaseWall
def self.Wall length, width, material
Module.new do
define_method(:length) { length }
define_method(:width) { width }
define_method(:material) { material }
def self.included clazz
private :length, :width, :material
end
@pirj
pirj / download.bash
Last active August 29, 2015 13:57
Parallel download of audio files (10 files at a time) from VK.com. Install extension from vkopt.net, download playlist as "playlist.lst", and run `./download.bash playlist.lst`. Makes "playlist" directory.
mkdir "${1%.*}"
( cd "${1%.*}"
xargs -n1 -P10 -0 -d"\n" -Iuri bash -c "wget -O \"\$(echo \"uri\" | sed -e \"s/^.*&\///g\" -f ../urldecode.sed)\" \"uri\"" <../$1
)
@pirj
pirj / index.html
Created April 29, 2014 18:46
GNU/Linux и устройство на Rockchip 2918 / Хабрахабр
<!DOCTYPE html>
<!-- saved from url=(0032)http://habrahabr.ru/post/147793/ -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width = 1080">
<title>GNU/Linux и устройство на Rockchip 2918 / Хабрахабр</title>