Skip to content

Instantly share code, notes, and snippets.

probably playing code golf

Rob Papesch roblogic

probably playing code golf
  • Auckland, NZL
View GitHub Profile
roblogic / hackerlogo-sm.bas
Created Dec 17, 2020
Shorter version, slower and the drawing is a bit worse, but saves bytes :P
View hackerlogo-sm.bas
1hgr:hcolor=3:fori=0to123:hplot0,i to123,i:next
2hcolor=0:fori=18to84step22:hplot18,i to84,i:hploti,18toi,84:next
roblogic / hacker-logo-glider.bas
Created Dec 17, 2020
Apple II BASIC code for drawing the "hacker logo": a glider from Conway's Game of Life
View hacker-logo-glider.bas
1hgr2:hcolor=3:fori=0to191:hplot0,i to191,i:hplot i,0toi,191:next
2hcolor=0:fori=18to84step22:hplot18,i to84,i:hplot i,18toi,84:next
4forr=0to9step0.5:r2=r*r:for x=0 to r:y=sqr(r2-x*x)
5hplot a+x,y+b:hplot a-x,y+b:hplot a+x,-y+b:hplot a-x,-y+b
6hplot a+y,x+b:hplot a-y,x+b:hplot a+y,-x+b:hplot a-y,-x+b

Per [wikibooks][1], "It should be remembered that Fortran is designed for scientific computing and is probably not a good choice for writing a new word processor.". Fortran doesn't have a regex concept either. This just makes [string][2] [challenges][3] more [interesting][4]!

In this solution, we trim the string S, then iterate over it. Print each character unless it's a space followed by another space. [Try it Online!][5]

do i=1,len(S);if(S(i:i+1).ne.'  ')then
roblogic /
Created Nov 19, 2020
Regular Expressions in Zsh

The following is taken from a brilliant answer on Posting it here for personal reference. The question was:

What kind of patterns can I use in zsh parameter expansion?

${var//pattern/replacement} is using zsh wildcard patterns for pattern, the same ones as used for filename generation aka globbing which are a superset of the sh wildcard patterns. The syntax is also affected by the kshglob and extendedglob options. The ${var//pattern/replacement} comes from the Korn shell initially.

I'd recommend enabling extendedglob (set -o extendedglob in your ~/.zshrc) which gives you the most features (more so than standard EREs) at the expense of some backward incompatibility in some corner cases.

You'll find it documented at info zsh 'filename generation'.

roblogic / triangles.zsh
Last active Nov 10, 2020
Golf solution to "ASCII Triangles", (60 bytes)
View triangles.zsh
for ((;i<$1;))printf "|%$[i++]s\\\\\n"&&a=$a-
roblogic / static
Created Nov 4, 2020
fun with @ish_app -- fill screen with technicolor spew
View static
P=(' ' █ ░ ▒ ▓)
while :;do
printf "\e[9$(( ( RANDOM % 7 ) + 1 ))m\e[$[RANDOM%$LINES+1];$[RANDOM%$COLUMNS+1]f${P[$RANDOM%5]}"
roblogic / patt
Last active Oct 12, 2020
pattern matcher for doing simon shuker's code-cracker in the nz herald. ".txt" uses data from
View patt
[ "$1" ] || { echo "pattern?"; exit; }
grep -E "^$patt$" *.txt | awk -F: '{print $2}'| sort -u | paste - - - - -
roblogic / .profile
Last active Oct 12, 2020
my jazzy iSH profile for iPhone
View .profile
uname -v
neofetch --off
set -o vi
export PS1="\w$ "
alias l="ls -alp"
alias ll="ls -alptr|tail -20"
alias ls="ls -p"
rap(){ echo "$(fortune)" \
|tr -d '\t'|tr '\n' ' ' \
roblogic / stan.user.css
Last active May 30, 2020
messing about with a blog's CSS
View stan.user.css
/* ==UserStyle==
@name TheStandard ReArranger
@description Change fonts and rearrange random things for fun and $$$
@version 0.1.0-fiasco
@author roblogic
@license unlicense
@preprocessor stylus
==/UserStyle== */
roblogic /
Last active Apr 4, 2021
Code Page 437 / Extended ASCII

CP437 is a ubiquitous character set that appears somewhat obsolete, but is still found everywhere. Usually seen in BIOS, there are no fancy fonts here. Here's the charset, using UTF-8 equivalents.

································ !"#$%&'()*+,-./0123456789:;<=>?

Found this useful bash script on stackoverflow.