- 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') |
| var React = require('react-native') | |
| var { | |
| View, | |
| Text, | |
| LinkingIOS, | |
| StyleSheet, | |
| } = React | |
| // you might want to compile these two as standalone umd bundles | |
| // using `browserify --standalone` and `derequire` |
| // 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) |
| // for an updated version see https://github.com/jsdf/react-native-refreshable-listview | |
| var React = require('react-native') | |
| var { | |
| ListView, | |
| ActivityIndicatorIOS, | |
| StyleSheet, | |
| View, | |
| Text, | |
| } = React |
| <!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} |