This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub mod flight_discount { | |
pub trait Discount { | |
fn percentage(self: Self) -> u8; | |
} | |
#[allow(dead_code)] | |
pub enum SpanishSubsidy { | |
LargeFamily, | |
ResidentOfIslandsOrCeuta, | |
SpecialResidentLargeFamily, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum DiscountKind { | |
NoDiscount, | |
Special, | |
Resident, | |
Family, | |
Business | |
} | |
interface Discount { | |
kind: DiscountKind; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prevent from using the custom alias on 3rd party scripts. Must be at the top of the file | |
[ -z "$PS1" ] && return | |
# alias | |
alias blog='cd ~/projects/blog' | |
alias blog-posts='cd ~/projects/blog/content/blog' | |
alias .zshrc='nvim ~/.zshrc' | |
alias gitlog="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" | |
alias wifi='nmcli device show wlan0' | |
function cd { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Based on this post https://stsewd.dev/es/posts/neovim-plugins/ | |
call plug#begin('~/.local/share/nvim/plugged') | |
Plug 'yashguptaz/calvera-dark.nvim' | |
Plug 'scrooloose/nerdtree' | |
Plug 'vim-airline/vim-airline' | |
Plug 'vim-airline/vim-airline-themes' " Temas para airline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
check() { | |
test "$@" && echo true || echo false | |
} | |
show_help() { | |
echo -e "Generate a file with current day as file name based on template. Will create a folder based on current month and save the file inside.\n" | |
echo -e "Usage: new-post.sh template_path output_parent_directory.\n" | |
echo -e "Example: ./new-post.sh ./template.md ./posts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fizzBuzz, { FIZZ, BUZZ, FIZZ_BUZZ } from "./fizzBuzz.ts"; | |
import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; | |
Deno.test( | |
"FizzBuzz should return the same number given if is not divisible by 3 or 5", | |
() => { | |
assertEquals(fizzBuzz(1), 1); | |
}, | |
); | |
Deno.test( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias gitstats='git-stats' | |
alias gits='git status -s' | |
alias gita='git add -A && git status -s' | |
alias gitcom='git commit -am' | |
alias gitacom='git add -A && git commit -am' | |
alias gitc='git checkout' | |
alias gitcm='git checkout master' | |
alias gitcd='git checkout development' | |
alias gitcgh='git checkout gh-pages' | |
alias gitb='git branch' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { address, company, random } = require('faker'); | |
const fs = require('fs'); | |
const path = require('path'); | |
fs.writeFile( | |
path.resolve('companies.mock.json'), | |
JSON.stringify( | |
[...new Array(60)].map(() => ({ | |
id: random.number(), | |
name: company.companyName(), |
NewerOlder