Skip to content

Instantly share code, notes, and snippets.

View roblogic's full-sized avatar
💭
probably playing code golf

Rob Papesch roblogic

💭
probably playing code golf
  • Auckland, NZL
  • 12:02 (UTC +12:00)
View GitHub Profile
@roblogic
roblogic / README.md
Created August 21, 2023 09:52 — forked from brennanMKE/README.md
Clone All Gists

Clone All Gists

This is a shell script version of the Node.js version created by mbostock.

Place it in a directory in your PATH and set the permissions.

chmod u+x clone-all-gists
@roblogic
roblogic / yakgolf
Created February 3, 2023 20:54
Solution to Code Golf problem: "Yakko's New World Order", https://codegolf.stackexchange.com/q/257358/15940
#!/bin/zsh
argv=(abudhabi afghanistan albania algeria algiers angola argentina australia austria bahamas bahrain bangladesh barbados belgium belize benin bermuda bhutan bolivia borneo botswana brazil bulgaria burma burundi cameroon canada caribbean cayman chad chile china colombia congo costarica crete cuba cyprus czechoslovakia dahomey denmark djibouti ecuador egypt elsalvador england ethiopia fiji finland france frenchguiana gabon gambia germany ghana greece greenland guam guatemala guinea guinea-bissau guyana haiti honduras hongkong hungary iceland india indonesia iran iraq ireland israel italy jamaica japan jordan kampuchea kenya korea kuwait laos lebanon lesotho liberia libya liechtenstein luxembourg madagascar mahore malawi malaysia mali malta mauritania mexico monaco mongolia morocco mozambique namibia nepal newguinea newzealand nicaragua niger nigeria norway oman pakistan palestine panama paraguay peru poland portugal puertorico qatar republicdominican romania russia rwanda sanjuan saudiarabia scotlan
@roblogic
roblogic / bits.85
Last active November 23, 2022 05:14
Snippets for Arecibo Code Golf answer https://codegolf.stackexchange.com/a/191473/15940
0&M8}p.B@#L#QZE00001Fb*2U02+?qq#={[000069asT6g8.)4ZwEwH000Mg1onA4aoh}/0Q{6?7
?7Abap8T<N!#M/0000:ZZ{J%0d$no1{.{L01Yzs5hjUju{Cb/00eC!f:[8q1oX#k5eUKnfBigKaB
[#)FcD1?fA=JG2NyzwD&LsiWGLW<&LA29Gr+T=<o=q3huiZS05#83BRN)l3zmwk01TOWF4#ep&0Y
P[gY.1d24nhWll]9LmgYDLaoqEc0f^Fe]ZR$Y
#!/bin/zsh
setopt extendedglob
s=0
f(){
q=(${(s: :)${1//(#s)d/1d}//[^0-9]/ })
for i ({1..$q[1]})((s+=RANDOM%q[2]+1))
<<<$[s+q[3]]
}
f d1
f d6
@roblogic
roblogic / fizzbuzz.f
Created November 7, 2022 15:39
fizzbuzz in gfortran (145 bytes), for code golf challenge https://codegolf.stackexchange.com/a/254203/15940
character(8)s;do i=1,100;s=''
if(mod(i,3)<1)s='fizz';if(mod(i,5)<1)s=trim(s)//'buzz'
if(s>'')then;print'(A)',s;else;print'(i0)',i;endif;enddo;end
@roblogic
roblogic / sync_media
Created November 7, 2022 15:33
another rsync script
#!/bin/zsh
#set -x
do_sync(){
target=$1
rsync -iPr --size-only --dry-run --delete /Volumes/Seagate-6TB/$target /Volumes/Seagate-8TB \
| grep -e ".mkv$" -e ".mp4$" -e ".avi$"
objects=`rsync -iPr --size-only --dry-run --delete /Volumes/Seagate-6TB/$target /Volumes/Seagate-8TB \
| grep -e ".mkv$" -e ".mp4$" -e ".avi$" | wc -l`
echo
@roblogic
roblogic / gruvbox8-to-vim
Last active November 7, 2022 16:41
Import new colorschemes to MacVim via Terminal
#!/bin/zsh
# refs:
# https://vimcolorschemes.com/lifepillar/vim-gruvbox8
# https://github.com/lifepillar/vim-gruvbox8
cd ~/.vim/colors
chmod 777 .
curl https://raw.githubusercontent.com/lifepillar/vim-gruvbox8/master/colors/gruvbox8.vim -o gruvbox8.vim
curl https://raw.githubusercontent.com/lifepillar/vim-gruvbox8/master/colors/gruvbox8_hard.vim -o gruvbox8_hard.vim
curl https://raw.githubusercontent.com/lifepillar/vim-gruvbox8/master/colors/gruvbox8_soft.vim -o gruvbox8_soft.vim
@roblogic
roblogic / fast-rsync.zsh
Last active September 7, 2022 20:50
rsync with minimal fuss, matching in size only. much faster than archive mode, does not bother with checksums. also removes crud from torrent dls
cd /Volumes/Seagate-6TB
find . -name "*YTS.*.jpg" -or -name "*YIFY-TORRENTS*" -or -name "*YTSProxies*" \
-or -name "*.exe" -or -name "*torrentgalaxy*" -or -name "RARBG*txt" \
-or -name "WWW.YTS.*.jpg" \
-delete
rsync -ivPr --size-only --delete /Volumes/Seagate-6TB/@tv-series /Volumes/Seagate-8TB
rsync -ivPr --size-only --delete /Volumes/Seagate-6TB/movies2022 /Volumes/Seagate-8TB
@roblogic
roblogic / static.zsh
Created October 29, 2021 00:14
fill the terminal with random coloured blocks
#!/bin/zsh
P=(' ' █ ░ ▒ ▓)
while :;do
printf "\e[9$(( ( RANDOM % 7 ) + 1 ))m\e[$[RANDOM%$LINES+1];$[RANDOM%$COLUMNS+1]f${P[$RANDOM%5]}"
done
@roblogic
roblogic / h2txt
Last active October 11, 2021 13:42
experimental messing about with nzh source ;)
#!/bin/zsh
[ $1 ]||{echo "Usage: $0 <nzherald-url>"&&exit 1;}
page=`mktemp herald.htm.XXXXX`
curl -s $1 > $page
echo "Extracting to: $page.txt"
xmllint --html --format $page --nowarning --xpath "//p" 2>/dev/null \
| perl -pe 's|<p.*?>||g;s|<span.*?>||g;s|</.*?>|\n|g;s|\n\n ||g' \
| fmt -p -s | perl -pe 's|<strong>||ig;s|&amp\;|&|g;s| ||g' \
| fmt -s | tee $page.txt | less
#