http://hashrocket.com/blog/posts/how-to-switch-from-textmate-to-vim http://www.vimgenius.com http://www.fprintf.net/vimCheatSheet.html http://vim-adventures.com http://www.vimsnake.com http://www.youtube.com/watch?v=9jzWDr24UHQ http://shime.github.io/blog/guard-down-vim-and-tmux-are-here/ http://stevelosh.com/blog/2010/09/coming-home-to-vim http://reefpoints.dockyard.com/2013/11/27/vim-windows.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rbenv global 2.2.2 | |
sudo service elasticsearch stop | |
if ! [ -e .semaphore-cache/elasticsearch-1.5.1.deb ]; then (cd .semaphore-cache; curl -OL https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.5.1.deb); fi | |
echo Y | sudo dpkg -i .semaphore-cache/elasticsearch-1.5.1.deb | |
sudo sh -c "echo 'script.disable_dynamic: false' >> /etc/elasticsearch/elasticsearch.yml" | |
sudo service elasticsearch start | |
sleep 5 && curl -XGET 'localhost:9200' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://minhajuddin.com/2016/03/03/put-this-in-your-code-to-debug-anything | |
require 'rouge' | |
require 'method_source' | |
require 'pp' | |
class Dbg | |
def initialize(object, to:) | |
@object, @stream = object, to | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddEmptyCheckForNameAndAmsKeyToCarriers < ActiveRecord::Migration | |
def up | |
execute %{ | |
ALTER TABLE carriers | |
ADD CONSTRAINT check_carriers_name_is_not_empty | |
CHECK (name <> ''); | |
} | |
execute %{ | |
ALTER TABLE carriers | |
ADD CONSTRAINT check_carriers_ams_key_is_not_empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Capybara::Poltergeist | |
class Client | |
private | |
def redirect_stdout(to = nil) | |
to ||= @write_io | |
prev = STDOUT.dup | |
prev.autoclose = false | |
$stdout = to | |
STDOUT.reopen(to) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage: | |
// $('div').gracefullEffect('slideDown') | |
$.fn.gracefullEffect = function(effectName) { | |
fallbacksMap = { | |
slideDown: 'show', | |
slideUp: 'hide' | |
// ... | |
} | |
if ($.support.trailingWhiteSpace) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Usage: | |
# Add env variable: /path/to/this/script {environment} add VAR_NAME varvalue | |
# Remove env variable: /path/to/this/script {environment} remove VAR_NAME | |
require 'active_support' | |
app_name = "betterdoc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TooltipsAndClientSideValidationsFormBuilder > ActionView::Helpers::FormBuilder | |
def text_field(object_name, method, options = {}) | |
# do nothing if raw option is present (same as rails standard text_field) | |
unless options[:raw] | |
extract_tooltip_options! options | |
extract_validation_options! options | |
end | |
super(object_name, method, options = {}) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://fredwu.me/post/60441991350/protip-ruby-devs-please-tweak-your-gc-settings-for | |
http://fredwu.me/post/61571741083/protip-faster-ruby-tests-with-databasecleaner-and | |
http://labs.goclio.com/tuning-ruby-garbage-collection-for-rspec/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hamed Asghari post: http://hasghari.github.io/2013/09/15/active-record-enhanced-query-objects.html | |
class PopularProductQuery | |
def initialize(relation = Product.scoped) | |
@relation = relation.extending(Scopes) | |
end | |
def popular(time) | |
@relation.with_recent_activity(time).with_available_reviews | |
end |