Skip to content

Instantly share code, notes, and snippets.

View inodaf's full-sized avatar
👨‍🚀
Starfleet Command

Isac Fadoni inodaf

👨‍🚀
Starfleet Command
  • Senior Software Engineer · @n26
  • Berlin, Germany
  • 17:34 (UTC +02:00)
  • X @o_inodaf
View GitHub Profile
@inodaf
inodaf / boring.md
Last active May 16, 2024 18:24
N reasons to use GNU Make (in my opinion)
  • ✅ You probably have Make installed by default, your CI does too;
  • ✅ When you write a Makefile, you are just defining your dependency graph;
  • ✅ It is incremental, so it only create files, compile, run tasks that are necessary;
  • ✅ Efficient. It can run jobs in parallel;
  • ✅ Easily integrates with any CLI tool;
  • ✅ Superfast, it's made in C;
  • ✅ A boring tool: stable, reliable, predictable, fast and powerful;
  • ✅ Your CI will love it;
  • ✅ Full control over your workflow;
  • ✅ Used for compiling large C, Go and many other codebase for decades;
function textToSlackEmoji(text: string): string {
return text.split('').reduce((phrase, char) => {
if (char) return phrase + `:alphabet-white-${char}:`
else return phrase + ' '
}, '').replaceAll(':alphabet-white- :', ' ')
}
textToSlackEmoji('ladies and gentleman the weekend')
@inodaf
inodaf / main.rs
Created May 19, 2021 01:49
My first Rust program.
use rand::Rng;
use std::cmp::Ordering;
use std::io;
fn main() {
println!("Guess the number!");
let secret_number = rand::thread_rng().gen_range(1..101);
loop {
function getIndexOfMin(list: number[]) {
let current = list[0];
let index = 0;
for (let i = 0; i < list.length; i++) {
if (list[i] < current) {
current = list[i];
index = i;
}
}
// O(logn)
const binarySearch = (list: number[], item) => {
let [from, to] = [0, list.length - 1];
if (!item) return
while (from <= to) {
const index = Math.ceil((from + to) / 2);
const guess = list[index];
@inodaf
inodaf / fib.js
Last active January 25, 2021 20:22
Fibonacci: Exponential vs Dynamic Programming using Memoizers
const fib = n => {
if (n <= 2) return 1
return fib(n - 1) + fib(n - 2)
}
function fib2(n, mem = {}) {
let fibonacci;
if (n in mem) return mem[n]
fibonacci = n <= 2 ? 1 : fib2(n - 1, mem) + fib2(n - 2, mem)
function max(target: Array<Number>): Number {
const reducer = (greatest, current) => current > greatest ? current : greatest
return target.reduce(reducer)
}
function crush(length, queries) {
const zeroes = Array(length).fill(0)
for (let i = 0; i < queries.length; i++) {
const [a, b, k] = queries[i];
@inodaf
inodaf / _minmax.ts
Last active January 12, 2021 21:07
Get the Minimum & Maximum Number from an Array in JavaScript
function min(target: Array<Number>): Number {
const reducer = (lowerest, current) => current < lowerest ? current : lowerest
return target.reduce(reducer)
}
function max(target: Array<Number>): Number {
const reducer = (greatest, current) => current > greatest ? current : greatest
return target.reduce(reducer)
}
@inodaf
inodaf / generate.js
Created January 12, 2021 19:42
Generate an Array with Random Numbers in JavaScript
const generate = (length = 1000) => Array(length).fill().map(() =>
Math.floor(Math.random() * Math.floor(100))
)
@inodaf
inodaf / hourglass.ts
Last active January 12, 2021 15:34
Data Structures: Array
const twoDimensionsArray = [
[-9, -9, -9, 1, 1, 1],
[ 0, -9, 0, 4, 3, 2],
[-9, -9, -9, 1, 2, 3],
[ 0, 0, 8, 6, 6, 0],
[ 0, 0, 0, -3, 0, 0],
[ 0, 0, 1, 2, 4, 0],
]
const twoDimensionsArray2 = [