Skip to content

Instantly share code, notes, and snippets.

@celsopalmeiraneto
celsopalmeiraneto / linux-cheatsheet.md
Last active February 10, 2024 15:26
Celsos Linux Cheat Sheet

Celso's Linux / Unix Cheat Sheet

Applications

uname

Print Kernel and other software / device info, including Linux version:

uname -a
const { PerformanceObserver, performance } = require("node:perf_hooks");
const calculateWeight = (item) => {
const random = Math.random();
return Math.trunc(random * 1000);
};
const groupItemsByWeightImmutable = (items) =>
items.reduce((acc, item) => {
const weight = calculateWeight(item);
@celsopalmeiraneto
celsopalmeiraneto / testA.ts
Created September 13, 2022 11:17
Our discussion on dependency injection
import { SoilAssertion, assertSoilFertilized, assertSoilPloughed } from 'testB';
interface PlantPotatoes {
injected: (seeds: string[], soil: string) => Promise<string>;
dependencies: {
assertPloughed: SoilAssertion;
assertFertilized: SoilAssertion;
};
}
@celsopalmeiraneto
celsopalmeiraneto / lerFatura.js
Last active April 1, 2019 07:43
Santander Brasil - Ler Faturas dos Cartões
function readPageAndGenerateResults() {
function getBRLToUSD() {
const text = document.querySelector('.tabla_datos:nth-of-type(2) table:nth-of-type(2) tr:last-of-type td:last-of-type').textContent;
return parseNumber(text);
}
function getCCLedgers() {
const exchangeRate = getBRLToUSD();
const ledger = Array.from(document.querySelector('.tabla_datos:nth-of-type(1) table tbody').rows);
function convertCamelCaseToSnakeCase(text) {
const inputLines = text.split('\n');
const outputLines = inputLines.map((line) => {
return Array.from(line).reduce((acc, v, i) => {
if (i == 0) {
acc += v.toLocaleLowerCase();
return acc;
}
if (v.toLocaleUpperCase() == v) {
acc += '_';