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 Where | |
class <<self | |
attr_accessor :editor | |
def is_proc(proc) | |
source_location(proc) | |
end | |
def is_method(klass, method_name) | |
source_location(klass.method(method_name)) |
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
# updated variant of older solution: | |
# http://www.davidverhasselt.com/2012/05/13/how-to-migrate-passwords-from-legacy-systems-to-devise | |
class User < ActiveRecord::Base | |
# ... | |
def valid_password?(password) | |
if legacy_password? | |
# Use Devise's secure_compare to avoid timing attacks |
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
# lib/bundler/dsl.rb | |
# Bundler::DSL extension to provide OS-depended gems in Gemfile | |
# https://github.com/bundler/bundler/wiki/Platform-as-a-parameter | |
# | |
# Allows to group os-dependent gems in blocks with one or more symbols, strings or regexps as parameters. | |
# OS name is obtained from `RbConfig::CONFIG['host_os']` or `RUBY_PLATFORM` if the first one is not available. | |
# | |
# Place this file in the project's lib folder and require it in your Gemfile: | |
# require File.expand_path('../lib/bundler/dsl', __FILE__) |
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
# -- config/passenger.rb | |
# require this file in the config/deploy.rb | |
Capistrano::Configuration.instance.load do | |
# Config template path (config/passenger/template.nginx.conf) | |
set :template_path, File.expand_path('../passenger/template.nginx.conf', __FILE__) | |
# Upload config to: | |
set :config_deploy_path, "#{deploy_to}/config/nginx_passenger.conf" |
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
# .pryrc | |
Pry::Commands.create_command "reload!" do | |
description "Exits and runs again pry process" | |
def process | |
target.eval <<-EVAL | |
at_exit { puts "Reloading pry..."; exec "pry" } | |
exit | |
EVAL |
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
# ============================================== | |
# = Improved responsive tables for Bootstrap 2 = | |
# ============================================== | |
# | |
# Add .table-responsive to enable this feature for tables. | |
# Change $.fn.tableResponsive.defaults.media_query to support other devices. | |
class TableResponsive | |
provide_uniq_id = (table) -> | |
table.id ?= "table-responsive-#{ just.genuniq() }" |
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
# helpers/bootstrap_helper/tabbable.rb | |
# Bootstrap 2 tabs helper method for Ruby on Rails | |
# http://getbootstrap.com/2.3.2/components.html | |
# | |
# == Usage (slim): | |
# | |
# = tabbable do |t| | |
# = t.section :tab_1 do | |
# / Content for Tab #1 |
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
# = Kernel#switch | |
# Provides alternative switch-case syntax. | |
# | |
# # support methods: | |
# value = [] | |
# switch value do | |
# on empty?: -> { "none" } | |
# on one?: -> { "one" } | |
# on many?: -> { "many" } | |
# 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>beforeRunningCommand</key> | |
<string>nop</string> | |
<key>command</key> | |
<string>#!/usr/bin/env ruby -wU | |
unless ENV['TM_FILENAME'] =~ /^(?:Gemfile|.*\.gemspec)$/ |
OlderNewer