Skip to content

Instantly share code, notes, and snippets.

Avatar

Jamie thelucid

View GitHub Profile
@thelucid
thelucid / tache-layouts.rb
Last active August 29, 2015 13:57
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 December 27, 2015 00:19
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">
@thelucid
thelucid / issue-3144.rb
Last active December 21, 2015 04:29 — forked from anonymous/issue-3144.rb
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 July 19, 2013 12:51
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 December 18, 2015 05:09
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 December 18, 2015 05:09
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 January 2, 2013 19:31
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 January 2, 2013 18:29
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!'