Skip to content

Instantly share code, notes, and snippets.

View d3vild06's full-sized avatar

Roberto C Quezada d3vild06

View GitHub Profile
@d3vild06
d3vild06 / findShortest.js
Last active July 1, 2016 15:51
Find Shortest String In Array
var my_arry = ["hello", "muchasgracias", "hi", "elephant"];
function findShortest(arry) {
return arry.reduce(function(prevWord,currWord) {
if (currWord.length < prevWord.length) {
return currWord;
}
else
return prevWord;
})
@d3vild06
d3vild06 / Array.js
Last active February 9, 2017 05:31
JS Array Re-Implementation
// Exercise to re-implement a Javascript Array from scratch
// We are using a quazi implementation of memory (JS Array) to mimic directly accessing your system memory and simulating a block of memory
// const memory = require('./memory'); <=== fake memory using JS Array
// Initialize Array object (using ES6 class syntax here)
class Array {
constructor() {
this.length = 0;
this._capacity = 0;
this.ptr = memory.allocate(this.length);
@d3vild06
d3vild06 / HashMap.js
Last active February 13, 2017 19:03
Hash Map Implementation
class HashMap {
constructor(capacity) {
this.length = 0;
this._slots = [];
this.capacity = capacity || 8;
this.deleted = 0;
};
set(key, value) {
const loadRatio = (this.length + this.deleted + 1) / this.capacity;
@d3vild06
d3vild06 / bst.js
Last active February 14, 2017 21:14
Binary Search Tree (Ordered Map)
class BST {
constructor(key, value, parent) {
this.key = key || null;
this.value = value || null;
this.parent = parent || null;
this.left = null;
this.right = null;
}
insert(key, value, parent) {
@d3vild06
d3vild06 / githubAuthRevoke.js
Created July 12, 2018 23:09
GitHub Auth Revoke
githubAuthRevoke = function(accessToken) {
check(accessToken, String);
console.log("in githubAuthRevoke");
let clientId = Meteor.settings.github_clientid
let clientSecret = Meteor.settings.github_clientsecret
let options = {
headers: {
'User-Agent': 'CodeBuddies'
},