Skip to content

Instantly share code, notes, and snippets.

View subtleGradient's full-sized avatar
👋

Tom Aylott subtleGradient

👋
View GitHub Profile
Rx.Observable.asStream = function (ev) {
return Rx.Observable.create(function (obs) {
function handler (data) {
obs.onNext(data); // Call as many times with onNext to yield new data
// obs.onCompleted(); // optional to signal the end of the stream
}
ev.on('data', handler);
@zhchbin
zhchbin / index.html
Created February 10, 2013 10:55
Node-Webkit API Demo: Window.capturePage
<html>
<body style="background: #333">
<script >
var gui = require('nw.gui');
var win = gui.Window.get();
function takeSnapshot() {
win.capturePage(function(img) {
var popWindow = gui.Window.open('popup.html',
{width: 420, height: 300});
popWindow.on('loaded', function() {
@Inviz
Inviz / .gitmodules
Last active December 12, 2015 01:48
[submodule "color"]
path = color
url = https://github.com/kamicane/mootools-color
[submodule "lsd-specs"]
path = lsd-specs
url = https://github.com/lovelyscalabledrawings/lsd-specs
[submodule "lsd"]
path = lsd
url = https://github.com/lovelyscalabledrawings/lsd
[submodule "Sheet.js"]
@gitssk
gitssk / wshandshake.sh
Created October 30, 2012 09:12
websocket handshake bash script
#!/bin/bash
rm -rf t
while true
do
read packet
echo $packet >> t
cnt=`echo $packet | wc -c`
if [ $cnt == 2 ] #end of message
then
key=`cat t | grep "Sec-WebSocket-Key:" | cut -f2 -d " "`
@mckamey
mckamey / bezier.js
Created September 25, 2012 16:35
JavaScript port of Webkit CSS cubic-bezier(p1x.p1y,p2x,p2y) and various approximations
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
@rsms
rsms / iopatch.c
Created April 22, 2012 08:20
I/O Patch implementation in C
//
// I/O Patch implementation in C
//
// A patch has strongly defined inputs and outputs, which can be connected to other
// patches' outputs and inputs to form program flow. A patch implements user code
// which reads zero or more immutable input values and mutates zero or more output
// values. This user code is implemented as conceptually pure functions (although
// the user is able to break pureness).
//
// Build and run:
@beizhang
beizhang / removeNode.js
Created December 31, 2011 01:35
removeNode for IE7
d = d || document.createElement('div');
var id = n.id;
do {
do {
d.appendChild(n);
d.innerHTML = '';
} while (n.parentNode);
} while (n = document.getElementById(id));
@sebmarkbage
sebmarkbage / Math.js
Created November 27, 2011 16:37
Module Syntax With Global Imports (Designed to Emulate ECMAScript 6 Modules)
var two = 2, four = 4, five = 5;
exports: function sum(x, y) {
return x + y;
}
exports: var pi = 3.141593, birthday = 12;
exports: two, four;
@Inviz
Inviz / Test.js
Created November 7, 2011 04:35
behavior for `2 masters, 4 slaves` checkboxes in LSD.Script
// Does this look familiar? A grid of dependent checkboxes.
// [ ] Select all
// [ ] Option 1
// [ ] Option 2
// [ ] Option 3
// [ ] Option 4
// [ ] Select all
@sebmarkbage
sebmarkbage / Example.coffee
Created October 24, 2011 21:54
CoffeeScript Whitespace After a Statement Creates an Object Context
###
The indentation on a line following a statement creates an implicit variable.
That variable can be reused by placing more statements on the same whitespace level.
###
createElement 'a'
.style
.width = 100
.height = 100
.setAttribute 'href', 'http://...'