Skip to content

Instantly share code, notes, and snippets.

Avatar

Justin French justinfrench

View GitHub Profile
@justinfrench
justinfrench / PhotoHunt.md
Last active Sep 29, 2020
Photo Scavenger Hunt for Kids
View PhotoHunt.md
  • The letter X
  • The letter Y
  • The letter Z
  • Roman numerals
  • The number 7
  • A Yellow flower
  • A Purple flower
  • A Red flower
  • An Orange flower
  • Something shiny
@justinfrench
justinfrench / SassMeister-input.sass
Created Dec 11, 2014
Generated by SassMeister.com.
View SassMeister-input.sass
// ----
// Sass (v3.4.7)
// Compass (v1.0.1)
// ----
.selector
@media screen and (min-width: 1024px)
&.-of-5
width: 20%
View patch.rb
def validator_relevant?(validator)
return true unless validator.options.key?(:if) || validator.options.key?(:unless)
conditional = validator.options.key?(:if) ? validator.options[:if] : validator.options[:unless]
result = if conditional.respond_to?(:call)
object.instance_exec(&conditional)
elsif conditional.is_a?(::Symbol) && object.respond_to?(conditional)
object.send(conditional)
else
conditional
@justinfrench
justinfrench / omg.rb
Created Oct 24, 2012
Using ActiveRecord::Relation in non AR classes
View omg.rb
class NonActiveRecordModel
def initialize(relation)
@relation = relation
end
def do_stuff
@relation.some_association.where(...)
end
end
@justinfrench
justinfrench / rails_server.sh
Created Aug 14, 2012
Run either foreman, `rails server` (Rails 3) or `script/server` (Rails 2) based what's in the file system
View rails_server.sh
function s()
{
# Look for a .env file, run foreman with -p 3000 for consistency
if [ -e ".env" ]
then
foreman start -p 3000
# Look for "script/rails" (Rails 3)
elif [ -e "script/rails" ]
then
script/rails server
View whatevers.css.scss
@import "twitter/bootstrap";
.whatever {
@extend .well;
}
@justinfrench
justinfrench / .gitconfig
Created May 10, 2012
git aliases for tracking and publishing branches
View .gitconfig
[alias]
current-branch = !git branch | grep '^*' | sed s/\\*\\ //
track = !git branch --set-upstream $(git current-branch) origin/$(git current-branch)
publish = !git push origin $(git current-branch) && echo $(git track)
View gist:2362758
# Expected h1 title for posts#show is "My Blog :: My Post Title"
# --------------------------------------------------------------
# This was how it worked with `layout nil` in the controller
#
# posts_controller.rb
class PostsController
layout nil
@justinfrench
justinfrench / gist:1777140
Created Feb 9, 2012
Target modern browsers with the :not selector
View gist:1777140
.something {
rules for older browsers like IE6–8
}
.something:not(.crappy) {
extra rules for any browser that supports :not selector
the .crappy class is a hack, but it feels appropriate
}
View gist:1727546
# PRODUCT MODEL
has_many :product_people
has_many :people, :through => :product_people
accepts_nested_attributes_for :people
<%= f.inputs "Cast" do %>
<%= f.inputs :for => :people do |p| %>
<%= p.input :name %>
<%= p.input :_destroy, :as => :boolean %>
You can’t perform that action at this time.