🏳️⚧️
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
# Adapted from from: http://nestegg.rubyforge.org/ | |
module NestedException | |
# Public: Initializes a new nested error, the original error defaults | |
# to the global error variable so that it doesn't need to be explicity | |
# provided when re-raising an exception. | |
def initialize(message = nil, cause = $!) | |
@cause = cause | |
super(message || cause && cause.message) | |
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
LOG_PATTERN = /^(INFO|DEBUG)\t[-0-9]+ [:0-9]+\t/ | |
def filter_and_format(log, level) | |
log.each_line.with_object("") { |line, filtered| | |
next unless line.start_with?(level) | |
filtered << line.sub(LOG_PATTERN, '') | |
} | |
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 'date' | |
module Blackboxx | |
class Logger | |
# TODO false value supresses logging | |
def initialize(output, options = {}) | |
@output = output | |
@echo_to_stdout = options.fetch(:echo_to_stdout) { output != STDOUT } | |
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
/** | |
* {@internal Missing Short Description}} | |
* | |
* {@internal Missing Long Description}} | |
* | |
* @since 1.5.0 | |
* | |
* @param unknown_type $queries | |
* @param unknown_type $execute | |
* @return unknown |
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
Environment::build( function () { | |
$api_key = 'ABC123'; | |
$partials_path = array('app/views/'); | |
}); | |
// Dumps something like this: | |
// => array('api_key' = 'ABC123', $partials_path => array('app/views/')) | |
// The method should be able to digest things like $api_key into an actual API connection instance. |
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 UserEmitter | |
include Enumerable | |
def initialize(path) | |
@table = CSV.table(path, skip_blanks: true) | |
@enumerator = Fiber.new do | |
@table.each do |row| | |
Fiber.yield UserImporter.import(merchant, row) | |
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
$ ruby -rbase64 -e "puts Base64.encode64('foo:bar')" | |
> Zm9vOmJhcg== | |
$ echo "foo:bar" | base64 | |
> Zm9vOmJhcgo= | |
$ curl -u foo:bar -v http://httpbin.org | |
> GET / HTTP/1.1 | |
> Authorization: Basic Zm9vOmJhcg== |
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 | |
# Summons a Quicklook window and then returns focus to the terminal. | |
# | |
# TODO: Support other terminal emulators | |
# | |
# Usage: | |
# $ ql ~/example.jpg | |
set -e |
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 'awesome_print' | |
# require 'map_by_method' | |
if require 'hirb' | |
Pry.config.print = proc do |output, value| | |
Hirb::View.view_or_page_output(value) || Pry::DEFAULT_PRINT.call(output, value) | |
end | |
Hirb.enable | |
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
# Eliot, two parts of ETL. | |
# | |
# Yes, in the movie it's Eliott (with TWO Ts), but no one wants to | |
# type that every time. | |
# | |
# | |
# Handles extracting data from multiple formats, CSV, JSON, YAML, XML? | |
# Handles transforming records into models using attributes hash or | |
# assignment. | |
# |