a list of slides from nodeconf
you may want to take a look at the jsconf-gist too!
import { STAR_PERSON, MET_PERSON, UPDATE_NOTES, SET_URL } from '../constants/action-types' | |
import { LS_KEY } from '../constants/localstorage-keys' | |
import tryit from 'tryit' | |
import debounce from 'lodash.debounce' | |
const userPreferenceActions = [STAR_PERSON, MET_PERSON, UPDATE_NOTES] | |
function writeToLocalStorage (getState) { | |
let data = { | |
starred: {}, |
// If you don't use underscore.js, use it (http://documentcloud.github.com/underscore/) | |
// Then, use underscore's mixin method to extend it with all your other utility methods | |
// like so: | |
_.mixin({ | |
escapeHtml: function () { | |
return this.replace(/&/g,'&') | |
.replace(/>/g,'>') | |
.replace(/</g,'<') | |
.replace(/"/g,'"') | |
.replace(/'/g,'''); |
<html lang="en-US" jsl="$t t-Tkdr7Li1J_A;$x 0;" jsvs="true;'en-US';" jsan= | |
"t-Tkdr7Li1J_A,0.lang" xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta name="generator" content= | |
"HTML Tidy for Linux/x86 (vers 25 March 2009), see www.w3.org" /> | |
<meta charset="utf-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<title>Inbox – hjoreteg@gmail.com</title> | |
<link class="i1Vy9" href= |
export default (fn, ...args) => { | |
if (typeof window !== 'undefined') { | |
fn(...args) | |
} else { | |
const last = args.slice(-1)[0] | |
let argString = '' | |
if (typeof last !== 'undefined') { | |
argString = args.reduce((accum, val, index) => { | |
const type = typeof val | |
const isLast = index === args.length - 1 |
import { DO_THING, DO_OTHER_THING, SOMETHING_ELSE } from './actions' | |
export default (state, { type, payload }) => { | |
switch (type) { | |
case DO_THING: { | |
// by using blocks in our case statements we can create locally scoped vars | |
// and returning early keeps things readable | |
const scopedVariable = payload.thing | |
return Object.assign({}, state, {do: scopedVariable}) | |
} |
export default (cb) => { | |
ensurePromise(() => { | |
ensureFetch(cb) | |
}) | |
} | |
const ensurePromise = (cb) => { | |
if (typeof Promise === 'undefined') { | |
require.ensure([], (require) => { | |
require('imports?this=>window!es6-promise') |
/* | |
Building a module this way allows you to do this on the client: | |
<script src="underscore.js"></script> | |
<script src="myutils.js"></script> | |
Then use it in your code as children of '_' without polluting your global namespace. | |
_.myFunction(); |
a list of slides from nodeconf
you may want to take a look at the jsconf-gist too!
var fermata = require('fermata'), | |
uuid = require('node-uuid'); | |
var apiKey = 'YOUR_API_KEY'; // should probably be imported from an external keys file | |
var site = fermata.api({url: 'https://api.postageapp.com/v.1.0'}); | |
exports.send = function (details, cb) { | |
site['send_message.json'].post(details, cb); | |
}; |
=text_shadow($color, $x, $y, $blur) | |
:text-shadow = $color $x $y #{$blur}px | |
=box_shadow($color, $x, $y, $blur) | |
:-webkit-box-shadow = $color $x $y #{$blur}px | |
:-moz-box-shadow = $color $x $y #{$blur}px | |
:box-shadow = $color $x $y #{$blur}px | |
=inner_shadow($color, $x, $y, $blur) | |
:box-shadow = inset $color $x $y #{$blur}px |