Skip to content

Instantly share code, notes, and snippets.

title Подача заявки на бесплатный аккаунт БВ

Actor->HomeController: GET /ownership/
HomeController-->Actor: 200 description text

alt Гость

  Actor->RequestsController: GET /ownership/requests/new
  RequestsController-->Actor: 200, email, fio
@gumayunov
gumayunov / vim.rb
Created February 27, 2012 18:37
vim formula for brew
require 'formula'
class Vim <Formula
url 'ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2'
homepage 'http://www.vim.org/'
md5 '5b9510a17074e2b37d8bb38ae09edbf2'
version '7.3.135'
def patchlevel; 135 end
def features; %w(tiny small normal big huge) end
@gumayunov
gumayunov / base.rb
Created February 21, 2012 19:02
File actionpack/lib/action_view/base.rb, line 255
def render(options = {}, local_assigns = {}, &block) #:nodoc:
local_assigns ||= {}
case options
when Hash
options = options.reverse_merge(:locals => {})
if options[:layout]
_render_with_layout(options, local_assigns, &block)
elsif options[:file]
template = self.view_paths.find_template(options[:file], template_format)
module OptHelper
def opt(name)
local_assigns[name.to_sym].presence
end
end
plan.allow? "Business", :add_photos, :subject => business
# если в качестве неймспейса передана не строка и не символ то
# неймспейсом берется класс объекта и он же подставляется как subject
plan.allow? business, :add_photos
@gumayunov
gumayunov / return_path_middleware.rb
Created January 29, 2012 12:28
OmniAuth::ReturnPathMiddleware
module OmniAuth
class ReturnPathMiddleware
def initialize(app)
@app = app
end
def call(env)
if auth_request?(env) && asseptable_referer?(env)
save_referer(env)
@gumayunov
gumayunov / social_friendlists_controller.rb
Created December 24, 2011 16:58
SocialHamster lib contept
# app/controllers/social_friendlists_controller.rb
def show
frineds = SocialService.get_friends(user_id, params[:provider])
rescue SocialService::NoCredentialsError
redirect_to auth_path(prams[:provider]) #to omniauth's /auth/facebook/
rescue SocialService::Error
flash[:error] = "Cant access #{params[:provider].capitalize}. Try again later"
redirect_to social_friendlists_path
end
var abonent = AbonentsCollection.build(user_data);
var view = new Map.Abonent(abonent);
Madiator.addAbonentView(view);
....
.click(function(ev){
Mediator.showOnMap($(ev.target).attr('abonent_id'))
})
@gumayunov
gumayunov / gist:1393657
Created November 25, 2011 14:35
AuthenticationService example
class AuthenticationsController < ApplicationController
def create
service = AuthenticationService
response = if current_user.present?
service.join(
:omniauth_hash => request.env['omniauth'],
:user => current_user
)
#!/bin/zsh
VPNWORK="192.168.10.1"
if [[ $IPREMOTE = $VPNWORK ]]; then
/sbin/route add 192.168.166.0/24 192.168.10.1 > /tmp/ppp.log 2>&1
fi