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 onlyUnique(value, index, self) { | |
return self.indexOf(value) === index; | |
} | |
function findMatchingRoutes(routes, urlPath, ancestors) { | |
var result = []; | |
ancestors = ancestors || []; | |
routes.forEach(function (route) { |
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
// Example of async form validation in ampersand | |
// Has default `ampersand-input-view` clientside validation. | |
// If clientside validation passes, async validation is called 1 sec after input to check if given username exists | |
var FormView = require('ampersand-form-view'); | |
var InputView = require('ampersand-input-view'); | |
var debounce = require('amp-debounce'); | |
var extend = require('amp-extend'); |
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 px-to-rem($val, $base: 16) { | |
// if it's a unitless number | |
@if type-of($val) == number and unitless($val) { | |
// don't convert 0 | |
@if $val == 0 { | |
@return 0; | |
} | |
// assume its px and convert it to rem based on $base document font-size | |
@return #{$val / $base}rem; | |
} |
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
#!/bin/sh | |
# Alot of these configs have been taken from the various places | |
# on the web, most from here | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# Set the colours you can use | |
black='\033[0;30m' | |
white='\033[0;37m' | |
red='\033[0;31m' |
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
javascript:(function(d,g,a,b,c,e,f,h,n,t,u,w,x){f=function(e,o,k){for(k in o)e.setAttribute(k,o[k])};c=function(e){return d.createElement(e)};n=function(s){return d.createTextNode(s)};a=function(e,c,k){for(k in c)e.appendChild(c[k])};w=c(g);h=c(g);t=n('Toggle Style-Elements');u=c('ul');b=d.querySelector('body');x='position:fixed;top:0;right:0;z-index:99999;margin:0;padding:0;background:#f4fff4;color:#99ad85;font:14px Helvetica,Arial,sans-serif;border:1px solid #bada55;border-top-width:0;border-right-width:0;border-bottom-left-radius:10px;';e=d.getElementById('tcss');if(b&&e)f(e,{style:x+(e.style.display=='none'?'':'display:none')});else if(b){f(w,{id:'tcss',style:x});f(h,{style:'font:20px Georgia,serif;padding:10px;margin:0;background:#dae7da;color:#693'});f(u,{style:'margin:0;padding:10px;list-style-type:disc'});f(u,{style:'margin:0;padding:10px;list-style-type:disc;'});a(b,[w]);a(w,[h,u]);a(h,[t]);[].slice.call(d.styleSheets).forEach(function(s,i,l,m,y,z){y='margin:0 0 0 20px;padding:0;cursor:pointer;line-h |
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
var server = new (require('hapi')).Server('localhost', 8000); | |
server.method('registered', function(request, reply) { | |
console.log('registered', reply()); | |
}); | |
server.route({ | |
method: 'GET', | |
path: '/', | |
config: { |
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
plugin.method('users.validate', function(request, reply) { | |
User.find({ $or: [ | |
{ email: request.payload.email }, | |
{ username: request.payload.username } | |
]}, function(err, user) { | |
if (err || user) { | |
return reply({ error: 'db error or username/email exists' }).takeover(); | |
} | |
reply(); | |
}); |
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
.outer { | |
height: 400px; | |
overflow: auto; | |
position: relative; | |
width: 200px; | |
} | |
.inner { | |
height: 1200px; | |
zoom: 1; | |
} |
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
class TodoModel | |
constructor: -> | |
@todos = [] | |
@callbacks = [] | |
add: (name) -> | |
@todos.push name: name, completed: false | |
@handleChange 'add', name | |
onChange: (callback) -> | |
@callbacks.push callback | |
handleChange: (type, value) -> |
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
<body> | |
<svg xmlns:xlink="http://www.w3.org/1999/xlink"> | |
<a> | |
<text y="1em">Click me</text> | |
<animate attributeName="xlink:href" values="#;#;#;#;#;javascript:alert('Bang!')" begin="0s" dur="0.1s" fill="freeze" repeatCount="indefinite"/> | |
</a> | |
</svg> | |
</body> |