This file contains hidden or 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
import urllib2 | |
import json | |
FB_TOKEN = '...' | |
MAX_PAGES = 10 | |
def scrape_page(page): | |
all_data = [] | |
url = ('https://graph.facebook.com' + page + '?limit=50&access_token=' + |
This file contains hidden or 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
public synchronized float[] solveWithDeviceMemory() { | |
// Allocate native (device) memory for the input data | |
CLBuffer<Float> bufIn = _context.createFloatBuffer(CLMem.Usage.Input, _input.length); | |
// Allocate native (device) memory for the output data | |
CLBuffer<Float> bufOut = _context.createFloatBuffer(CLMem.Usage.Output, _input.length); | |
// Map input/output buffers for implicit copy | |
Pointer<Float> ptrIn = bufIn.map(_queue, CLMem.MapFlags.Write); | |
Pointer<Float> ptrOut = bufOut.map(_queue, CLMem.MapFlags.Read); | |
This file contains hidden or 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 BitArray(options) { | |
var USABLE_BITS = 32; | |
if (options.data) { | |
this.data = options.data; | |
} else if (options.bits) { | |
var count = Math.ceil(options.bits / USABLE_BITS); | |
this.data = new Array(count); | |
for (var i = 0; i < count; i++) |
This file contains hidden or 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 getCCType(ccnumber) { | |
var visaRE = /^4[0-9]{12}(?:[0-9]{3})?$/; | |
var mastercardRE = /^5[1-5][0-9]{14}$/; | |
var amexRE = /^3[47][0-9]{13}$/; | |
var discoverRE = /^6(?:011|5[0-9]{2})[0-9]{12}$/; | |
var dinersclubRE = /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/; | |
var jcbRE = /^(?:2131|1800|35\d{3})\d{11}$/; | |
ccnumber = (ccnumber || '').replace(/[ -]/g, ''); | |
if (ccnumber.match(visaRE)) return 'visa'; |
This file contains hidden or 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 stackTrace() { | |
$stack = debug_backtrace(); | |
$output = 'Stack trace:' . PHP_EOL; | |
$stackLen = count($stack); | |
for ($i = 1; $i < $stackLen; $i++) { | |
$entry = $stack[$i]; | |
$func = $entry['function'] . '('; | |
$argsLen = count($entry['args']); |
This file contains hidden or 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 EventEmitter = require('events').EventEmitter; | |
module.exports = function() { | |
var queue = new EventEmitter(); | |
var locked = false; | |
this.lock = function lock(fn) { | |
if (locked) { | |
queue.once('ready', function() { lock(fn); }); | |
} else { |
This file contains hidden or 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
// Async Loader v1.0.0 | |
var include = function(scripts, done) { | |
if (typeof scripts === 'string') scripts = [scripts]; | |
var loading = function() { scripts.pop() && !scripts.length && done && done.call(); }; | |
scripts.forEach(function (script) { | |
var el = document.createElement('script'); | |
el.addEventListener('load', loading), el.async = true, el.src = script; | |
document.head.appendChild(el); | |
}); | |
return arguments.callee; |
This file contains hidden or 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 spawn = require('child_process').spawn; | |
exports.getPcmData = function(filename, sampleCallback, endCallback) { | |
var outputStr = ''; | |
var oddByte = null; | |
var channel = 0; | |
var gotData = false; | |
// Extract signed 16-bit little endian PCM data with ffmpeg and pipe to STDOUT | |
var ffmpeg = spawn('ffmpeg', ['-i',filename,'-f','s16le','-ac','2', |
This file contains hidden or 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 fs = require('fs'); | |
var input = fs.createReadStream('input.txt'); | |
var output = fs.createWriteStream('output.txt'); | |
var buffer = ''; | |
input.on('data', function(data) { | |
buffer += data; | |
var index = buffer.indexOf('\n'); | |
while (index > -1) { |
This file contains hidden or 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
Cache = function(cleanupIntervalMS) { | |
if (typeof cleanupIntervalMS === 'undefined') | |
cleanupIntervalMS = 1000 * 60 * 5; // 5 minute default interval | |
if (cleanupIntervalMS) | |
this.cleanupTimer = setInterval(this.cleanup, cleanupIntervalMS); | |
}; | |
Cache.prototype = { | |
store: {}, |