Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
| // It is important to declare your variables. | |
| (function() { | |
| var foo = 'Hello, world!'; | |
| print(foo); //=> Hello, world! | |
| })(); | |
| // Because if you don't, the become global variables. | |
| (function() { |
| function getMetaProperty($, wantedProperty) { | |
| var meta = $('meta'); | |
| var keys = Object.keys(meta); | |
| var metaProperty; | |
| keys.forEach(function (key) { | |
| if (meta[key].attributes && meta[key].attributes.property && meta[key].attributes.property.value === wantedProperty) { | |
| metaProperty = meta[key].content; | |
| } |
| exports.ext = function () { | |
| var extTypes = { | |
| "3gp" : "video/3gpp" | |
| , "a" : "application/octet-stream" | |
| , "ai" : "application/postscript" | |
| , "aif" : "audio/x-aiff" | |
| , "aiff" : "audio/x-aiff" | |
| , "asc" : "application/pgp-signature" | |
| , "asf" : "video/x-ms-asf" | |
| , "asm" : "text/x-asm" |
| //global variable | |
| test = 'hello'; | |
| //is exactly the same as | |
| global.test = 'hello'; | |
| //local variable - this will definitly override your global variable | |
| var test = 'world'; | |
| //using the process scope, if, and really if, you can't do without a global variable |
| var debug = require('debug')('mongoose-setup') | |
| module.exports.db = function (mongoose, config){ | |
| function connect() { | |
| mongoose.connect(config.get('mongo_url')); | |
| } | |
| // connection is open and ready | |
| mongoose.connection.on('open', function (ref) { | |
| debug('open connection to mongo server.'); |
| (function() { | |
| var CSSCriticalPath = function(w, d, opts) { | |
| var opt = opts || {}; | |
| var css = {}; | |
| var pushCSS = function(r) { | |
| if(!!css[r.selectorText] === false) css[r.selectorText] = {}; | |
| var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/); | |
| for(var i = 0; i < styles.length; i++) { | |
| if(!!styles[i] === false) continue; | |
| var pair = styles[i].split(": "); |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset=utf-8 /> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <h2>Original CSS</h2> | |
| <style style="display: block; white-space: pre; font-family: monospace"> | |
| h2 { margin:0; } |
| /** @jsx React.DOM */ | |
| 'use strict'; | |
| var React = require('react'); | |
| var MasonryMixin = require('./react-masonry-mixin.js'); | |
| var masonryOptions = { | |
| transitionDuration: 0 |
| var StoreListenerMixin = function(...stores) { | |
| var StoreMixin = { | |
| getInitialState() { | |
| return this.getStateFromStores(this.props); | |
| }, | |
| componentDidMount() { | |
| stores.forEach(store => store.addChangeListener(this.handleStoresChanged)); | |
| this.setState(this.getStateFromStores(this.props)); |
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)