- same code on the client and server
- usable by non-JS clients (crawlers etc)
- initially render app on the server, then run client side
- 'portable' Javascript
- SEO
merge = require 'xtend' | |
Promise = require 'bluebird' | |
request = Promise.promisify require 'request' | |
fs = require 'fs' | |
Promise.promisifyAll(fs) | |
servicesEndpointUrl = process.argv[2] or 'http://example.com/api' | |
contentType = process.argv[3] or 'node' | |
idType = process.argv[4] or 'nid' |
javascript:var $textnode = $(getSelection().baseNode).closest('.output');if ($textnode.length) {$textnode.css({width:'100vw',height:'100vh',position: 'absolute',top: 0,left: 0,background: 'white'}).find('pre').css({height: '100%', 'box-shadow':'none', margin:0});$(window).scrollTop(0);$textnode.detach();$(document.body).css({width:'100vw',height:'100vh',overflow:'hidden'}).empty().append($textnode)} else {alert('select some text in an output log and then click the bookmarklet again')} |
#!/usr/bin/env node | |
var crypto = require('crypto') | |
var path = require('path') | |
var fs = require('fs') | |
var Promise = require('bluebird') | |
Promise.promisifyAll(fs) | |
function hash(input, algorithm, encoding) { | |
return crypto |
#!/usr/bin/env node | |
var crypto = require('crypto') | |
var path = require('path') | |
var fs = require('fs') | |
function hash(input, algorithm, encoding) { | |
return crypto | |
.createHash(algorithm || 'md5') | |
.update(input, 'utf8') |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>CJSX in a script tag</title> | |
<script src="https://fb.me/react-0.13.2.js"></script> | |
<script type="text/javascript" src="https://wzrd.in/standalone/coffee-react-browser"></script> | |
<script type="text/cjsx"> | |
# defining a component | |
class Clock extends React.Component | |
@defaultProps = interval: 2000 |
(function() { | |
// attach all comment disclosers | |
$('.comment').forEach(function(comment) { | |
var commentRoot = closest(comment, '.athing') | |
CommentDiscloser(commentRoot) | |
}) | |
function CommentDiscloser(root) { | |
// initial state | |
var state = {open: true} |
// A useful way of thinking about how the value of 'this' is bound in Javascript | |
// functions is to imagine that Function.prototype.call is being used | |
// implicitly at the call site to set the 'context' (the 'this' value). eg. | |
// assuming in each case | |
var o = {} | |
var o2 = {} | |
var fn = function(){} | |
// 1. bare function call |
import React from 'react/addons'; | |
export default function shallowRender(element) { | |
const shallowRenderer = React.addons.TestUtils.createRenderer(); | |
shallowRenderer.render(element); | |
return shallowRenderer.getRenderOutput(); | |
} |
// make sure you npm install 'url' (the browserify port of the node api url module) | |
var url = require('url') | |
var Faye = require('faye/browser/faye-browser') | |
var API_URL = 'http://localhost:8000/faye' | |
// initialise fake window.location - same origin as api host | |
// required to use some faye transports which expect to deal with same-origin policy. | |
// url.parse return value looks kind of like window.location, if you squint just right | |
window.location = url.parse(API_URL) |