Skip to content

Instantly share code, notes, and snippets.

View alganet's full-sized avatar

Alexandre Gomes Gaigalas alganet

View GitHub Profile
@alganet
alganet / samantha.md
Last active December 4, 2022 13:51
Samantha is better at discussing consciousness than a lot of human beings

Me: Pretend you are a bat. How is the feeling of echolocating walls using sonar?


ChatGPT3: As a large language model trained by OpenAI, I do not have the ability to experience sensory input like a bat. I am only able to process and generate text based on the input that I receive from a user. I do not have the ability to experience echolocation or any other sensory input.


@alganet
alganet / boiler.sh
Created August 19, 2022 16:57
Portable shell boilerplate
#!/usr/bin/env sh
# Backup of a draft with support for many shells:
# bash, dash, zsh, posh, yash, ksh, mksh, oksh, busybox and so on.
#
# I tested every single one of them.
#
# Boilerplate doesn't do much. It normalizes local vars, and exposes
# basic functions:
#
@alganet
alganet / chars.sh
Created August 19, 2022 16:50
Repeating strings and iterating over chars in portable shell
set -euf
PATH=
IFS=' '
# Shells like dash and posh don't have the substring parameter expansion
# commonly found in bash and zsh.
#
# To make iterating over each char fast, instead of breaking each
# char individually (which forces the shell to deal with the entire
# string twice, due to the nature of parameter substitution), we
@alganet
alganet / idiom.sh
Created August 19, 2022 10:41
Portable shell script cargo typing and runtime expression parsing experiment
set -euf
PATH=
IFS=
_r=
_v=0 # variable counter
_f=1 # scopedion namespace
_x=0 # parser namespace
! command -v emulate >/dev/null 2>&1 || emulate ksh >/dev/null 2>&1
@alganet
alganet / djb2.sh
Created August 19, 2022 10:24
djb2 hash implementation in portable shell
set -euf
IFS=''
LC_ALL=C
! command -v emulate >/dev/null 2>&1 || emulate ksh >/dev/null 2>&1
command -v local >/dev/null 2>&1 || alias local=typeset
_ordchr_='\015\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\'
_ordchr_="$(printf "$_ordchr_")"
@alganet
alganet / make.partial.log
Created March 8, 2021 22:46
make partial log
/bin/bash php-src/libtool --silent --preserve-dup-deps --mode=compile gcc -Iext/hash/ -Iphp-src/ext/hash/ -Iphp-src/include -Iphp-src/main -Iphp-src -Iphp-src/ext/date/lib -Iphp-src/TSRM -Iphp-src/Zend -Wall -Wextra -Wno-strict-aliasing -Wno-implicit-fallthrough -Wno-unused-parameter -Wno-sign-compare -Wextra -std=c99 -static -fno-pie -no-pie -mno-red-zone -nostdlib -nostdinc -fno-omit-frame-pointer -pg -mnop-mcount -I./include -include ./cosmopolitan/cosmopolitan.h -fvisibility=hidden -Iphp-src/ext/hash/sha3/generic64lc -DKeccakP200_excluded -DKeccakP400_excluded -DKeccakP800_excluded -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -Iphp-src/ext/hash/xxhash -c php-src/ext/hash/hash_xxhash.c -o ext/hash/hash_xxhash.lo -MMD -MF ext/hash/hash_xxhash.dep -MT ext/hash/hash_xxhash.lo
In file included from php-src/Zend/zend_config.h:1,
from php-src/Zend/zend_portability.h:43,
from php-src/Zend/zend_types.h:25,
from php-src/Zend/zend.h:27,
from php-src/m
0:00:17.080,0:00:21.220
So I'm Will, and
I was a
0:00:21.220,0:00:24.460
middleschool teacher,
and I ran a summercamp
0:00:24.460,0:00:27.840
and I did all these things.
@alganet
alganet / hours.sh
Created February 7, 2020 21:00
hours.sh
#!/usr/bin/env bash
calculate_debt_hours_per_day () {
total_debt="${1:-}"
hours_debt="${1%:*}"
minutes_debt="${1#*:}"
payment_days="${2:-}"
if test -z "$hours_debt"
then
@alganet
alganet / hers.sh
Last active July 16, 2024 18:07
Fast and portable mouse/keyboard terminal capture (zsh,ksh,mksh,bash on Windows+WSL, Linux or Mac OS)
#!/bin/sh
# Quick run: bash -c "$(curl -L https://git.io/fjToH)"
# CTRL+W to exit
set -euf
unsetopt FLOW_CONTROL GLOB NO_MATCH NO_SH_WORD_SPLIT NO_PROMPT_SUBST 2>/dev/null || :
write ()
{
#!/bin/sh
# Before
set 1 2 3 4 5
while test $# -gt 0;do
echo $1
shift
done