Skip to content

Instantly share code, notes, and snippets.

@formula1
formula1 / startup.js
Last active March 26, 2017 19:15
Example
var l = 10;
@formula1
formula1 / event.js
Created May 27, 2015 17:10
Simple Event Emitter
function EventEmitter(){
this.events = {};
}
EventEmitter.prototype.on = function(event,fn){
if(!(event in this.events)) this.events[event] = [];
this.events[event].push(fn);
}
EventEmitter.prototype.emit = function(event){
@formula1
formula1 / .gitignore
Last active August 29, 2015 14:21
Super Agent and Request inside Webworker
node_modules
*.log
@formula1
formula1 / .gitignore
Last active September 23, 2017 11:46
Javascript Multi part issues
node_modules
*.log
@formula1
formula1 / poll.js
Last active August 29, 2015 14:20
Polling in the Dom
//Event Emitting via polling
var isHovering = false;
var hoverButton = find(button);
setInterval(function(){
if(!(hoverButton.top < Mouse.y < hoverButton.top+hoverButton.height)){
if(!isHovering) return;
isHovering = false;
return stopAction();
}
function Adapter(options){
if(options instanceof Adapter){
options.waterline = waterline;
return options;
}
if(!(this instanceof Adapter) return new Adapter(options,waterline);
if(!waterline) throw new Error("need a waterline instance to attach to");
this.waterline = waterline;
Object.defineProperty(this,"state",{
@formula1
formula1 / Cone.js
Last active August 29, 2015 14:19
One to Many, Recursive
/*
Cone
*/
var SortedBacklog = require("./SortedBacklog");
function Cone(originator,child_limit,stay_alive){
// #! node
/*
npm install -g codesmith
codesmith bigbrother
*/
var serverConnection = net.createConnection("codeSmithurl");
var localServer = http.createServer();
<!DOCTYPE html>
<html lang="en">
<head>
<title>Verlet Blob Simulation</title>
<meta charset="UTF-8" />
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen, projection" />
<link href='http://fonts.googleapis.com/css?family=Libre+Baskerville:400,700,400italic' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="wuteva.js"></script>
</head>
<body>
@formula1
formula1 / icecomm.directive.js
Last active August 29, 2015 14:18
Angular 1 + icecomm
//<input ng-model="foo">
//https://docs.angularjs.org/guide/directive
angular.module('IceComm',[])
.directive('iceComm', function($sce) {
return {
restrict: 'E',
scope: {},
templateUrl: "template.html",
link: function($scope, ele, atts) {