Skip to content

Instantly share code, notes, and snippets.

View stoplion's full-sized avatar
🎯
Focusing

George Norris stoplion

🎯
Focusing
  • Ottertune
  • Elsewhere
View GitHub Profile
@stoplion
stoplion / make_anchor_unless_current
Created September 12, 2012 20:45
Needed a method like link_to_unless_current but that takes a block for both failing/passing conditions and either creates a link or not from the block
def make_anchor_unless_current(options={})
if current_page?(options)
content_tag(:span, class: 'current') do
yield
end
else
link_to options do
yield
end
end
@stoplion
stoplion / aspectratio.scss
Created September 24, 2012 18:39 — forked from brianmcallister/maintain-ratio.scss
Sass mixin for a responsive box that maintains an aspect ratio.
/*
Maintain ratio mixin.
@param {List} [$ratio] Ratio the element needs to maintain. A 16:9 ratio would look like this:
.element { @include maintain-ratio(16 9); }
*/
@mixin maintain-ratio($ratio: 1 1) {
$width: 100%;
$height: percentage(nth($ratio, 2) / nth($ratio, 1));
width: $width;
@stoplion
stoplion / gist:3866787
Created October 10, 2012 16:42
coffeescript arg, callback pattern
func = ($names = {}, $callback='') ->
$proper_names = ("Mr. #{$name}" for $name of $names)
#$callback($proper_names) unless $callback?
if $callback
$callback($proper_names)
else
alert 'no callback given'
func {'bill', 'john'}, ($p_names) -> alert "i love #{$p_names}"
@stoplion
stoplion / jproportion
Created October 15, 2012 19:46
keeps things in proportion
(($, window) ->
$.extend $.fn, jproportion: (options) ->
@defaultOptions =
ratio : 1.5
settings = $.extend({}, @defaultOptions, options)
@stoplion
stoplion / Javascript: select follow links
Created November 8, 2012 15:21
javascript: select box follow links
@stoplion
stoplion / rake_notes
Created January 3, 2013 14:45
rake notes
=begin Basic Notes
a part of the standrd Ruby lib
Rake looks for Rakefile in dir
or *.rake
Globally available Rake
~/.rake dir
rake -g -T
@stoplion
stoplion / language ideas
Created January 9, 2013 16:42
language ideas
[h1..h5].each
font-size(16px + 5px)
display: none!
display: none !important
clss %w{.hide .show}

Behold, the nav_link:

The nav_link helper works just like the standard Rails link_to helper, but adds a 'selected' class to your link (or its wrapper) if certain criteria are met. By default, if the link's destination url is the same url as the url of the current page, a default class of 'selected' is added to the link.

<%= nav_link 'My Page', my_path %>

When my_path is the same as the current page url, this outputs:

<a class="selected" href="http://example.com/page">My Page</a>
@stoplion
stoplion / git ignore a commited file
Created March 20, 2013 02:29
git ignore a file already commited
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
@stoplion
stoplion / git add certain file types
Created March 23, 2013 19:13
git add all of certain file type
find . -name "*.sass" | xargs git add