Skip to content

Instantly share code, notes, and snippets.

@ikataitsev
ikataitsev / Gemfile
Created June 24, 2020 23:06 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
@ikataitsev
ikataitsev / gist:0ea0247e7c1ca0087e6c0df49613249a
Created October 16, 2017 21:04 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*

Keybase proof

I hereby claim:

  • I am ikataitsev on github.
  • I am ivankataitsev (https://keybase.io/ivankataitsev) on keybase.
  • I have a public key ASA0ReDlw1Xu66yzVc2ct-bWZGm-KX0m8ZDB4pQf4eqqMAo

To claim this, I am signing this object:

@ikataitsev
ikataitsev / skcluster.rb
Created March 15, 2017 09:09 — forked from stympy/skcluster.rb
Sidekiq cluster control script and systemd service
#!/usr/bin/env ruby
require 'sidekiq'
require 'sidekiq/cli'
# Default to running one process per core
def process_count
return ENV['SK_PROCESS_COUNT'].to_i unless ENV['SK_PROCESS_COUNT'].to_i == 0
case RbConfig::CONFIG['host_os']
@ikataitsev
ikataitsev / skcluster.rb
Created March 15, 2017 09:09 — forked from stympy/skcluster.rb
Sidekiq cluster control script and systemd service
#!/usr/bin/env ruby
require 'sidekiq'
require 'sidekiq/cli'
# Default to running one process per core
def process_count
return ENV['SK_PROCESS_COUNT'].to_i unless ENV['SK_PROCESS_COUNT'].to_i == 0
case RbConfig::CONFIG['host_os']
@ikataitsev
ikataitsev / gist:9a9c13d7d494ee27d780
Created May 23, 2014 08:56
EventMachine segmentation fault on Ruby 2.1.2
/home/ikataitsev/courier/shared/bundle/ruby/2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187: [BUG] Segmentation fault at 0x00000000000000
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0005 p:---- s:0017 e:000016 CFUNC :run_machine
c:0004 p:0267 s:0014 e:000013 METHOD /home/ikataitsev/courier/shared/bundle/ruby/2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187
c:0003 p:0013 s:0007 E:001848 METHOD lib/pusher.rb:11
c:0002 p:0080 s:0004 E:001778 EVAL lib/pusher.rb:43 [FINISH]
c:0001 p:0000 s:0002 E:000148 TOP [FINISH]
require 'active_record'
require 'yaml'
require 'mysql'
require 'logger'
task :default => :migrate
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x"
task :migrate => :environment do
ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil )
@ikataitsev
ikataitsev / gist:6038132
Created July 19, 2013 10:11
HTTP caching reading list
- http://tools.ietf.org/html/rfc2616#section-13
- http://tomayko.com/writings/things-caches-do
- http://www.mnot.net/cache_docs/
@ikataitsev
ikataitsev / gist:5300689
Created April 3, 2013 12:17
counting q
class Activity < ActiveRecord::Base
# Activity#result is a boolean
end
# Let's say
Activity.all.pluck(:result) # => [false, true, false, false, false, true]
# How can I calculate the number of the false results before that true one?