Skip to content

Instantly share code, notes, and snippets.

View jgarber's full-sized avatar

Jason Garber jgarber

View GitHub Profile
class HtmlTag < Parslet::Parser
root(:tag)
rule(:tag) do
( open_tag | close_tag | self_closing_tag ).as(:html_tag)
end
rule(:self_closing_tag) { str("<") >> tag_name >> attributes? >> (spaces? >> str("/")) >> str(">") }
rule(:open_tag) { str("<") >> tag_name >> attributes? >> str(">") }
rule(:close_tag) { str("</") >> tag_name >> str(">") }
@jgarber
jgarber / gist:1993171
Created March 7, 2012 13:38
Remove default field sizes in Rails 3.2.2
class ActionView::Helpers::InstanceTag
DEFAULT_FIELD_OPTIONS.delete("size")
DEFAULT_TEXT_AREA_OPTIONS.delete("rows")
DEFAULT_TEXT_AREA_OPTIONS.delete("cols")
end
@jgarber
jgarber / MIT-LICENSE.txt
Created April 4, 2012 14:57
Responsive video
Copyright (c) 2011 ZURB, http://www.zurb.com/
@jgarber
jgarber / gist:2349973
Created April 10, 2012 09:56
Spec for a tagging front-end Rails plugin or jQuery library

Need a Rails plugin that can also be used as just a jQuery library.

  • Written in CoffeeScript
  • Has Jasmine tests
  • Only requires jQuery — not jQuery UI
  • Based off of and styles itself after a single text form field
  • Can be downloaded with a minified JS version ready to go
  • Rails form helper for creating the field
  • SimpleForm detection and helper as well
  • Can specify separator characters like Tag-it
@jgarber
jgarber / wtf-commerce.php
Created May 4, 2012 23:02
ODEARGODSAVEMEFROMTHISINSANITY!!!!
<script>
function hightlightPaymentMethodLogo(payment_method_id) {
if(payment_method_id > 0) {
var payment_method_logo_id = 'payment_method_logo_' + payment_method_id;
var obj = document.getElementById(payment_method_logo_id);
obj.style['border-style'] = "solid";
obj.style['border-width'] = "2px";
obj.style['-moz-border-radius'] = "6px";
obj.style['-webkit-border-radius'] = "6px";
obj.style['border-color'] = "#00ff00";
$ rails c
1.9.2p320 :007 > ActiveRecord::Base.connection.send :postgresql_version
=> 90102
$ rake staging console
ActiveRecord::Base.connection.send :postgresql_version
=> 80311
$ rake production console
ActiveRecord::Base.connection.send :postgresql_version
@jgarber
jgarber / gist:3007310
Created June 27, 2012 22:30
Use Tmux with iTerm2 across users
brew uninstall tmux
brew install https://raw.github.com/adamv/homebrew-alt/master/other/tmux-iterm2.rb
tmux -S /tmp/pair -C new -s session_name
chmod 777 /tmp/pair
tmux -S /tmp/pair -C attach -t session_name
@jgarber
jgarber / private.xml
Created August 28, 2012 01:59
KeyRemap4MacBook setup to pair program with one Dvorak - Qwerty ⌘ typist and one Qwerty typist
<?xml version="1.0"?>
<root>
<deviceproductdef>
<productname>APPLE_INTERNAL_KEYBOARD_TRACKPAD_0x024c</productname>
<productid>0x024c</productid>
</deviceproductdef>
<deviceproductdef>
<productname>APPLE_WIRELESS_KEYBOARD_0x22c</productname>
<productid>0x22c</productid>
</deviceproductdef>
@jgarber
jgarber / big_decimal_to_digits.rb
Created October 3, 2012 17:56
BigDecimal#to_digits without trailing zero
class BigDecimalWithoutTrailingZeroes < BigDecimal
def to_digits
_, significant_digits, _, exponent = split
if zero?
'0'
elsif exponent >= significant_digits.size
to_i.to_s
else
to_s('F')
end
@jgarber
jgarber / gist:3833029
Created October 4, 2012 11:21 — forked from prathe/gist:1628799
BigDecimal#to_s without trailing zero
class BigDecimalWithoutTrailingZeroes < BigDecimal
def to_digits
_, significant_digits, _, exponent = split
if zero?
'0'
elsif exponent >= significant_digits.size
to_i.to_s
else
to_s('F')
end