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
| ADD2 = ->(a) { a + 2 } | |
| DIV3 = ->(a) { a / 3 } | |
| (ADD2 + DIV3).call(4) | |
| # == 3 | |
| (DIV3 + ADD2).call(4) | |
| # == 2 | |
| # Note: the order is important here |
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 Proc | |
| def +(other) | |
| Proc.new { |args| self.call(other.call(arg)) } | |
| end | |
| end |
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
| add_2_div_3 = (add_2 . div_3) |
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
| def self.add_2_div_3(a) | |
| div_3(add_2(a)) | |
| end | |
| puts add_2_div_3(4) | |
| # Print 2 | |
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
| def self.add_2(a) | |
| a + 2 | |
| end | |
| def self.div_3(a) | |
| a / 3 | |
| end |
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
| require 'benchmark' | |
| require 'benchmark/ips' | |
| Benchmark.ips do |r| | |
| r.report('merge!') do | |
| (1..100).inject({}) do |h, e| | |
| h.merge!(e => e) | |
| end | |
| end | |
| ref = (1..100).to_a | |
| r.report('Hash[]') do |
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
| #! /usr/bin/ruby | |
| file, line = (ARGV.shift || raise('Missing loc. Ex: /path/to/file:line')).split(/:/) | |
| exec "git show $(git blame #{file} -L #{line},#{line} | awk '{print $1}')" |
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
| [NewRelic][11/26/14 15:26:13 +0000 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX (2)] WARN : Timed out opening connection to collector after 120.003031938 seconds. If this problem persists, please see http://status.newrelic.com |
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
| function fuck() { | |
| if killall -9 "$2" 2>/dev/null; then | |
| echo ; echo " (╯°□°)╯︵$(echo "$2"|toilet -f term -F rotate)"; echo | |
| fi | |
| } |
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
| function get_free_port_starting_from() { | |
| local PORT=$1 | |
| local QUIT=0 | |
| while [ "$QUIT" -ne 1 ]; do | |
| lsof -i :$PORT> /dev/null | |
| if [ $? -ne 0 ] | |
| then | |
| QUIT=1 | |
| else | |
| PORT=`expr $PORT + 1` |
NewerOlder