Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 re | |
namespace_pattern = re.compile('{(?P<ns>[^}]*}') | |
def process_node(node, cb): | |
url = None | |
ns = namespace_pattern.match(node.tag) | |
if ns is not None: | |
url = ns.groupdict()['ns'] | |
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
'use strict' | |
const Emitter = require('events') | |
const oldEmitter = Emitter.prototype.emit | |
Emitter.prototype.emit = function wrappedEmit(ev) { | |
const start = Date.now() | |
const res = oldEmitter.apply(this, arguments) | |
console.log(`emitting ${ev} on ${this.constructor} took ${Date.now() - start} ms`) | |
return res | |
} |
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
#include <iostream> | |
#include <vector> | |
using namespace std; | |
void print(vector<int> a) { | |
for (int el : a) { | |
cout << el << " "; | |
} | |
cout << endl; |
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 min = this._data.findMinimum() | |
var data = [] | |
var iterationNodes = [min] | |
var iterationHeads = [min] | |
var depth = 0 | |
if (min) { | |
var current | |
while (depth >= 0) { | |
current = iterationNodes[depth] |
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 a(x) { this.x = 1 } | |
a.prototype.toJSON = function () {return} | |
x = {test: new a(1)} | |
JSON.stringify(x) |
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 oldNextTick = process.nextTick | |
process.nextTick = function(cb) { | |
var stack = (new Error()).stack | |
return oldNextTick.call(process, function() { | |
try { | |
return cb.apply(this, arguments) | |
} catch (e) { | |
e.stack = stack + e.stack | |
throw e | |
} |
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
new Promise(function(res, rej) { | |
return Promise.all([ | |
1, | |
10, | |
100, | |
1000 | |
].map(function createPromises(time) { | |
return new Promise(function(res, rej) { | |
setTimeout(function() { | |
console.log('waited ' + time + ' ms!') |
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 factArr = [1] | |
function fact(n) { | |
if (n > factArr.length) { | |
for (var i = factArr.length; i <= n; ++i) { | |
factArr[i] = factArr[i - 1] * i | |
} | |
} | |
return factArr[n] | |
} |
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 collatz(n) { | |
var chain = [n] | |
while (n !== 1) { | |
if (n % 2 === 0) { | |
n /= 2 | |
} else { | |
n = n * 3 + 1 | |
} | |
chain.push(n) | |
} |
NewerOlder