Skip to content

Instantly share code, notes, and snippets.

class ActiveSupport::BufferedLogger
def formatter=(formatter)
@log.formatter = formatter
end
end
class Formatter
SEVERITY_TO_TAG_MAP = {'DEBUG'=>'meh', 'INFO'=>'fyi', 'WARN'=>'hmm', 'ERROR'=>'wtf', 'FATAL'=>'omg', 'UNKNOWN'=>'???'}
SEVERITY_TO_COLOR_MAP = {'DEBUG'=>'0;37', 'INFO'=>'32', 'WARN'=>'33', 'ERROR'=>'31', 'FATAL'=>'31', 'UNKNOWN'=>'37'}
PROTOCOL_COLOR = 34
module ActiveSupport
# Format the buffered logger with timestamp/severity info.
class BufferedLogger
NUMBER_TO_NAME_MAP = {0=>'DEBUG', 1=>'INFO', 2=>'WARN', 3=>'ERROR', 4=>'FATAL', 5=>'UNKNOWN'}
NUMBER_TO_COLOR_MAP = {0=>'0;37', 1=>'32', 2=>'33', 3=>'31', 4=>'31', 5=>'37'}
def add(severity, message = nil, progname = nil, &block)
return if @level > severity
sevstring = NUMBER_TO_NAME_MAP[severity]
[user]
name = ****
email = ****
[github]
user = ****
token = ****
[color]
branch = auto
diff = auto
status = auto
@Eugene-Shapovalov
Eugene-Shapovalov / gist:4976771
Created February 18, 2013 11:36
Rails dev env conf
# exclude docs and ri
echo 'gem: --no-ri --no-rdoc' >> ~/.gemrc
# rspec conf
echo '--colour --format documentation' > .rspec
# Git
echo 'test' >> .gitignore
echo '*.swp' >> .gitignore
echo '.DS_Store' >> .gitignore
@Eugene-Shapovalov
Eugene-Shapovalov / flac3mp3.sh
Last active August 29, 2015 14:01
flac2mp3
#!/bin/sh
for flac in *.flac;
do
wav="${flac%.*}".wav
# convert 2 wav
flac -d "$flac"
# convert 2 mp3 vbr max
lame -V 0 -h "$wav"
rm "$wav"
#!/bin/sh
for ape in *.ape;
do
ffmpeg -i "$ape" -ab 192k "${ape%.*}".mp3
done
#mp3splt -c audiotrack.cue audiotrack.mp3
@Eugene-Shapovalov
Eugene-Shapovalov / .bash_aliases
Created February 24, 2015 10:28
.bash_aliases
# Rails
alias be='bundle exec'
alias bers='be rails server'
alias berk='be rake'
alias berc='be rails c'
# Utils
alias hgrep='history | grep'
@Eugene-Shapovalov
Eugene-Shapovalov / exs.rb
Last active March 2, 2016 13:32
Ruby examples
Array.new(10) { rand 300 } #=> [217, 232, 274, 141, 157, 180, 11, 193, 66, 187]
[].methods.grep /^re.*/ # => array of matched methods
# All to boolean
!!(4) # => true
!!(nil) # false
# Different ways to call a lambda
my_lambda = -> { puts 'Hello' }
for f in *.log; do > $f; done
#
# systemd unit file for CentOS 7, Ubuntu 15.04
#
# Customize this file based on your bundler location, app directory, etc.
# Put this in /usr/lib/systemd/system (CentOS) or /lib/systemd/system (Ubuntu).
# Run:
# - systemctl enable sidekiq
# - systemctl {start,stop,restart} sidekiq
#
# This file corresponds to a single Sidekiq process. Add multiple copies