This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.defineProperty(Object.prototype, 'extend', { | |
writable: true, | |
enumerable: false, | |
configurable: true, | |
value: function(o){ | |
var names = Object.getOwnPropertyNames(o); | |
for(var i = 0; i < names.length; i++){ | |
if(names[i] in this) continue; | |
var desc = Object.getOwnPropertyDescriptor(o, names[i]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var events = require('events'); | |
var net = require('net'); | |
var channel = new events.EventEmitter(); | |
channel.clients = {}; | |
channel.subscriptions = {}; | |
//Add a listener for the join event that stores a user’s client object, | |
//allowing the application to send data back to the user. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var events = require('events'); | |
var net = require('net'); | |
var channel = new events.EventEmitter(); | |
channel.clients = {}; | |
channel.subscriptions = {}; | |
//Add a listener for the join event that stores a user’s client object, | |
//allowing the application to send data back to the user. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
//move to commands.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
.warning { | |
color: tomato; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// Sass (v3.4.7) | |
// Compass (v1.0.1) | |
// ---- | |
$sans: sans-serif; | |
$serif: georgia, times; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Number.prototype.toBinary = function(){ | |
return parseInt(this.toString(2)); | |
}; | |
// > (55).toBinary() | |
// > 110111 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var scrambleWord = function(word){ | |
var result = ""; | |
var i = word.length; | |
while(i--){ | |
result += word.charAt(Math.floor(Math.random() * word.length)); | |
} | |
return result | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Find the index of an element in an array using binary sorting | |
function binarySort(collection, target, callback, minimum, maximum) { | |
// Get the starting and ending points | |
var min = minimum || 0; | |
var max = maximum || collection.length; | |
// Get the median value and the value at that index | |
var median = Math.floor((min + max) / 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function WeightedQuickUnion(initCount) { | |
var size = this.size = []; | |
var parent = this.parent = []; | |
var count = initCount; | |
/* Initialize the union-find structure */ | |
for(var i = 0; i < count; i++) { | |
parent[i] = i; | |
size[i] = 1; |
OlderNewer