Skip to content

Instantly share code, notes, and snippets.

🤘
clickity clack

Joshua Priddle itspriddle

🤘
clickity clack
Block or report user

Report or block itspriddle

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@itspriddle
itspriddle / phpunit.rb
Created Apr 17, 2013
Install PHPUnit on OS X Mountain Lion using Homebrew
View phpunit.rb
require 'formula'
class Phpunit < Formula
homepage 'http://www.phpunit.de/manual/current/en/index.html'
url 'http://pear.phpunit.de/get/phpunit.phar'
sha1 '7aaa26086ddf7cd0c517d7f52b74a53a7a1d7e29'
version 'HEAD'
def install
bin.install "phpunit.phar" => "phpunit"
View hosts
# This hosts file is brought to you by Dan Pollock and can be found at
# http://someonewhocares.org/hosts/
# You are free to copy and distribute this file, as long the original
# URL is included. See below for acknowledgements.
# Please forward any additions, corrections or comments by email to
# hosts@someonewhocares.org
# Last updated: Feb 17th, 2013 at 13:37
View gist:4756144
~ > history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head -20
882 vim
702 git
466 cd
408 ack
241 gco
232 ls
218 rm
129 mv
100 rspec
@itspriddle
itspriddle / gist:4698767
Created Feb 2, 2013
This is why you shouldn't use floating points for money in your app
View gist:4698767
~ > node -e "console.log((0.1 + 0.2) + 0.3 == 0.1 + (0.2 + 0.3))"
false
~ > php -r "var_dump((0.1 + 0.2) + 0.3 == 0.1 + (0.2 + 0.3));"
bool(false)
~ > ruby -e "p (0.1 + 0.2) + 0.3 == 0.1 + (0.2 + 0.3)"
false
~ > python -c "print (0.1 + 0.2) + 0.3 == 0.1 + (0.2 + 0.3)"
View gfm
#!/usr/bin/env ruby
# Usage:
# gfm <files>
#
# Examples:
#
# gfm README.markdown
# echo "# Test" | gfm
# echo "# Test" | gfm - README.markdown
# gfm
View gist:4155109
#!/usr/bin/env ruby
#
# Usage: rebundle gem_name
#
# The script will remove the gem dependency tree from the lockfile and bundle.
LOCKFILE_NAME = "Gemfile.lock"
lockfile = File.readlines(LOCKFILE_NAME)
View i18n.rb
# Always raise errors when I18n translations are missing. To override this
# behavior:
#
# I18n.t :some_key, allow_missing: false
I18n.exception_handler = -> exception, locale, key, options do
if options.delete(:allow_missing)
I18n::ExceptionHandler.new.call(exception, locale, key, options)
else
raise I18n::MissingTranslationData.new(locale, key, options)
end
View struct.rb
class Struct
def to_hash
Hash[each_pair.to_a]
end
end
View .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
@itspriddle
itspriddle / or.rb
Created Jul 6, 2012
Why not Object#or
View or.rb
class Object
def or(fallback)
self || fallback
end
end
1.or :name
=> 1
nil.or :name
You can’t perform that action at this time.