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 / 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 / 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 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 / 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 / ability.rb
Created July 17, 2011 20:23
Padrino and CanCan
# include this in app file
# this is for Role Based Access Controle, can be much shorter
class Ability
include CanCan::Ability
def initialize account
@abilities ||= {}
allow [:any, :manager, :manufacturer, :admin] do
user app;
worker_processes 2;
error_log /home/app/logs/nginx.error.log info;
events {
worker_connections 1024;
}
def class_for_name name
namespaces = name.split '::'
base = Kernel
namespaces.each do |namespace| base = base.const_get(namespace) end
base
end
6
whale: big black water animal
penguin: black white ice beak
piano: keyboard black white wire
jackboot: leather heel black
train: rail wheel black
rose: red green thorn
4
whale penguin piano jackboot train
penguin piano
@pirj
pirj / простой
Created April 19, 2010 18:25
http proxy
local function handler(sock_in)
local line = sock_in:receive('*l')
-- where to?
local url = string.match(line, 'http://([%a%d\.-]+):*%d*/')
local port = string.match(line, 'http://[%a%d\.-]+:(%d+)/')
local sock_out = socket.connect(url, port or 80)
repeat
if line then sock_out:send(line..'\r\n') end
@pirj
pirj / agent.lua
Created February 23, 2010 15:04
Agent
require 'util'
require 'luarocks.require' -- http://www.luarocks.org/
local http = require 'socket.http' -- http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/
local bot_container = 'http://dozorni.heroku.com/whatnow'
local body, status = http.request(bot_container, '')
local json = require('json') -- http://luaforge.net/projects/luajson/
local dec = json.decode(body)