Skip to content

Instantly share code, notes, and snippets.

var result = squareOfDifference(4, 7);
console.log('Result is', result);
function square(n) {
var result = n * n;
return result;
}
function squareOfDifference(x, y) {
var diff = x - y;
var start = new Date().getTime()
timestamp = function timestamp(msg){
var end = new Date().getTime()
console.log('[' + (end - start) + 'ms]', msg)
}
var mine = require('js-linker/mine.js');
var fs = require('fs');
timestamp('loaded modules')
timestamp('start')
@airportyh
airportyh / README.md
Last active August 29, 2015 13:56
Benchmarks comparisons of Component with syntax-error feature applied.

component is Component version 0.19.6. mycomponent is the same version with applied.

@airportyh
airportyh / index.html
Created February 26, 2014 16:04
Results of pairing with Brookes on auto discovering and linking URLs in an editable div.
<!doctype html>
<html>
<head>
</head>
<div id="textarea" contenteditable="true">
Hello, World!
</div>
<button>Done</button>
<script>
textarea.addEventListener('keyup', function(e){
@airportyh
airportyh / typo-it
Created March 7, 2014 15:53
A script to add a typo to your code.
#! /usr/bin/env node
var fs = require('fs')
var filename = process.argv[2]
var transforms = [mutation, deletion, insertion]
var text = fs.readFileSync(filename) + ''
var idx = Math.floor(Math.random() * transforms.length)
var transform = transforms[idx]
text = transform(text)
fs.writeFileSync(filename, text)
function BackboneAdapter(model){
if (!(this instanceof BackboneAdapter)) return new BackboneAdapter(model);
this.model = model;
}
BackboneAdapter.prototype = {
subscribe: function(prop, fn){
this.model.on('change:' + prop, fn);
},
unsubscribe: function(prop, fn){
@airportyh
airportyh / delay_proxy.js
Last active August 29, 2015 13:57
A web proxy to simulate network delay.
#! /usr/bin/env node
var http = require('http')
var request = require('request')
var server = http.createServer(handler)
server.listen(3001)
console.log('Listening on port 3001')

Proposed New Adapter API

Constructor

new Adapter()

Methods

@airportyh
airportyh / gist:9743613
Created March 24, 2014 16:20
array EcmaScript 5 Non-Compliance
* doesn't skip holes properly
* `indexOf` - doesn't handle second parameter `fromIndex`
* iteration methods (`map`, `forEach`, `reduce`, etc) don't handle 3rd parameter array
* iteration methods don't set context for the callback when provided as last parameter
* `reduceRight` method non-existent
* `some` method non-existent
3rd-eden/fortress
4th-dimension/utf8-length
alanshaw/hoodie-plugin-reactive
acconut/util
alexindigo/deeply
amiorin/jquery2
amiorin/jquery
alexindigo/timeless
acstll/deep-get-set
acstll/alerts