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 Anonymizer | |
include ActiveSupport::Benchmarkable | |
attr_reader :factory_names, :callbacks | |
def initialize(factory_names = nil, callbacks = {}) | |
raise ArgumentError.new("You must be in development to use the anonymizer") unless Rails.env.development? | |
require Rails.root.join("spec/factories") unless FactoryBot.factories.count > 0 | |
@factory_names = [*factory_names].compact.map(&:to_sym) |
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
#!/usr/bin/env ruby | |
require "colorize" | |
class Branch | |
attr_reader :name, :base_branch | |
def initialize(name, base) | |
@name = name | |
@base_branch = base || %x{git log -1 --format="%h" @{u}}.chomp |
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 "codeclimate-test-reporter" | |
CodeClimate::TestReporter.start | |
# output Rcov-style coverage files | |
require 'simplecov' | |
require 'simplecov-rcov' | |
class SimpleCov::Formatter::MergedFormatter | |
def format(result) | |
require "codeclimate-test-reporter" |
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
p ||= Chronic::Parser.new | |
def p.get_anchor(tokens, options) | |
puts "get_anchor", " tokens: #{tokens}" | |
grabber = Chronic::Grabber.new(:this) | |
pointer = :future | |
repeaters = get_repeaters(tokens) | |
repeaters.size.times { tokens.pop } | |
puts " grabber: #{grabber}" |
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
jQuery.fn.visibleText = function() { | |
if (this.length === 0) return null; | |
if (this.length > 1) return this.first().visibleText(); | |
if (this[0].nodeType === 3) return this.text(); | |
var buffer = []; | |
$.each(this.contents(), function(ix, e) { | |
if ($(e).is(':visible')) { | |
return buffer.push($(e).visibleText()); | |
} |
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
// | |
// Example usage: phantomjs screenshot.js http://yahoo.com /tmp/yahoo.png | |
// | |
var system = require('system'); | |
var url = system.args[1]; | |
var filename = system.args[2]; | |
var page = new WebPage(); | |
page.open(url, function (status) { |
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
tell application "Safari" | |
set _tab to the current tab of window 1 | |
tell _tab to do JavaScript "var t = escape(getSelection()); if (t.length > 0) t = '“'+t+'”: '; window.location = 'twitterrific:///post?message='+t+''+escape(window.location.href)" | |
end tell |
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' | |
def fizzbuzz_if(k) | |
k%3==0 ? (k%5==0 ? "fizzbuzz" : "fizz") : (k%5==0 ? "buzz" : k) | |
end | |
def fizzbuzz_d(k) | |
{true => {true => "fizzbuzz", false => "fizz"}, false => {true => "buzz"}}[k%3==0][k%5==0] || k | |
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
<input type='file' id='picker'> | |
<img style='border: 1px solid black' id='img'> | |
<script> | |
var onFilePicked = function(el, callback, opts) { | |
opts = opts || {} | |
var delayedCallback = function(url) { | |
setTimeout(function() {callback(url)}, 0); | |
} | |
el.onchange = el.onmouseout = function(event) { |