This file contains 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
/* ripped off from ea1.co */ | |
/* (just add vendor prefixes) */ | |
body { | |
animation: background-animation-cool 5s linear infinite alternate; | |
} | |
section:nth-child(2n+1) { | |
animation: background-animation-warm 5s linear infinite alternate; | |
} |
This file contains 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
# from http://makandracards.com/makandra/18605-you-don-t-need-each-collect-or-select-in-coffeescript | |
## each | |
for item in items | |
... | |
## collect / map | |
ages = (person.age for person in people) | |
## select / grep |
This file contains 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
function isValidEmail(input) { | |
var trimmedInput = $.trim(input), | |
hasSpaces = trimmedInput.indexOf(' ') !== -1, // true if no spaces | |
matchesBasicEmailPattern = trimmedInput.match(/@.*[.]/); | |
return matchesBasicEmailPattern && !hasSpaces; | |
} |
This file contains 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
html | |
font-size: 62.5% | |
body | |
font-size: 1.6rem // = 16px |
This file contains 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
validateEmail = (email, input) -> | |
emailPattern = /^[A-Za-z0-9](([_\.\-+]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$/i | |
if emailPattern.test(email) | |
addSuccessCookie() | |
return true | |
else | |
input.addClass('fail') | |
return false | |
addSuccessCookie = () -> |
This file contains 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
require 'sinatra' | |
require 'haml' | |
$users = {'john' => {:roles => [:user] }, 'mike' => {:roles => [:user, :admin] } } | |
$tokens = {'123' => {:username => 'john', :expires_at => Time.now+60}} | |
helpers do | |
def authenticate_user! | |
@auth_token = auth_token | |
if $tokens.has_key?(@auth_token) && !$tokens[@auth_token][:expires_at].nil? && $tokens[@auth_token][:expires_at] > Time.now |
This file contains 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
# add this line to your .bash-profile (.bashrc should also work) | |
# call this in a repo folder with `git-recent` | |
alias git-recent="git for-each-ref --count=5 --sort=-committerdate refs/heads/ --format='🌺 %(refname:short)'" |
This file contains 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
# bouncy links | |
$('a').each -> | |
$(this).mousemove (e) -> | |
if this.isAlreadyAnimating | |
console.log 'still animating: ', this.isAlreadyAnimating | |
else | |
baseExpX = 4 # 2 ^ 4 == 16 | |
baseExpY = 2 # 2 ^ 4 == 16 |
This file contains 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
target = $('body') | |
# get random RGB values so we can change background and link colors | |
r = Math.floor Math.random() * 241 | |
g = Math.floor Math.random() * 241 | |
b = Math.floor Math.random() * 241 | |
# variables to hold the lighter shade RGB values | |
# rp1; gp1; bp1; rp2; gp2; bp2; rp3; gp3; bp3 |
This file contains 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
dothis = -> | |
console.log 'do this' | |
dothistoo = -> | |
console.log 'do this too' | |
dox = -> | |
console.log 'do x' | |
text = (x) -> |