Skip to content

Instantly share code, notes, and snippets.

View garenyondem's full-sized avatar
:shipit:

Garen Yöndem garenyondem

:shipit:
View GitHub Profile
@garenyondem
garenyondem / cmd.sh
Created October 8, 2016 12:38 — forked from kelvinn/cmd.sh
Example of using Apache Bench (ab) to POST JSON to an API
# 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/
@garenyondem
garenyondem / server.js
Created September 22, 2017 15:25
Node.js Sample Server with Restify
/*
* 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
*
@garenyondem
garenyondem / invert-binary-tree.js
Created June 4, 2018 20:36 — forked from kidGodzilla/invert-binary-tree.js
Invert a Binary Tree in Javascript
// 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
// / \ / \
@garenyondem
garenyondem / hashid.js
Last active September 30, 2018 19:30 — forked from fiznool/hashid.js
Short 'hash' ID generator.
'use strict';
const ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-+';
const ALPHABET_LENGTH = ALPHABET.length;
const ID_LENGTH = 8;
const UNIQUE_RETRIES = 9999;
let HashID = {};
HashID.generate = function () {
@garenyondem
garenyondem / qrCode.js
Last active October 10, 2018 14:50 — forked from sjcotto/qrCode.js
Generate QR Code and save to mongodb
'use strict';
const qr = require('qr-image');
const mongoose = require('mongoose');
const Grid = require('gridfs');
const json = {
email: '[email protected]',
name: 'John Doe'
};
@garenyondem
garenyondem / RSA.js
Created January 25, 2020 13:11 — forked from fb55/index.js
RSA.js
(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;
},