Skip to content

Instantly share code, notes, and snippets.

Madara Uchiha MadaraUchiha

Block or report user

Report or block MadaraUchiha

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View producer-consumer.js
class Producer {
start(consumer) {
this.counter = 0;
this.handler = setInterval(() =>, 1000);
stop() {
View webpack.base.ts
// This is the interesting bit
module: {
rules: [
use: [
loader: 'awesome-typescript-loader',
options: {
transpileOnly: true, // Note, this means you ignore errors.
// Due to legacy, we ignore errors in TypeScript files too, DON'T DO THIS FOR TS FILES
View in.js
const request = require('request');
const reqContext = request.defaults({jar: true});
request.get('', (err, response, body) => {
console.log(JSON.stringify(response.headers));'', {
form: {
comp: 2135,
name: 41,
View router.js
export async function reserve(req, res) {
try {
const locker = await Locker.find({
where: {
await handleEntityNotFound(res, true)(locker);
const reservation = req.body.reservation || {};
if (!reservation.tmpToken) {
MadaraUchiha /
Created Dec 24, 2015
Implement the Promise constructor challenge

Task 1

A Promise is an object that represents a (potential value) over time. A replacement for callbacks. Your job is to implement the Promise object. Here are the requirements:

  • The Promise constructor takes a function with two arguments: new Promise((resolve, reject) => { ... })
    • Calling the resolve function inside of the handler will resolve the promise (i.e. success). You can call resolve with a single argument, which will be passed to .then().
    • Calling the reject function will reject it (i.e. error). You should always call reject with an Error instance, which will be passed to .then().
  • A Promise has three states, it starts at "pending" and can mutate only once to either "resolved" or "rejected".
  • A Promise object has a .then() method which accepts two functions, the first will call if it's resolved, and the second if it rejects.


View day10.js
const next = input => {
let chars = input.match(/(\d)\1*/g);
return => `${repetition.length}${repetition[0]}`).join('');
const nextN = (input, times) => {
if (times === 0) {
return input;
return nextN(next(input), times - 1);
View ivals.promises.js
let ivals = [/* lots of ivals here */];
let c = new Ftp();
function putItem(ftp, item) {
return new Promise((resolve, reject) =>
ftp.put(item, item, (err) => err ? reject(err) : resolve()));
ivals.reduce((promise, ival) =>
promise.then(() => {
MadaraUchiha /
Created Oct 13, 2015
Why double hashing is bad

The woes of double hashing

What is a hashing function? A hashing function is a function that takes arbitrary input, and returns output with a uniform size (oversimplification, I know). What does this mean? Here's my hashing function:

function myHash($input) {
    return $input[0] === 'A' ? "1" : "0";

This hash function accepts any sort of string input, and returns an output of a uniform size. Either 0 or 1.

You can’t perform that action at this time.