This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Just an example. | |
# @video is a direct reference to a '<video>' element. | |
# $() is assuming jQuery is being used in this example. | |
@video.addEventListener("loadedmetadata", (event) => | |
actualRatio = @video.videoWidth/@video.videoHeight | |
targetRatio = $(@video).width()/$(@video).height() | |
adjustmentRatio = targetRatio/actualRatio | |
$(@video).css("-webkit-transform","scaleX(#{adjustmentRatio})") | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# FairTax vs. Progressive Income Tax | |
# DISCLAIMER: This of too simple and doesn't take the rebate/prebates into | |
# account but illustrates how consumption based taxation can be regressive. | |
# Current income tax brackets would be the equivalent of 16.9% of income for the middle fifth | |
# and 23.74% for the upper fifth. | |
# http://www.moneychimp.com/features/tax_brackets.htm | |
# Results in $7,361 on $44,943 of earnings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make a sauce for the headline... | |
var headlineSauce = new Sauce(); | |
headlineSauce.recipe(function(element){ | |
element.change("y").from(-200).using(Easie.bounceOut); | |
element.change("scale").from(0).using(Easie.circOut); | |
}); | |
headlineSauce.duration(1).delay(1).putOn("sauce"); | |
// Make a sauce for the tagline... | |
var taglineSauce = new Sauce(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: mergeObjects(obj1,obj2,obj3,etc) | |
mergeObjects = (objects...) -> | |
combinedObject = {} | |
for object in objects | |
combinedObject[key] = value for key,value of object | |
combinedObject |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hotSauce = new Sauce(); | |
hotSauce.addFlavor("chili",{ | |
equation: Easie.elasticOut, | |
from: -400, | |
to: 0, | |
period: 15 | |
}).addFlavor("pepper",{ | |
equation: Easie.circOut, | |
from: 0.5, | |
to: 1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<!-- Apple nicely commented all of these transitions on their source file: | |
http://images.apple.com/global/styles/productbrowser.css --> | |
<style type="text/css" media="screen"> | |
/* Just some basic presentational CSS for the example */ | |
a { | |
background: #000; display: block; color: #fff; | |
font: 1.5em "Lucida Grande", "Trebuchet MS", Verdana, sans-serif; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inspired and largely borrowed from Pixstatic | |
# http://www.pixastic.com/lib/git/pixastic/actions/noise.js | |
# https://github.com/jseidelin/pixastic | |
# And NetTuts tutorial: | |
# http://blip.tv/nettuts/how-to-generate-image-noise-with-canvas-4439977#EpisodeDescription | |
# http://net.tutsplus.com/tutorials/javascript-ajax/how-to-generate-noise-with-canvas/ | |
window.Noise = class Noise | |
constructor: -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# item.getDate() assumes you are returning a Date object from your model. | |
dateComparator: (item) -> | |
item.getDate().getTime() | |
reverseDateComparator: (item) -> | |
-item.getDate().getTime() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nodes = File.open("path/to/stylesheet.css").readlines.join("").gsub(/\n/,"").split("}").map do |chunk| | |
selectors = chunk.split("{")[0] | |
rules = chunk.split("{")[1] | |
chunk = { :selectors => selectors.split(','), :rules => rules.split(';').map{|r| [r.split(':')[0],r.split(':')[1]]} } unless rules.nil? or selectors.nil? | |
end | |
output = "" | |
nodes.each do |node| | |
unless node.nil? | |
output += node[:selectors].sort {|x,y| x.length <=> y.length }.join(",\n") + " {\n" | |
output += node[:rules].sort {|x,y| x[0] <=> y[0] }.map{|rule| " #{rule.join(": ")}"}.join(";\n") + "\n}\n\n" |