This file contains hidden or 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 | |
| seq 100 \ | |
| | while read n | |
| do echo $((n % 3)),$((n % 5)) $n | |
| done \ | |
| | while read mod n | |
| do | |
| case "$mod" in | |
| 0,*) printf Fizz ;;& |
This file contains hidden or 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/local/bin/bash | |
| enable -f accept accept | |
| set -u | |
| shopt -s nullglob | |
| SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | |
| STATE_DIR="$PWD/state" # TODO: XDG_STATE or something? :) | |
| GRID_DIR="$STATE_DIR/grid" |
This file contains hidden or 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
| function a(b, c = 0) { | |
| d=b.length | |
| if (!d) return '' | |
| n = b[d - 1] | |
| let r = ((n != '-' && c && !(c % 3)) ? ',' : '') + n + a(b.slice(0, d - 1), c + 1) | |
| if (!c) return r.split('').reverse().join('') | |
| return r | |
| } |
This file contains hidden or 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
| int latency = AudioSettings.outputSampleRate / 10; | |
| AudioClip clip = Microphone.Start(device, true, 1, AudioSettings.outputSampleRate); | |
| int last = 0; | |
| int dist(int samples, int start, int end) { | |
| if (end >= start) return end - start; | |
| return (end + samples) - start; // handle wrapping | |
| } | |
| while(true) { |
This file contains hidden or 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
| i=0 | |
| j=0 | |
| while [ "$i" -lt 600 ]; do | |
| n=$(((i-60)/2)) | |
| if [ "$n" -lt 0 ]; then | |
| n=255 | |
| fi | |
| if [ "$n" -gt 255 ]; then |
This file contains hidden or 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 | |
| tput civis | |
| declare -a arr0 | |
| declare -a arr1 | |
| idx=0 | |
| declare -n cur=arr0 | |
| declare -n next=arr1 |
This file contains hidden or 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 | |
| # terrible lisp interpreter | |
| # | |
| # example run: | |
| # | |
| # (first (list 1 (+ 2 3) 9))) | |
| # | |
| # evaluating + 2 3 = 5 | |
| # evaluating list 1 5 9 = 1,5,9 |
This file contains hidden or 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 | |
| # basic lisp parser that creates an AST. | |
| # assumes valid input. | |
| # | |
| # it stores this AST using the file system, since | |
| # bash doesn't really have a good way to do trees | |
| output_path=/tmp/parsed |
This file contains hidden or 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 | |
| echo -ne "\033[38;5;$((RANDOM % 255))m" | |
| printf -v hex "%x" "$((RANDOM % 93 + 33))" | |
| printf "\x${hex}" |
This file contains hidden or 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 | |
| # solution for https://chrzanowski.me/blog_0003.html | |
| seq $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $(echo $BASH_SUBSHELL)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) |
NewerOlder