Skip to content

Instantly share code, notes, and snippets.

@sontek
Last active January 27, 2026 13:29
Show Gist options
  • Select an option

  • Save sontek/1505483 to your computer and use it in GitHub Desktop.

Select an option

Save sontek/1505483 to your computer and use it in GitHub Desktop.

Revisions

  1. sontek revised this gist Dec 26, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions snowjob.sh
    100644 → 100755
    Original file line number Diff line number Diff line change
    @@ -19,7 +19,7 @@ function move_flake() {
    fi
    fi

    printf "\033[%s;%sH*\033[1;1H" ${snowflakes[$i]} $i
    printf "\033[%s;%sH\u274$[($RANDOM%6)+3]\033[1;1H" ${snowflakes[$i]} $i

    lastflakes[$i]=${snowflakes[$i]}
    snowflakes[$i]=$((${snowflakes[$i]}+1))
    @@ -37,4 +37,4 @@ do
    done

    sleep 0.1
    done
    done
  2. sontek renamed this gist Dec 23, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. sontek revised this gist Dec 21, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -15,11 +15,11 @@ function move_flake() {
    snowflakes[$i]=0
    else
    if [ "${lastflakes[$i]}" != "" ]; then
    printf "\033[%s;%sH \033[0;0H " ${lastflakes[$i]} $i
    printf "\033[%s;%sH \033[1;1H " ${lastflakes[$i]} $i
    fi
    fi

    printf "\033[%s;%sH*\033[0;0H" ${snowflakes[$i]} $i
    printf "\033[%s;%sH*\033[1;1H" ${snowflakes[$i]} $i

    lastflakes[$i]=${snowflakes[$i]}
    snowflakes[$i]=$((${snowflakes[$i]}+1))
  4. sontek revised this gist Dec 21, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -3,11 +3,11 @@
    LINES=$(tput lines)
    COLUMNS=$(tput cols)

    clear

    declare -A snowflakes
    declare -A lastflakes

    clear

    function move_flake() {
    i="$1"

  5. sontek created this gist Dec 21, 2011.
    40 changes: 40 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    #!/bin/bash

    LINES=$(tput lines)
    COLUMNS=$(tput cols)

    clear

    declare -A snowflakes
    declare -A lastflakes

    function move_flake() {
    i="$1"

    if [ "${snowflakes[$i]}" = "" ] || [ "${snowflakes[$i]}" = "$LINES" ]; then
    snowflakes[$i]=0
    else
    if [ "${lastflakes[$i]}" != "" ]; then
    printf "\033[%s;%sH \033[0;0H " ${lastflakes[$i]} $i
    fi
    fi

    printf "\033[%s;%sH*\033[0;0H" ${snowflakes[$i]} $i

    lastflakes[$i]=${snowflakes[$i]}
    snowflakes[$i]=$((${snowflakes[$i]}+1))
    }

    while :
    do
    i=$(($RANDOM % $COLUMNS))

    move_flake $i

    for x in "${!lastflakes[@]}"
    do
    move_flake "$x"
    done

    sleep 0.1
    done