Skip to content

Instantly share code, notes, and snippets.

View rainerborene's full-sized avatar

Rainer Borene rainerborene

View GitHub Profile
3.2M ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/fog-1.23.0/tags
356K ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.5/tags
216K ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/actionpack-4.1.5/tags
176K ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.1.5/tags
168K ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/skylight-0.3.19/tags
152K ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/mail-2.5.4/tags
132K ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/sass-3.2.19/tags
128K ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/shoulda-matchers-2.6.2/tags
128K ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/actionview-4.1.5/tags
128K ~/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bundler/gems/active_admin-0af2fdcafc0e/tags
<?xml version="1.0"?>
<root>
<item>
<name>Use the correct shift keys.</name>
<identifier>private.correct_shift_keys</identifier>
<autogen>--KeyToKey-- KeyCode::Q, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
<autogen>--KeyToKey-- KeyCode::W, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
<autogen>--KeyToKey-- KeyCode::E, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
<autogen>--KeyToKey-- KeyCode::R, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
@rainerborene
rainerborene / database.rb
Created August 17, 2014 17:16
Sidekiq Initializer
module Platform
module Database
def connect(size=35)
config = ActiveRecord::Base.configurations[Rails.env]
config['pool'] = ENV['DB_POOL'] || size
ActiveRecord::Base.establish_connection(config)
end
def disconnect
ActiveRecord::Base.connection_pool.disconnect!
activerecord (4.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:815:in `async_exec'
activerecord (4.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:815:in `block in exec_no_cache'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
activesupport (4.1.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
activerecord (4.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:815:in `exec_no_cache'
activerecord (4.1.1) lib/active_record/connection_adapters/postgresql/database_statements.rb:137:in `exec_query'
activerecord (4.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:947:in `select'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/database_statements.rb:31:in `select_all'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/query_cache.rb:67:in `block in sele
@rainerborene
rainerborene / classification_query.rb
Last active August 29, 2015 14:01
Classification Query Object
class ClassificationQuery
Tag = ActsAsTaggableOn::Tag
Tagging = ActsAsTaggableOn::Tagging
def initialize(bill, tagger = nil)
@bill, @tagger = bill, tagger
end
def count
relation = Tag.select(Tag[:name], Arel.star.count).where(
--- Available models:
---
--- ActsAsTaggableOn::Tag
--- ActsAsTaggableOn::Tagging
SELECT "tags"."name",
COUNT(*),
bool_or("taggings"."tagger_id" = $1)
FROM "tags"
INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id"
id | ancestry | path | created_at
--------+---------------+---------------------------------------------------------+----------------------------
213703 | 213701/213702 | {1397457810,213702,1397457473,213701,1397457945,213703} | 2014-04-14 06:45:45.878378
213718 | 213701 | {1397457473,213701,1397482294,213718} | 2014-04-14 13:31:34.509714
213701 | | {1397457473,213701} | 2014-04-14 06:37:53.96286
213725 | 213701 | {1397457473,213701,1397493839,213725} | 2014-04-14 16:43:59.824504
213702 | 213701 | {1397457473,213701,1397457810,213702} | 2014-04-14 06:43:30.375029
213701 | | {1397457473,213701} | 2014-04-14 06:37:53.96286
213697 | 213696 | {1397452306,213696,1397452646,213697} | 2014-04-14 05:17:26.964411
213696 | | {1397452

data

weekday | start_time | end_time
---------+------------+----------
      6 | 17:30:00   | 00:00:00
      7 | 11:30:00   | 01:00:00
(2 rows)

schema

class SocialProxy < SimpleDelegator
attr_reader :auth
def initialize(auth)
@auth = auth
@provider = auth.provider.to_sym
case @provider
when :facebook then require 'koala'
when :twitter then require 'twitter'
@rainerborene
rainerborene / ctrlp.vim
Last active November 22, 2017 13:52
Close buffer via <C-@> using CtrlP
let g:ctrlp_buffer_func = { 'enter': 'CtrlPMappings' }
function! CtrlPMappings()
nnoremap <buffer> <silent> <C-@> :call <sid>DeleteBuffer()<cr>
endfunction
function! s:DeleteBuffer()
let path = fnamemodify(getline('.')[2:], ':p')
let bufn = matchstr(path, '\v\d+\ze\*No Name')
exec "bd" bufn ==# "" ? path : bufn