{
"body": {
"client": {
"name": "keybase.io node.js client",
"version": "0.8.20"
},
"key": {
"eldest_kid": "01017e6bf6b40651b3462eac3eac9203d8708904de24287fa6c034bf6a008894276d0a",
"fingerprint": "43d8c4e47eff66d1dc95697ed23a839f8f3cd8c8",
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
-- Show the coverage of a partial index | |
SELECT COUNT(DISTNICT(SUBSTR(<column>,1,<partial index length>))) / COUNT(DISTINCT(<column>)) * 100 FROM <table>; |
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
def toggle_console_logging | |
if ActiveRecord::Base.logger == Rails.logger | |
l = Logger.new(STDOUT) | |
l.level = Rails.logger.level | |
set_logger l and return "console" | |
else | |
set_logger Rails.logger and return "log file" | |
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
DEFAULT="\[\033[1;00m\]" | |
BLACK="\[\033[1;30m\]" | |
YELLOW="\[\033[1;33m\]" | |
GREEN="\[\033[1;32m\]" | |
WHITE="\[\033[1;37m\]" | |
BLUE="\[\033[1;36m\]" | |
# Returns "*" if the current git branch is dirty. | |
function parse_git_dirty { | |
[[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]] && echo "*" | |
} |
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
# $ translate hola | |
# hello | |
# $ translate hello es | |
# hola | |
# $ translate hello fr | |
# bonjour | |
# | |
# USAGE: | |
# | |
# translate <phrase to translate> <destination language> [<source language>] |
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
// To edit: | |
// Bundles -> Bundle Editor -> Edit Languages | |
// Open Ruby on Rails | |
// Edit HTML (Rails) | |
// add to the patterns | |
// works for <% content_for :inline_js do -%> | |
// can prefix :inline_js like :fb_inline_js | |
// the end tag must look like | |
// <!-- end :fb_inline_js--> works as well |
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
# A direct calculation of the number of months between two dates | |
class Time | |
class << self | |
def months_between(start_date, end_date) | |
return -months_between(end_date, start_date) if end_date < start_date | |
s = start_date |
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
# this was for Rails 3.2.0 before the RC dropped | |
rvm gemset create rails-master | |
rvm gemset use rails-master | |
cd ~/src | |
git clone git://github.com/rails/arel.git | |
cd arel | |
gem build arel.gemspec | |
gem install arel-*.gem |
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
require File.expand_path('../boot', __FILE__) | |
require 'rails/all' | |
module MyApp | |
class Application < Rails::Application | |
# you app configuration code | |
end | |
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
module AppName | |
class Application < Rails::Application | |
config.encoding = "utf-8" | |
config.filter_parameters += [:password] | |
config.assets.enabled = true | |
config.assets.version = '1.0' | |
# registers any file in the app/observers directory as an observer | |
observers = [] # Register all observers in the observers folder. | |
pattern = File.join(Rails.application.config.root, 'app', 'observers', '**', '*.rb') |
OlderNewer