Skip to content

Instantly share code, notes, and snippets.

@pariser
pariser / ___minimal_bug_repo.rb
Last active June 29, 2019 19:58
compatibility issue with 2.3.0 <= ruby <= 2.3.1 and 5.0.1 <= activesupport < 6
class Foo
private_class_method :new
singleton_class.prepend(Module.new)
public_class_method :new
end
puts Foo.method(:new)
@pariser
pariser / sorbet_spec_helper.rb
Created June 27, 2019 16:45
sorbet rspec ignore doubles
T::Configuration.call_validation_error_handler = lambda do |signature, opts|
method_file, method_line = signature.method.source_location
location = opts[:location]
suffix = "Caller: #{location.path}:#{location.lineno}\n" \
"Definition: #{method_file}:#{method_line}"
error_message = "#{opts[:kind]}#{opts[:name] ? " '#{opts[:name]}'" : ''}: #{opts[:message]}\n#{suffix}"
break if opts[:value].is_a?(RSpec::Mocks::Double)
#!/usr/bin/env bash
set -e
set -x
# To run, install aws cli tools
# Run aws configure
for bucket in `aws s3 ls | cut -d ' ' -f 3`; do
# puts each bucket into its own folder
PING 8.8.4.4 (8.8.4.4): 56 data bytes
64 bytes from 8.8.4.4: icmp_seq=0 ttl=60 time=42.250 ms
64 bytes from 8.8.4.4: icmp_seq=1 ttl=60 time=98.729 ms
64 bytes from 8.8.4.4: icmp_seq=2 ttl=60 time=7.611 ms
64 bytes from 8.8.4.4: icmp_seq=3 ttl=60 time=8.053 ms
64 bytes from 8.8.4.4: icmp_seq=4 ttl=60 time=25.205 ms
64 bytes from 8.8.4.4: icmp_seq=5 ttl=60 time=56.228 ms
64 bytes from 8.8.4.4: icmp_seq=6 ttl=60 time=92.111 ms
64 bytes from 8.8.4.4: icmp_seq=7 ttl=60 time=139.504 ms
64 bytes from 8.8.4.4: icmp_seq=8 ttl=60 time=12.042 ms
class Tesseract < Formula
desc "OCR (Optical Character Recognition) engine"
homepage "https://github.com/tesseract-ocr/"
url "https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.02.tar.gz"
sha256 "26cd39cb3f2a6f6f1bf4050d1cc0aae35edee49eb49a92df3cb7f9487caa013d"
revision 3
bottle do
revision 1
sha256 "19d4caa5ce632ca41d3b45accd7f116f6cf93688531f26437cb4833f26cc0172" => :yosemite
@pariser
pariser / git-branch-details.rb
Last active May 10, 2016 22:01 — forked from jaredatron/git-branch-details.rb
git-branch-details
#!/usr/bin/env ruby
require 'time'
require 'colored'
require 'parallel'
require 'optparse'
class GitBranchDetails
NotAGitRepository = Class.new(StandardError)
#!/usr/bin/env ruby
require 'time'
require 'colored'
require 'pry'
SPECIAL_BRANCHES = %w(
production
staging
beta
@pariser
pariser / nokogiri_pretty_print.rb
Created August 30, 2015 01:28
Augment Nokogiri with Pretty Print functionality
Nokogiri::XML::Node.class_eval do
# Print every Node by default (will be overridden by CharacterData)
define_method :should_print? do
true
end
# Duplicate this node, replace the contents of the duplicated node with a
# newline. With this content substitution, the #to_s method conveniently
# returns a string with the opening tag (e.g. `<a href="foo">`) on the first
# line and the closing tag on the second (e.g. `</a>`, provided that the
@pariser
pariser / ylogin.py
Created November 1, 2011 18:09
Y!Login
#!/usr/bin/python
import urllib
import urllib2
import re
import json
import os
from pyquery import PyQuery
import codecs
@pariser
pariser / git-new-repo.py
Created May 20, 2011 21:53
initialize current directory as a new git repository; push to remote git server
#!/usr/bin/python
import sys
import re
import os
import subprocess
import pprint
def usage(exit=None):
if exit == 0: