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
  • 19:20 (UTC +12:00)
View GitHub Profile
@roblogic
roblogic / hackerlogo-sm.bas
Created December 17, 2020 02:43
Shorter version, slower and the drawing is a bit worse, but saves bytes :P
0data51,29,73,51,73,73,51,73,29,73
1hgr:hcolor=3:fori=0to123:hplot0,i to123,i:next
2hcolor=0:fori=18to84step22:hplot18,i to84,i:hploti,18toi,84:next
3fori=1to5:reada,b:a=a+.5:b=b+.5:gosub8:next:end
8forr=1to9:hplota,b:forn=0to6.3step.1:y=sin(n)*r:x=cos(n)*r:hplottoa+x,b+y
9next:next:return
@roblogic
roblogic / hacker-logo-glider.bas
Created December 17, 2020 02:41
Apple II BASIC code for drawing the "hacker logo": a glider from Conway's Game of Life
0data51,29,73,51,73,73,51,73,29,73
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
3fori=1to5:reada,b:a=a+.5:b=b+.5:gosub4:next:end
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
7next:next:return

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]

character(99)S;read(*,'(A)')S
S='"'//trim(adjustl(S))//'"'
do i=1,len(S);if(S(i:i+1).ne.'  ')then
write(*,'(A)',advance="no")S(i:i)
endif;enddo;end
@roblogic
roblogic / zshexpn-explained.md
Created November 19, 2020 01:49
Regular Expressions in Zsh

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

${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
roblogic / triangles.zsh
Last active November 10, 2020 23:49
Golf solution to "ASCII Triangles", https://codegolf.stackexchange.com/a/215028/15940 (60 bytes)
for ((;i<$1;))printf "|%$[i++]s\\\\\n"&&a=$a-
(($1))&&<<<$a-
@roblogic
roblogic / static
Created November 4, 2020 23:39
fun with @ish_app -- fill screen with technicolor spew
#!/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 / patt
Last active October 12, 2020 05:22
pattern matcher for doing simon shuker's code-cracker in the nz herald. ".txt" uses data from https://github.com/dolph/dictionary/blob/master/unix-words
#!/bin/sh
[ "$1" ] || { echo "pattern?"; exit; }
patt="$1"
grep -E "^$patt$" *.txt | awk -F: '{print $2}'| sort -u | paste - - - - -
@roblogic
roblogic / .profile
Last active October 12, 2020 05:02
my jazzy iSH profile for iPhone
uname -v
neofetch --off
#resize
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
roblogic / stan.user.css
Last active February 8, 2024 00:11
messing about with a blog's CSS
/* ==UserStyle==
@name TheStandard ReArranger
@description Change fonts and rearrange random things for fun and $$$
@namespace https://github.com/roblogic
@version 0.1.1-groovy
@author roblogic
@license unlicense
@preprocessor stylus
==/UserStyle== */
@roblogic
roblogic / CP437.md
Last active January 27, 2024 06:20
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:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~�
ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐
└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ 

Found this useful bash script on stackoverflow.