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 TrueClass | |
def do(_if: ->{}, _else: ->{}) | |
_if.call | |
self | |
end | |
end | |
class FalseClass | |
def do(_if: ->{}, _else: ->{}) | |
_else.call |
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 Foobar < ActiveRecord::Base | |
attr_accessor :foobar | |
def as_json(options = {}) | |
options[:methods] ||= [] | |
options[:methods] << :foobar | |
super(options) | |
end | |
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
hasQueryVariable = (variable)-> | |
query = window.location.search.substring(1) | |
queryVars = query.split("&") | |
for queryVar in queryVars | |
queryKv = queryVar.split("=") | |
if queryKv[0] == variable | |
#Return true as soon as we find the variable nam | |
return true |
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
Foo.transaction do | |
Foo.connection.execute("CREATE TEMPORARY TABLE temp_foos ON COMMIT DROP AS (SELECT *, RANDOM() AS rank FROM foos)") | |
Foo.select("temp_foos.*").from("temp_foos").order("rank").find_each do |foo| | |
#whatever | |
end | |
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
# Load *.bash files in the .bashrc.d directory. Put bash config files there. | |
export $BASH_D=$HOME/.bashrc.d | |
if [ -d $BASH_D ]; then | |
for conf in $BASH_D/*.bash; do | |
. $conf | |
done | |
fi |
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
setup: &SETUP | |
adapter: postgresql | |
encoding: utf8 | |
reconnect: true | |
pool: 5 | |
timeout: 5000 | |
production: | |
<<: *SETUP | |
database: <project_name>_production |
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
describe TTT::ConsolePrinter | |
subject{TTT::ConsolePrinter.new(output)} | |
let(:output) {StringIO.new("")} | |
let(:board) {...} | |
it "should be awesome" do | |
subject.print(board) | |
expect(output.read).to eq("An awesome TTT board") | |
end | |
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
class LinkedList | |
def initialize(items) | |
items = Array(items) | |
if items.size == 1 | |
@value = items[0] | |
else | |
@value, @next = items[0], LinkedList.new(items[1..-1]) | |
end | |
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
<tr> | |
<td><%= hours[:paylocity_id] %></td> | |
<td>E</td> | |
<td>REG</td> | |
<td><%= hours[:regular_hours] %></td> | |
</tr> | |
<tr> | |
<td><%= hours[:paylocity_id] %></td> | |
<td>E</td> | |
<td>OT</td> |
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
" Reset to preferred behaviour {{{ | |
set norelativenumber | |
set number | |
" }}} | |
" Extra setup {{{ | |
" General {{{ | |
set softtabstop=2 | |
set shiftwidth=2 |