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 shuffleArray(array) { | |
for (var i = array.length - 1; i > 0; i--) { | |
var j = Math.floor(Math.random() * (i + 1)); | |
var temp = array[i]; | |
array[i] = array[j]; | |
array[j] = temp; | |
} | |
return array; |
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
# So, this is pretty horrible. If we just encode using btoa, any UTF-8 chars cause an error. | |
# If we use either of the workarounds on MDN[1], the £ sign is encoded wrong. I suspect | |
# Excel totally sucking at encodings is the reason why. So, the workaround is, to use | |
# the MDN workaround on chars with values > 255, and allow chars 0-255 to be encoded | |
# as is with btoa. Note that if you use either of the workarounds on MDN, chars | |
# 128-255 will be encoded as UTF-8, which includeds the £ sign. This will cause excel | |
# to choke on these chars. Excel will still choke on chars > 255, but at least the £ | |
# sign works now... | |
# [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Base64_encoding_and_decoding |
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
// The API accepts the page parameter and returns the pagination info in meta | |
{ | |
"messages": [ ... ], | |
"meta": { | |
"pagination": { | |
"total_pages": 3, | |
"current_page": 1, | |
"total_count": 55 | |
} |
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 digestBomb() { | |
var $rootScope = angular.injector(['ng']).get('$rootScope'); | |
function $digest() { | |
$rootScope.$$postDigest($digest); | |
$rootScope.$digest(); | |
} | |
$digest(); | |
} |
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
goog.require('goog.Uri'); | |
goog.require('goog.events'); | |
goog.require('goog.json'); | |
goog.require('goog.net.xpc.CrossPageChannel'); | |
goog.global.initOuter = function(url) { | |
goog.events.listen(window, 'load', function() { xpcdemo.initOuter(url); }); | |
}; | |
goog.global.initInner = function() { | |
goog.events.listen(window, 'load', function() { xpcdemo.initInner(); }); |
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
// Scraping Made Easy with jQuery and SelectorGadget | |
// (http://blog.dtrejo.com/scraping-made-easy-with-jquery-and-selectorga) | |
// by David Trejo | |
// | |
// Install node.js and npm: | |
// http://joyeur.com/2010/12/10/installing-node-and-npm/ | |
// Then run | |
// npm install jsdom jquery http-agent | |
// node numresults.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
// Version without jQuery | |
javascript:(function () { var root = angular.element(document.getElementsByTagName('body')); var watchers = []; var f = function (element) { angular.forEach(['$scope', '$isolateScope'], function (scopeProperty) { if (element.data() && element.data().hasOwnProperty(scopeProperty)) { angular.forEach(element.data()[scopeProperty].$$watchers, function (watcher) { watchers.push(watcher); }); } }); angular.forEach(element.children(), function (childElement) { f(angular.element(childElement)); }); }; f(root); var watchersWithoutDuplicates = []; angular.forEach(watchers, function(item) { if(watchersWithoutDuplicates.indexOf(item) < 0) { watchersWithoutDuplicates.push(item); } }); console.log(watchersWithoutDuplicates.length); })(); | |
// Version with jQuery | |
javascript:(function () { var root = $(document.getElementsByTagName('body')); var watchers = []; var f = function (element) { if (element.data().hasOwnProperty('$scope')) { angular.forEach(element.data().$scope.$$watchers, function (watche |
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 uuid1 = require('uuid'); | |
var crypto = require('crypto'); | |
testOne("uuid module", uuid1); | |
testOne("my code", uuid2); | |
function testOne(name, fn) { | |
process.stdout.write(name + ": "); | |
var start = new Date(); | |
var s = ""; |
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 bittrex = require('./node.bittrex.api.js'); | |
bittrex.options({ | |
'apikey': '', | |
'apisecret': '', | |
'stream': false, | |
'verbose': false, | |
'cleartext': false | |
}); |
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
const setTimeout = require('timers').setTimeout; | |
const clearTimeout = require('timers').clearTimeout; | |
const WebSocket = require('ws'); | |
const Bluebird = require('bluebird'); | |
const Queue = require('promise-queue'); | |
const binance = require('../node-binance-api.js'); | |
binance.options({ | |
APIKEY: '<api key>', | |
APISECRET: '<api secret>', |
OlderNewer