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
# post_loc.txt contains the json you want to post | |
# -p means to POST it | |
# -H adds an Auth header (could be Basic or Token) | |
# -T sets the Content-Type | |
# -c is concurrent clients | |
# -n is the number of requests to run in the test | |
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/ |
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
/* | |
* Node.js Sample Server with Restify | |
* Copyright (C) 2014 - Thiago Uriel M. Garcia | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* |
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
// This problem was inspired by this original tweet by Max Howell: | |
// Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fuck off. | |
// So, let's invert a binary tree in Javascript | |
// Original Tree | |
// 4 | |
// / \ | |
// 2 7 | |
// / \ / \ |
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
'use strict'; | |
const ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-+'; | |
const ALPHABET_LENGTH = ALPHABET.length; | |
const ID_LENGTH = 8; | |
const UNIQUE_RETRIES = 9999; | |
let HashID = {}; | |
HashID.generate = function () { |
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
'use strict'; | |
const qr = require('qr-image'); | |
const mongoose = require('mongoose'); | |
const Grid = require('gridfs'); | |
const json = { | |
email: 'john@doe.com', | |
name: 'John Doe' | |
}; |
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(global){ | |
var MathUtils = { | |
powermod: function powermod(num, exp, mod){ | |
if(exp === 1) return num % mod; | |
if(exp & 1 === 1){ //odd | |
return (num * powermod(num, exp-1, mod)) % mod; | |
} | |
return Math.pow(powermod(num, exp/2, mod), 2) % mod; | |
}, |