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
#!/bin/bash | |
# meme.sh | |
# https://gist.github.com/joshuaflanagan/77f31411d137aec9b9c1b79b42d339f8 | |
# Meme generator with ImageMagick | |
# https://www.it-cooking.com/technology/digital-image/image-processing/meme-generator-imagemagick/ | |
usage() { | |
echo "Usage: $0 [ -t TOP_MSG ] [ -b BOTTOM_MSG ] [ -s FONTSIZE=80] [ -a TOP_FONTSIZE=80 ] [ -z BOTTOM_FONTSIZE=80 ] SRC DST" |
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 ActiveRecord::Base | |
# Find a record by UUID primary key prefix | |
# | |
# Example: | |
# > User.fish "1245" | |
# # User Load (0.3ms) SELECT "users".* FROM "users" WHERE ("users"."id" BETWEEN '12450000000000000000000000000000' AND '1245ffffffffffffffffffffffffffff') LIMIT $1 [["LIMIT", 2]] | |
# => #<User id: "12451304-761d-4e1d-8281-40aa6213b633", name: "josh"> | |
def self.fish(partial_id) | |
return find(partial_id) unless partial_id.is_a?(String) | |
scrubbed = partial_id.gsub(/[^a-fA-F0-9]/, "") |
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
# Ruby 2.1.2 | |
2.1.2 :173 > x = BigDecimal.new(1.0, 1) | |
=> #<BigDecimal:7ffcee09bb98,'0.1E1',9(27)> | |
2.1.2 :174 > y = Marshal.load Marshal.dump x | |
=> #<BigDecimal:7ffcec5d9ee0,'0.1E1',9(18)> | |
2.1.2 :175 > x == y | |
=> true | |
2.1.2 :176 > Marshal.dump(x) == Marshal.dump(y) | |
=> false |
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 no_surprises! | |
ActiveRecord::Base.class_eval do | |
include SkipsValidations | |
include SkipsCallbacks | |
end | |
end | |
module SkipsValidations | |
def perform_validations(*) | |
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
# http://www.w3.org/TR/PNG/#5DataRep | |
class PNGCheck | |
def initialize(path) | |
@path = path | |
end | |
def check_all! | |
expected_signature = [137, 80, 78, 71, 13, 10, 26, 10] | |
file.seek 0 | |
signature_data = file.read(8) |
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
http -v -a username:password POST https://api.github.com/repos/owner/repo/git/refs ref="refs/heads/recovered_branch" sha="290b2090a741d35edd67f15c74b2d43299df8995" | |
git fetch | |
git checkout recovered_branch |
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
name | default_version | installed_version | comment | |
------------------------+-----------------+-------------------+--------------------------------------------------------------------- | |
pg_buffercache | 1.0 | | examine the shared buffer cache | |
earthdistance | 1.0 | | calculate great-circle distances on the surface of the Earth | |
pg_freespacemap | 1.0 | | examine the free space map (FSM) | |
intagg | 1.0 | | integer aggregator and enumerator (obsolete) | |
plperl | 1.0 | | PL/Perl procedural language | |
sslinfo | 1.0 | | information about SSL certificates | |
btree_gist | 1.0 | | support for indexing common datatypes in GiST | |
fuzzystrmatch | 1.0 |
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
// ==UserScript== | |
// @name Pull Request Labels | |
// @namespace http://joshuaflanagan.com | |
// @include https://github.com/*/*/pulls | |
// @version 1 | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js | |
// ==/UserScript== | |
$(function(){ | |
var $pull_requests = $(".pulls-list .list-browser-item h3"); | |
$pull_requests.each(function(){ |
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
# I used this to monitor changes to the .git folder during | |
# my Austin on Rails lightning talk on Understanding Git. | |
# | |
# I ignore any changes to the .git/logs folder, because they are | |
# noisy and don't add a lot to understanding. | |
# If you want "the whole truth", remove the :ignore parameter below. | |
# | |
# ruby listen.rb <path to .git folder> | |
# | |
# gem install listen # its the foundation of Guard |
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 'test/unit' | |
require 'delegate' | |
# These tests demonstrate some unexpected (to me) | |
# behavior of a class created by DelegateClass. | |
# An instance of a DelegateClass created class does not eql? itself. | |
# | |
# The WidgetTests all pass. | |
# The comparison and eql WidgetWrapperTests fail. | |
# ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0] |
NewerOlder