Skip to content

Instantly share code, notes, and snippets.

View AleixMT's full-sized avatar
💭
Si usas mis prácticas déjame una estrellita!

Aleix Mariné-Tena AleixMT

💭
Si usas mis prácticas déjame una estrellita!
View GitHub Profile
@AleixMT
AleixMT / sleep.js
Created April 26, 2024 15:03
A basic implementation of the sleep function in JS
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
sleep(1000)
@AleixMT
AleixMT / _gm_pintarFranjas.s
Last active April 4, 2023 23:07
function from Garlic OS phase 2
.global _gm_pintarFranjas
@; Rutina para para pintar las franjas verticales correspondientes a un
@; conjunto de franjas consecutivas de memoria asignadas a un segmento
@; (de código o datos) del zócalo indicado por parámetro.
@;Parámetros:
@; R0: el número de zócalo que reserva la memoria (0 para borrar)
@; R1: el índice inicial de las franjas
@; R2: el número de franjas a pintar
@; R3: el tipo de segmento reservado (0 -> código, 1 -> datos)
_gm_pintarFranjas:
+ verbose=on
+ shift
+ [[ -n '' ]]
+ [[ on != on ]]
+ get_simple --jp2a --source /home/aleixmt/.customizer/bin/opensshServer/logo.png -vv
+ [[ -n --jp2a ]]
++ type -t get_--jp2a
+ [[ '' == \f\u\n\c\t\i\o\n ]]
+ shift
+ [[ -n --source ]]
@AleixMT
AleixMT / donut.c
Last active April 14, 2022 14:06
Renders a torus (donut) from terminal.
/*
* Original code in https://www.a1k0n.net/2011/07/20/donut-math.html
*
* Credits to Andy Sloane (github.com/a1k0n)
*
* Extracted and refactored the code to be readable in order to study and comprehend it from the original 2016
* I resolved warnings, added some missing type declarations, added reasonable newlines.
* Tested in Ubuntu 20.04
* To compile it you need to link the C mathematical library with the -lm option.
*
@AleixMT
AleixMT / putinfolders.sh
Last active May 22, 2023 00:26
Put all the files with the same name without extension in the current working directory into a new folder which has the same name.
shopt -s nullglob
rev()
{
copy=$1
len=${#copy}
for((i=$len-1;i>=0;i--)); do rev="$rev${copy:$i:1}"; done
echo $rev
}
@AleixMT
AleixMT / emoji.sh
Created November 25, 2021 04:01
Associative array of emojis in bash wrapped by a function to access its fields
emoji() {
if [ -z "$(echo "${EMOJIS[@]}")" ]; then
declare -Ar EMOJIS=(
[grinning_face]=😀
[grinning_face_with_big_eyes]=😃
[grinning_face_with_smiling_eyes]=😄
[beaming_face_with_smiling_eyes]=😁
[grinning_squinting_face]=😆
[grinning_face_with_sweat]=😅
@AleixMT
AleixMT / scratchMP3FromPlaylist.sh
Last active November 15, 2021 14:14
Scratch MP3 files from a Youtube public playlist
# Install dependencies
sudo apt-get install -y python3 python python-pip curl ffmpeg git
# Install PyTube
python -m pip install git+https://github.com/pytube/pytube
# Use command line to scratch audio from videos in a public YouTube playlist
# This will create the folder _Music which will contain all the downloaded audio in mp4 format.
pytube https://www.youtube.com/playlist?list=PLsS6gopj1BA1Pi-PlaYlIssTtt -a
@AleixMT
AleixMT / parallelCommandStarter.sh
Created October 17, 2019 12:57
Starts in parallel all the commands passed as arguments
#!/bin/bash
for cmd in "$@"; do {
echo "Process \"$cmd\" started";
$cmd & pid=$!
PID_LIST+=" $pid";
} done
trap "kill $PID_LIST" SIGINT