Skip to content

Instantly share code, notes, and snippets.

def create
@lead = params[:lead]
if @lead.save
respond_to do |format|
format.js
end
else
# handle errors here
end
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# SETUP CONSTANTS
# Bunch-o-predefined colors. Makes reading code easier than escape sequences.
# I don't remember where I found this. o_O
Benchmark.bm() do |x|
x.report { 1000000.times { %r(это медленно или быстро)i }}
x.report { 1000000.times { /это медленно или быстро\?/i }}
x.report { 1000000.times { Regexp.new('это медленно или быстро',true) }}
end
user system total real
0.050000 0.000000 0.050000 ( 0.047505)
0.050000 0.000000 0.050000 ( 0.047224)
12.010000 0.150000 12.160000 ( 12.169472)
module MemoryProfiler
class << self
DEFAULTS = {:delay => 10, :string_debug => false}
def start(opt={})
opt = DEFAULTS.dup.merge(opt)
Thread.new do
prev = Hash.new(0)
curr = Hash.new(0)
require 'i18n'
require 'arel'
module ModelTranslate
def self.included(base)
base.send :extend, Base
end
module Base
def translations *methods
if args['polygon'].present?
if (num = args['polygon'].match(/^(?:\-)?\d+$/)) && num[0].to_i > 0 && Polygon.exists?(num[0])
event[:polygon_id] = args['polygon']
else
event[:declared_polygon] = args['polygon']
end
end
@silentshade
silentshade / google_calendars.yml
Created June 19, 2018 13:30
Google holidays calendar ids with alpha2 YAML
en:
religious:
- :name: Christian
:id: en.christian#[email protected]
- :name: Islamic
:id: en.islamic#[email protected]
- :name: Jewish
:id: en.jewish#[email protected]
national:
- :name: Australian