Skip to content

Instantly share code, notes, and snippets.

@justinfrench
justinfrench / PhotoHunt.md
Last active September 29, 2020 07:32
Photo Scavenger Hunt for Kids
  • 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 December 11, 2014 02:38
Generated by SassMeister.com.
// ----
// Sass (v3.4.7)
// Compass (v1.0.1)
// ----
.selector
@media screen and (min-width: 1024px)
&.-of-5
width: 20%
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 October 24, 2012 21:21
Using ActiveRecord::Relation in non AR classes
class NonActiveRecordModel
def initialize(relation)
@relation = relation
end
def do_stuff
@relation.some_association.where(...)
end
end
@justinfrench
justinfrench / rails_server.sh
Created August 14, 2012 10:22
Run either foreman, `rails server` (Rails 3) or `script/server` (Rails 2) based what's in the file system
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
@justinfrench
justinfrench / whatevers.css.scss
Created July 21, 2012 02:51
Bootstrap mixins
@import "twitter/bootstrap";
.whatever {
@extend .well;
}
@justinfrench
justinfrench / .gitconfig
Created May 10, 2012 04:22
git aliases for tracking and publishing branches
[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)
# 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 February 9, 2012 03:53
Target modern browsers with the :not selector
.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
}
# 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 %>