This file contains hidden or 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
local function run(self, name, f) | |
local start = os.clock() | |
f() | |
local now = os.clock() | |
table.insert(self.result, { name=name, time=now-start }) | |
end | |
local function report(self) | |
local data = '' |
This file contains hidden or 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 RemoveTimePrecisionGranularity | |
def self.included(mod) | |
mod.class_eval do | |
extend ClassMethods | |
alias_method :orig_equals, :== | |
end | |
end | |
module ClassMethods | |
def equals_method_ignore_1_second_granularity! |
This file contains hidden or 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/bash | |
# usage: | |
# save this file into $HOME/bin/mysql (don't forget to make it executable) | |
# and make sure $HOME/bin is in PATH environment variable before folder where original mysql binary is located. | |
# for instance mysql binary is here: /usr/local/bin/mysql, than PATH should be like: | |
# /home/user/bin:/usr/local/bin:... | |
set -e | |
declare -a args=() |
This file contains hidden or 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
/** | |
Usage: | |
var engine = SimpleJsTemplator({ | |
value: '{pattern}' | |
}) | |
engine.compile('string with {pattern}', { value: 'PATTERN' }) | |
will produce: | |
'string with PATTERN' | |
*/ | |
var SimpleJsTemplator = (function () { |
This file contains hidden or 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
sed -i.bak -E "s/YAML\.load_file\(Rails\.root\.join\('config\/(.+)\.yml'\)\)\[Rails\.env\]/Rails.application.config_for('\1')/" $(git grep -l YAML.load_file) |
This file contains hidden or 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
irb(main):001:0> a = [] | |
=> [] | |
irb(main):002:0> a << 1 | |
=> [1] | |
irb(main):003:0> a << a | |
=> [1, [...]] | |
irb(main):004:0> a | |
=> [1, [...]] | |
irb(main):005:0> |
This file contains hidden or 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
# version 1 | |
class Space | |
end | |
class Time | |
def self.and smth | |
end | |
end | |
Time.and Space |
This file contains hidden or 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
class EnableHstore < ActiveRecord::Migration | |
def up | |
enable_extension :hstore | |
rescue ActiveRecord::StatementInvalid => maybe_hstore_exception | |
if maybe_hstore_exception.original_exception.is_a? PG::UndefinedFile | |
STDERR.puts <<MSG | |
***************************************************** | |
Exception occured during enabling "hstore" extension. |
This file contains hidden or 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
# features/support/capybara_ignore_alert_after_scenario.rb | |
# if scenario failed and left modal alert after self | |
# accept it and prevent other scenarios failing | |
After '@javascript' do |scenario| | |
if scenario.failed? | |
# exception for modal dialogs | |
# http://rdoc.info/gems/selenium-webdriver/Selenium/WebDriver/Error/UnhandledAlertError | |
if scenario.exception.instance_of?(Selenium::WebDriver::Error::UnhandledAlertError) | |
page.driver.browser.switch_to.alert.accept |
This file contains hidden or 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/bash | |
# removes from PATH sections with `rbenv` | |
PATH=`echo ${PATH} | awk -v RS=: -v ORS=: '/rbenv/ {next} {print}'` | |
MINA=`which mina` | |
[ -x "$MINA" ] || (echo "mina not found: installing mina gem" && sudo gem install mina) | |
mina $* |
NewerOlder