Skip to content

Instantly share code, notes, and snippets.

View tapalilov's full-sized avatar
🐒
Clicking on keyboard

Georgi Tapalilov tapalilov

🐒
Clicking on keyboard
View GitHub Profile
resources :students do
resources :reports, only: :index, controller: 'students/reports'
end
def foo(key: 'something')
bar(key: key)
end
require 'rubygems'
require 'active_merchant'
require 'pry'
ActiveMerchant::Billing::Base.mode = :test
gateway = ActiveMerchant::Billing::WebpayGateway.new(:login => 'xxx') # login cleared for security purpose
amount = 5000
module JsonRender
extend ActiveSupport::Concern
included do
def json_render(object_or_collection)
end
def meta_hash
end
home/georgi/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec/core/formatters/deprecation_formatter.rb:186:in `puts': The `:example_group` key in an example group's metadata hash is deprecated. Use the example group's hash directly for the computed keys and `:parent_example_group` to access the parent example group metadata instead. Called from /home/georgi/ruby/xxx/spec/models/emr_spec.rb:3:in `<top (required)>'. (RSpec::Core::DeprecationError)
from /home/georgi/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec/core/formatters/deprecation_formatter.rb:125:in `print_deprecation_message'
from /home/georgi/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec/core/formatters/deprecation_formatter.rb:36:in `deprecation'
from /home/georgi/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec/core/reporter.rb:137:in `block in notify'
from /home/georgi/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.1/lib/rspec
ActionView::MissingTemplate - Missing template gaku/enrollments/index, gaku/gaku/index, gaku/core/index with {:locale=>[:en], :formats=>[:js, "application/ecmascript", "application/x-ecmascript", :html, :text, :js, :css, :ics, :csv, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :slim, :rb]}. Searched in:
* "/home/georgi/ruby/gaku/frontend/app/views/gaku/class_groups"
* "/home/georgi/ruby/gaku_dev_app/app/views"
* "/home/georgi/ruby/gaku_imex/app/views"
* "/home/georgi/ruby/gaku/admin/app/views"
* "/home/georgi/ruby/gaku/frontend/app/views"
* "/home/georgi/ruby/gaku/core/app/views"
* "/home/georgi/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/kaminari-0.15.1/app/views"
i have following array
['a', 'b', 'c']
How to convert it to hash like this bellow:
{'a' => { position: index of array element } }
require 'stringio'
require 'timeout'
class Object
def methods_returning(expected, *args, &blk)
old_stdout = $>
$> = StringIO.new
methods.select do |meth|
Timeout::timeout(1) { dup.public_send(meth, *args, &blk) == expected rescue false } rescue false
@tapalilov
tapalilov / timeout.rb
Created November 21, 2013 18:17
dasdasda
def locked_for?(action_user)
!time_expired? and user != action_user
end
def timeout?
time_expired? && !user.premium_account?
end
def time_until_expire
expiration_time if !time_expired?
Depot::Application.routes.draw do
# match 'admin', :to => 'admin#index'
get 'admin' => 'admin#index'
controller :sessions do
get 'login' => :new
post 'login' => :create
delete 'logout' => :destroy
end