Sunday, November 29, 2015

Bash animations

Animations in various languages.

1. The donut.

$ gcc -lm donut.c -o donut

           k;double sin()
         ,cos();main(){float A=
       0,B=0,i,j,z[1760];char b[
 >i;i+=0.02){float c=sin(i),d=cos(j),e=
 h*e+f*g+5),l=cos      (i),m=cos(B),n=s\
in(B),t=c*h*g-f*        e;int x=40+30*D*
(l*h*m-t*n),y=            12+15*D*(l*h*n
+t*m),o=x+80*y,          N=8*((f*e-c*d*g
 )*m-c*d*e-f*g-l        *d*n);if(22>y&&


Other interesting things:

2. Yahoo

$ gcc -lm yahoo.c -o yahoo


c,p,i,j,n,F=40,k,m;float a,x,y,S=0,V=0;main(){for(;F--;usleep(50000),F?puts(
i-27),i++<73;putchar(c[" ''\".$u$"]))for(c=0,n=3;n--;)for(y=S*(j+n-36),k=0,c
m=8:0)a=(k["O:85!fI,wfO8!yZfO8!f*hXK3&fO;:O;#hP;\"i[by asloane"]-79)/14.64;}

3. Explode

$ python



import sys, math, time, random

def distance(x, y):
    # ((y - y_center) * 2) -> correct ratio for a true circle
    return math.ceil(math.sqrt(((x - 40) ** 2) + (((y - 12) * 2) ** 2)))

def star(radiuses):
    for r in radiuses:
        #~ clear screen:
        print chr(27) + "[2J"

        # width
        for y in range(24):
            # height
            for x in range(80):
                d = distance(x, y)

                #~ border
                if (d == r):
                #~ inside the star
                elif (d < r):
                    if (r > 35):
                        sys.stdout.write(' ')
                    elif (r > 25) and ((d % 2) != 0):
                    elif (r > 15) and ((d % 2) == 0):
                        sys.stdout.write(' ')
                    else :
                #~ space outside the star
                    sys.stdout.write(' ')

star(range(0, 12) + range(10, 0, -1) + range(0, 50))


3. car

$ gcc car.c -std=c99  -o car


#ifdef _WIN32
#define CLEAR "cls"
#define SLEEP "ping -n 1 localhost > nul"
#else //In any other OS
#define CLEAR "clear"
#define SLEEP "ping -c 1 localhost > nul"

void printline(char *, int);
void drawcar(int);

void printline(char *line, int no)
int i;
for( i = 0; i < no; i++)
  printf(" ");
printf("%s\n", line);

void drawcar(int no_of_spaces)
 char *line1 = "       .--------.";
 char *line2 = " ____/_____|___ \\___";
 char *line3 = " O    _   - |   _   ,*";
 char *line4 = " '--(_)-------(_)--'";
 printline(line1, no_of_spaces);
 printline(line2, no_of_spaces);
 printline(line3, no_of_spaces);
 printline(line4, no_of_spaces);
int main()
  int i;
  for (int i = 0; i < 50; i++)


4. The cat.

$ chmod +x cat
$ ./cat


#  --------------------------------------------------------------------------
#  (c) 2012 BruXy            Version: 1.0   
# downloaded with permission 
#  --------------------------------------------------------------------------
# switch off cursor, set blue background, clear screen
echo -e "\E[?25l\E[44m\E[2J"

# Play music
[ ! -f $M ] && wget -O $M >/dev/null 2>&1
while true; do mplayer $M > /dev/null 2>&1; done &

# easy way to reset terminal and exit subprocesses
trap "reset;killall" 2

## Nyan cat ANSI picture data, my own creation :P, size 38 x 11
# Compressed version of picture

# decompress it to $C
C=`echo "$D" | base64 -d | zcat`

# hash field with 'pixel' atributes
declare -A B

B=([A]=43\;30m▀ [a]=43\;30m▄ [B]=47\;30m▀ [b]=47\;30m▄ [C]=43m\  [D]='47m '
[E]=1\;40\;37m▀\\E[0m [F]=44m\  [G]=40m\  [H]=1\;31m█\\E[0m [I]=0\;35m█
[J]=44\;30m▄ [j]=44\;30m▀ [K]=45\;30m▄ [k]=45\;30m▀ [L]=43\;35m▀
[l]=43\;35m▄ [M]=45\;31m▄ [O]=31m█ [o]=44\;31m▄ [P]=33m█ 
[R]=42\;33m▀ [S]=42\;32m█ [s]=46\;32m▀ [T]=46\;36m█ [t]=46\;30m▄
[U]=45\;35m█ [u]=46\;35m▀ [V]=43\;30m▄ [v]=42\;30m▀ [W]=45\;30m▀
[X]=43\;32m▄ [x]=32m█ [c]=44\;36m▀ [d]=42\;35m▄ [e]=41\;33m▄ [Z]=44m\\n)

# get size of terminal window
read X Y <<< `tput cols; tput lines`

# some terminals have problem with background color change
# this fills screen with spaces and fill my signature to bottom left
printf "%*s" $[X*Y] BruXy

### Draw Nyan Cat

# set position to the center

# go through image data and draw them to specified position

j=1 #row    ... y
k=1 #column ... x
for i in {0..417} #38*11-1 image size
    p=${C:$i:1} # get pixel
    # put pixel to given position \E[y;xH
    echo -en "\E[$[j+yp];$[k+xp]H\E[${B[$p]}"
    # if pixel Z is found go to next row (pixel count worked strange)
    k=$[k++,k%38]; [ $p = 'Z' ] && : $[j++]

### Star animation

# Field with stars animation
S=("       " "      " "       " "       "
"       " "  ▄▀▄  " "      " "       "
"      " "      " "▀▀  ▀▀" "      "
"      " "     " "     " "    "
"      " "       " "     " "      ")

# function for star drawing
# $1 .. column, $2 .. row position
s () {
    echo -en "\E[1;37m" # set bright white
    for j in {0..4} # for each line
        # draw one star frame of animation
        for i in {0..3}
            echo -en "\E[$[i+$1];$[$2+m]H\E[1;37m${S[$[i+4*j]]}\E[0;44m"

        sleep 0.2

        # erase star
        for i in {0..3}
            echo -en "\E[$[i+$1];$[$2+m]H\E[44m${S[0]}"
        : $[m-=5] # move the next frame 5 columns to the left

# count star positions according to nyan cat position 
# -3,+3 best constant, I've played with those numbers
# to get best position of stars and do not destroy the cat :)
my=$[(Y-11)/2 - 3]
My=$[my+11 + 3]

while true
    for i in $(eval echo {1..$my..4}) # each position 4 rows difference
        # draw top star, animation has 20 columns length, so generated
        # for lowest start position columns is 0+20
        (s $i $[20 + $RANDOM % (X - 20)]) &
        # draw bottom star 
        (s $[i+My] $[20 + $RANDOM % (X - 20)]) &
    sleep 0.5
done &

### Draw rainbow flag

# oOPXxUuT .. top wave, OePxdUTc bottom wave

# Flag waving:
# $c .. flip flop when counter $i modulo 5 is zero,
#       then it adress top or bottom wave
while true
    : $[c^=1]
    for x in `eval echo {1..$[xp]}`
        if [ $[i++ % 5] -eq 4 ]; then : $[c^=1]; fi;
        for y in {0..7}
            echo -en "\E["$[yp+y+2]";${x}H\E[${B[${A:$[y+(c*8)]:1}]}\E[0m"
    sleep 0.5

5. Matrix

$ chmod +x matrix
$ ./matrix

echo -e "\033[2J\033[?25l"R=`tput lines` C=`tput cols`;: $[R--] ; while true 
do ( e=echo\ -e s=sleep j=$[RANDOM%C] d=$[RANDOM%R];for in `eval $e {1..$R}`;
do c=`printf '\\\\0%o' $[RANDOM%57+33]` ### ###
$e "\033[$[i-1];${j}H\033[32m$c\033[$i;${j}H\033[37m"$c; $s 0.1;if [ $i -ge $d ]
then $e "\033[$[i-d];${j}";fi;done;for in `eval $e {$[i-d]..$R}`; #[mat!rix]
do echo -e "\033[$i;${j}";$s 0.1;done)& sleep 0.05;done #(c) 2011 -- [ BruXy ]

Slide rule

You can make your own temporary slide rule that should somewhat accurate using very simple parts. (not drawn to scale).

Styrofoam board.
Clear plastic.

To get some templates:

$ wget

That need to be cut apart for the sections.

 The bottom section is for the backside of the center section,

Add labels.

Or to put it together.


 Slide rule tutorial:

Tuesday, November 24, 2015

Clear tv?

Noticed the Cleartv has changed antennas. The original antenna was not received very well and had some scathing reviews. Plus the specifications were easily attainable.   We made our our own version.

Now I have noticed they have come up wigh a new antenna and the pictures are blurred with no specific technical details in the advertisements. Wondering why that is?

If I get a chance to duplicate it I will let you know.

Could it be?

Saturday, November 21, 2015

Dumb terminal to thin client.

Years ago there real was not a terminal that you could cozy up to to do your computing. In the beginning  there was a punch card machine. You would type in your data, your program in to 80 column punch cards. On this cards you would also have to number them. If the cards went into a pile, there would be an unpleasant experience reorganizing them. Used one of these for writing programs in Fortran.

Eventually systems came with enough storage, that you did not need to carry the punch cards and you could print out what you keyed in and the results of what you were working on with the printing terminal. Finance company I worked for had one of thes that connected to an acoustical modem contract the credit bureau..

The finally we get a crt soft of like a tv with a keyboard.  Worked much like the printing terminal. You could even edit what you were working on in real time. Saved a lot of paper. You can not see it very well but the text was in green. Used one of these at a real outlet for sending email and doing various reports. These were still used less than 20 years ago.

Eventually the terminals also know as thin clients became more portable and you could use standard monitors with them. Thin clients came two way, they either had an embedded minimal operating system, remote desktop client, or  a minimal operating system was installed from the network onto the systems. They basically connect to a server that does all the heavy lifting. The unit had no drives or off-line storage. This terminal is working with an Linux terminal server.

And now the ultimate in thin clients with the touchpads that are generally driven by web servers.

A fractured fairy tale history.

Ordering from the menu.

Web pages with menus are sure easy to navigate. In fact, I like all the base menus in one place so that you do not have to go though a maze to get what you want.

The menus are just one part of the page, so let's zoom in and see that we are looking at. The menu takes up minimal space, but expanding a pull-downs make it easy to manage.

Wrote this years ago so I am sure there are much better ways to do it now, but it still works for me on a private server. The menu is pretty much a large table comprised of sections having each option menu.


<form name="jump1">
<select name="menu1" onchange="top.location=document.jump1.menu1.options[document.jump1.menu1 ...
<!-- option value="../flatpress">Flatpress</option>
<option value="../wiki">Mediawiki</option> -->
<option value="../wordpress">Wordpress</option>
<option value="../vh/">Scrapbook</option>
<!-- <option value="../habari">Habari</option> -->

Notice there are some lines commented out of former options that were a part of the menu. But that is ok because they will not be shown. So what does the total page look like?

Notice that each section is named separately.  So here you go a quick and dirty menu section.

Note: in the main menu I nave set up a reference to make links easier.


<title> Offshore Educators (Main Page) 1 </title>
<base href="http://oeorgan1/oe/">

Have fun.

Friday, November 13, 2015

It's web time.

Ever wonder what would be like to have a local web app for the time without having to connect to some far off unknown place with who knows what hidden features.

Now you can have local clock time on your server

<table border=2>
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
document.write("<small><font color='000000' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</b></font></small>")
<span id=tick2>

function show2(){
if (!document.all&&!document.getElementById)
thelement=document.getElementById? document.getElementById("tick2"): document.all.tick2
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
var dn="PM"
if (hours<12)
if (hours>12)
if (hours==0)
if (minutes<=9)
if (seconds<=9)
var ctime=hours+":"+minutes+":"+seconds+" "+dn
thelement.innerHTML="<b style='font-size:14;color:blue;'>"+ctime+"</b>"

Open for business?

This is two scripts one to find and record machines on the system at the time and the second script is to find open ports on those systems below 1024.
rm /tmp/goodips
  ping -c 1 $1 > /dev/null
  [ $? -eq 0 ] && echo $i >> /tmp/goodips

for i in 192.168.1.{1..255}
is_alive_ping $i & disown


Now the second script.
m="not done"
while read line
do fdata[$a]=$line
echo $line
       let a=a+1
       for p in {1..1023};
       (echo >/dev/tcp/$line/$p) >/dev/null 2>&1 && echo "$p open"
done < $datafile

23 open
53 open
80 open
22 open
23 open
25 open
80 open
111 open
443 open
465 open
587 open
21 open
80 open
139 open
515 open
22 open
111 open

Vulnerabilities abound. Now would be a good time to install and run both chkrootkit and or rkhunter.

$ sudo apt-get install rkhunter chkrootkit

$ sudo  rkhunter --update
$ sudo  rkhunter -c

$ sudo chkrootkit

Tuesday, November 10, 2015

Another Tuxpaint hint.

Using two or more programs together can make a system more powerful. In this case we want to use Tuxpaint and the Gimp.  We will start off using Tuxpaint to make a picture and then take a screen shot just of the drawing.

The let's import a picture we have downloaded and use Tuxpaint to edit it and then of course to take a screen shot of that.

Then we need a screen shot that was made a while back.

The we need to open up the Gimp and set up a new page several times larger than the pictures and then import the three pictures.

Then you can export that picture and import it into tuxpaint for final editing.

So then you can use it in a web page like you blog or where ever

Saturday, November 7, 2015

Secure yourself.

Linux commandment: Thall shall not login remotely as root.

If your a good linux admin, you did this when you first set up the machine.

$ cd /etc/ssh
$ sudo vim sshd_config

Change the line that says permit Root login to no
in vim should find the line quickly

# Authentication:
LoginGraceTime 120
# PermitRootLogin yes
PermitRootLogin no
StrictModes yes

Save and exit the file.

Restart the service:

$ sudo service ssh restart

Friday, November 6, 2015

The PCinoPi

The PCinoPi available from many junk closets is not faster than a speeding bullet and  not faster than a speeding train but it can easily introduce you to computers and electronics. Will run Pitus Linux, Atomic Linux, Freedos (with Qbasic), among other operating systems right from the floppy drive. (Pictured is an i486 laptop)

You can easily do digital control with it's legacy parallel port. Lighting led's is a cinch. Controlling  rocket launchers is another benefit.  Need to do analog input? With a few discrete parts you can even get analog values too. Say grabbing the temperature. If the vga port is new enough, you can even use I2C

Picture of i2c interface. 

Extra cable and interfacing not included but can be built with off the shelf parts.

Picture of Vga breakout cable. 

Picture of DB9 serial break out cable.

Parallel (

Picture of Ready to use.

also see (

Thursday, November 5, 2015

Tuxpaint cad?

Tuxpaint can be good for drawing pictures, cartoons, and the like, but if we let it stretch it's muscles there is more that can be done. Maybe use it as a sort of drafting program. A drawing usually has at least four views. They are the front, side, top, and isometric (roughly translated at an angle).  If you needed a simple step stool, you certainly can make a drawing to reflect that. In this case you only have a partial isometric, but the point gets across.

Maybe you could do a floor plan:

A 3d object in 2d.

Then all the rest....

Circuit design.

Have fun.