Skip to content

Instantly share code, notes, and snippets.

View austinrfnd's full-sized avatar

Austin Fonacier austinrfnd

  • Loot Crate
  • Los Angeles, Ca
View GitHub Profile
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
+ items.to_query
-
- def query(items)
- @query = ''
- items.each do |var|
- @query << "#{var.to_s}=" + eval("@#{var}") + "&" if eval("@#{var}")
- end
- URI.escape(@query)
- end
-
@austinrfnd
austinrfnd / 2 hour time sink
Created September 13, 2012 22:12
Discovered this in my work codebase.
encodeURIComponent(q).replace(/%20/g, '+').replace(/%2C/g, ',').replace(/%26/g, '&').replace(/%3D/g, '=').replace(/%2B/g, '+')
@austinrfnd
austinrfnd / gist:5847849
Created June 24, 2013 05:08
I found this in an ActiveRecord Model.
def email_must_be_uniq
user = User.find_by_email(email)
if user.present? && user.id =! self.id
errors.add(:email, "is already taken")
end
end
@austinrfnd
austinrfnd / gist:5856131
Created June 25, 2013 05:28
Another jewel I found in a code base
has_many :enrollments, class_name: "CourseEnrollment", conditions: "course_enrollments.role='student'", dependent: :destroy
has_many :student_enrollments, class_name: "CourseEnrollment", conditions: "course_enrollments.role='student'", dependent: :destroy
@austinrfnd
austinrfnd / gist:5887260
Created June 28, 2013 19:11
sublimetext user settings
[
{ "keys": ["super+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} }
]
def admin
if read_attribute(:admin) == "t" || read_attribute(:admin) == "1"
true
else
false
end
end
def admin=(value)
@austinrfnd
austinrfnd / gist:6128877
Created August 1, 2013 06:27
A wonder comment I found in this code base.
# TODO Still don' know what this controller is for and what to do wiith it...
@austinrfnd
austinrfnd / gist:6217640
Created August 13, 2013 03:27
Find all tags given a context of a model from Acts as Taggble!
ActsAsTaggableOn::Tag.includes(:taggings).where("taggings.taggable_type = 'Question'").select("DISTINCS tags.*")
@austinrfnd
austinrfnd / gist:2d48013a769261599090
Created October 27, 2014 15:57
Sublime Text Key Bindings
[
{ "keys": ["super+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} }
]