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 'logger' | |
l = Logger.new(STDOUT) | |
l.formatter = proc { |severity, datetime, progname, msg| | |
dt = datetime.strftime('%Y-%b-%d@%H:%M:%S:%z') | |
"#{[severity,dt,progname,msg].join(' ').squeeze(' ')}\n" | |
} | |
l.info "woot" #=> INFO 2014-Feb-11@09:48:32:-0500 woot |
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 p(*args) | |
location = caller_locations(1,1)[0] | |
location_string = "#{location.path.split('/').last}:#{location.lineno}(#{location.label})" | |
super([*args, location_string]) | |
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
# This can be run from the voltron directory while the NetSkycanner has a couple of `rake pathfinder` processes running | |
require 'bundler/setup' | |
Bundler.require :default, :pathfinder | |
require 'json' | |
require 'thump' | |
require 'mr_sulu_messages' | |
test = "searching" |
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/initializers/stupid_t.rb | |
# Any text that doesn't appear as "localized" isn't localized | |
module ActionView::Helpers::TranslationHelper | |
def t(*args) | |
result = I18n.t!(*args) | |
if result.respond_to?(:map) | |
result.map { |r| "localized" } | |
else | |
"localized" | |
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
" <cr> should not only clear highlighted search, but flash the current | |
" cursor location. | |
:nnoremap <CR> :nohlsearch<CR>:set cul cuc<cr>:sleep 50m<cr>:set nocul nocuc<cr>/<BS> |
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
function safelog(message) { | |
try{ console.log(message); } catch(e){ /*do nothing*/ } | |
} |
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
#!/bin/sh | |
set -e | |
# Feel free to change any of the following variables for your app: | |
TIMEOUT=${TIMEOUT-60} | |
APP_ROOT=/home/deploy/taxscribe/current | |
PID=$APP_ROOT/tmp/pids/unicorn.pid | |
CMD="/usr/local/bin/unicorn --config-file $APP_ROOT/config/unicorn.server.rb --env production --daemonize $APP_ROOT/config.ru" | |
action="$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
// Simple wrapper for console.log() | |
// | |
// Does nothing unless it's turned on AND the user has a console open | |
// | |
// Usage | |
// - Turn on with `safeLogger.active = true;` | |
// - Log messages like `safeLogger.log('someString',someObject);` | |
safeLogger = { |
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 | |
# Rearrange song lyrics so it's easier to put guitar chords over them: put the | |
# first lines of each verse, which share the same chords, into the first | |
# paragraph. Second lines go into the second paragraph, etc. | |
# | |
# Meant to be used with Unix piping: `cat somefile.txt | ./this_script > output.txt | |
lyrics = STDIN.read | |
paragraphs = lyrics.split("\n\n") | |
lines = paragraphs.map { |paragraph| paragraph.split("\n") } |
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 safer console object (https://gist.github.com/nathanl/6368185) | |
// - Ensures `console.log` doesn't cause errors in browsers with no console | |
// - Lets you enable/disable console logging (using console.enable = true/false) | |
// - Supports all console methods documented here: https://developer.mozilla.org/en-US/docs/Web/API/console | |
// | |
// Less fancy but lighter weight than this: http://benalman.com/projects/javascript-debug-console-log/ | |
safe_console = { | |
enabled: false, | |
original_console: (function(){ | |
// If the browser has no usable one, define a no-op |
OlderNewer