Skip to content

Instantly share code, notes, and snippets.

Jamie Hill thelucid

View GitHub Profile
@thelucid
thelucid / tache-layouts.rb
Last active Aug 29, 2015
Layouts with Tache
View tache-layouts.rb
require 'tache'
layout = <<-eos
<html>
<head>
<title>{{#layout.title}}Default Title{{/layout.title}}</title>
</head>
<body>
{{#layout.content}}Default Content{{/layout.content}}
</body>
@thelucid
thelucid / gist:7237043
Last active Dec 27, 2015
Semantic sections without the need for class names using aria-labelledby. Has the bonus of being able to link to each section with an anchor.
View gist:7237043
<!-- Suck on this BEM! -->
<section aria-labelledby="latest-products">
<h2 id="latest-products">Latest Products</h2>
<ul>
...
</ul>
</section>
<section aria-labelledby="press-news">
View issue-3144.rb
Mongoid.connect_to 'mongoid-3144'
class Post
include Mongoid::Document
field :name
embeds_many :comments
accepts_nested_attributes_for :comments
# This line somehow triggers the bug; commenting it out fixes the bug, wierd.
@thelucid
thelucid / osx-tabs.sh
Created Jul 19, 2013
OSX Terminal – Tab and window shortcuts
View osx-tabs.sh
function tabname {
# Will use current dir name if called without arg.
printf "\e]1;${1-$(basename `pwd`)}\a"
}
function winname {
# Will use current dir name if called without arg.
printf "\e]2;${1-$(basename `pwd`)}\a"
}
function tab {
# Will cd into current dir if called without arg.
@thelucid
thelucid / scale.scss
Last active Dec 18, 2015
Modular scale and golden ratio with SCSS.
View scale.scss
// Example usage:
// $size-1: 13;
// $size-2: 15;
// $size-3: golden($size-1, 1);
// $size-4: golden($size-2, 1);
// $size-5: golden($size-1, 2);
// $size-6: golden($size-2, 2);
//
// In conjunction with rhythm (https://gist.github.com/thelucid/5730434):
// @include font($size-3);
@thelucid
thelucid / rhythm.scss
Last active Dec 18, 2015
Rhythm and rems with SCSS
View rhythm.scss
$rhythm-base: 16;
$rhythm-size: 26;
// Converts any non-zero, unitless number values from pixels to rems
// with a pixel fallback for old browsers.
//
// Example:
// @include rem('padding', 32 5%);
//
// Output:
@thelucid
thelucid / gist:4437186
Created Jan 2, 2013
Tache - Drop Shorthand
View gist:4437186
require 'tache/safe'
# ORM-like base class
class Model
def initialize(attributes = {})
attributes.each { |key, value| send "#{key}=", value }
end
def destroy
'Successfully destroyed!'
@thelucid
thelucid / gist:4436684
Created Jan 2, 2013
Tache - Drop Longhand
View gist:4436684
require 'tache/safe'
# ORM-like base class
class Model
def initialize(attributes = {})
attributes.each { |key, value| send "#{key}=", value }
end
def destroy
'Successfully destroyed!'
You can’t perform that action at this time.