Skip to content

Instantly share code, notes, and snippets.

View ulisesantana's full-sized avatar
😍
In love with TypeScript

Ulises Santana ulisesantana

😍
In love with TypeScript
View GitHub Profile
@ulisesantana
ulisesantana / algebraicTypes.rs
Created November 16, 2021 23:46
Ejemplo de tipos algebraicos en Rust
pub mod flight_discount {
pub trait Discount {
fn percentage(self: Self) -> u8;
}
#[allow(dead_code)]
pub enum SpanishSubsidy {
LargeFamily,
ResidentOfIslandsOrCeuta,
SpecialResidentLargeFamily,
@ulisesantana
ulisesantana / generate-huge-json.mjs
Last active April 10, 2024 19:09
Script for generating a JSON file with 100 million records. The output file size is 8,1 GB.
import { Readable, pipeline } from 'stream'
import fs from 'fs'
import path from 'path'
import { EOL } from 'os'
function createTransaction () {
return {
date: new Date(Math.random() * 100_000_000_000),
type: Math.random() > 0.5 ? 'INCOME' : 'OUTCOME',
amount: +(Math.random() * 100).toFixed(2)
@ulisesantana
ulisesantana / os-report.mjs
Last active March 4, 2022 08:49
A simple OS Report function
export function osReport(os) {
const cpus = os.cpus()
const totalMemory = os.totalmem()
const freeMemory = os.freemem()
const usedMemory = totalMemory - freeMemory
return `
Arch: ${os.arch}
CPUS: ${cpus.length} (${cpus[0].model} ${cpus[0].speed})
Memory: ${fromBytesToGigabytes(usedMemory)}/${fromBytesToGigabytes(totalMemory)}
Platform: ${os.platform}