Skip to content

Instantly share code, notes, and snippets.

View RodEsp's full-sized avatar

Rodrigo Espinosa de los Monteros RodEsp

View GitHub Profile
@RodEsp
RodEsp / memoize.js
Created December 12, 2023 22:53
JavaScript Memoize Function
export const memoize = (fn) => {
const cache = new Map();
return (...args) => {
const key = JSON.stringify(args);
if (cache.has(key)) return cache.get(key);
const result = fn(...args);
cache.set(key, result);
@RodEsp
RodEsp / tictactoe.js
Last active September 7, 2023 22:06
Interactive tic-tac-toe in a terminal
const clearScreen = () => {
process.stdout.cursorTo(0, 0);
process.stdout.clearScreenDown();
};
clearScreen();
console.log('Welcome to TicTacToe!');
console.log('Please select your opponent:');
console.log(' 1. Human');
console.log(' 2. Computer');

Please credit this guide if you use its instructions elsewhere.

Installing Spinnaker on a local Kubernetes cluster for local Spinnaker development

All the commands in this document are meant to be run from your computer’s terminal, unless stated otherwise. This guide has only been tested on macOS Catalina.

Install Docker and Kubernetes

  1. Download and install Docker Desktop from: https://www.docker.com/products/docker-desktop
#include <iostream>
void func (int n, int &nA) {
std::cout << "void func (int n, int &nA) {\n";
std::cout << "----------------------------\n";
std::cout << "n " << n << "\n";
std::cout << "&n " << &n << "\n";
std::cout << "nA " << nA << "\n";
std::cout << "&nA " << &nA << "\n";
std::cout << "\n";
@RodEsp
RodEsp / txtToBinary.js
Created June 16, 2017 14:07
Text-Binary translator
const convertTextToBinary = (text) => {
const chars = text.split('');
return chars.reduce((str, byte, i) => {
byte = byte.charCodeAt(0).toString(2);
byte = new Array(9 - byte.length).join(0) + byte;
return str + byte + (i === chars.length - 1 ? '' : ' ');
}, '');
}