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
class Foo | |
def self.bar(&block) | |
instance_exec(&block) | |
end | |
attr_accessor :x | |
end | |
Foo.bar do | |
x = 5 |
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 "simplecov" | |
SimpleCov.command_name "unit:#{Process.pid}" | |
SimpleCov.at_exit do | |
orig, $stdout = $stdout, File.open("/dev/null", "w") | |
SimpleCov.result.format! | |
$stdout, orig = orig, nil | |
end | |
SimpleCov.start |
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
class RingBuffer | |
attr_reader :capacity, :size | |
def initialize(capacity) | |
@array = Array.new(capacity) | |
@capacity = capacity | |
@read_index = 0 | |
@size = 0 | |
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
- hosts: servers | |
roles: | |
- role: server | |
some_variable: | |
{{ port }}: | |
internal: "{{ groups['clients'] }}" | |
external: | |
- 1.2.3.4 |
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 are instructions to run terco on login on Mac OS X. | |
1. Install terco using the system ruby (sudo gem install terco). | |
2. Copy the script below to ~/Library/LaunchAgents/com.soveran.terco.plist. You may have to replace `/usr/local/bin/terco`, if terco has been installed to a different directory (use `which terco` to find out). | |
3. Load the script using the command | |
sudo launchctl load ~/Library/LaunchAgents/com.soveran.terco.plist | |
To make a domain resolve to localhost follow these instructions: |
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 does_care(*a) | |
"hi" | |
end | |
def cares_a_little(*_a) | |
"hi" | |
end | |
def does_not_care(*_) | |
"hi" |
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 fish_right_prompt -d "Write out the right prompt" | |
set -l exit_code $status | |
set -l is_git_repository (git rev-parse --is-inside-work-tree 2> /dev/null) | |
set -l max_shlvl 1; and test "$TERM" = "screen"; and set -l max_shlvl 2 | |
# Print a fork symbol when in a subshell | |
if test $SHLVL -gt $max_shlvl | |
set_color yellow | |
echo -n "⑂ " | |
set_color normal |
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 jump -d "Jumps to a marked directory" | |
# If $JUMP_PATH isn't set, use a default (~/.config/jump). | |
if set -q $JUMP_PATH | |
set JUMP_PATH $HOME/.config/jump | |
end | |
# If the $JUMP_PATH directory doesn't exist, create it. | |
if not test -d $JUMP_PATH | |
mkdir -p $JUMP_PATH | |
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
["Del", "Delmar", "mar", "mariachi", "chickpea", "pea", "peahen", "henpecking", "ingraining", "ingratiated", "tedious", "ousters", "ersatzes", "zest", "estranging", "ingenuously", "sly", "slyness", "essayist", "isthmus", "mushing", "ingredient", "entertainment", "entryway", "waywardness", "essences", "cession", "ion", "ionization", "ionizer", "zeros", "roses", "sesame", "amelioration", "ionosphere", "erection", "ionospheres", "resale", "alerted", "tediously", "slyest", "establishment", "entrenchment", "entombed", "bedevilment", "entailing", "inglorious", "ousting", "ingested", "tediousness", "essay", "saying", "ingrown", "ownership", "hippie", "piercingly", "glycerin", "ringing", "ingrains", "insurgent", "entertainingly", "glycerol", "rolling", "ingenuousness", "essaying", "ingenuous", "ouster", "terracing", "ingesting", "ingratiating", "ingestion", "ionizing", "ingot", "got", "gotten", "tensing", "ingrates", "testable", "blest", "estimations", "onshore", "ore", "ores", "restructure", "urea", "rears", "arseni |
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 "benchmark/ips" | |
input = %w[one two three four five six seven] | |
Benchmark.ips do |x| | |
x.report "Array#join" do | |
Regexp.new input.map { |e| Regexp.escape e }.join "|" | |
end | |
x.report "Regexp.union" do |
NewerOlder