Home

More than you can hold.

Leave a comment

Chit chat

———–

Supposedly an update to vim, so I updated my Arch Linux box.

Do mirror this blog to others, so I am not copying someone’s work.

Story about #Munich backing out of #linux is allegely overbloated. http://www.omgubuntu.co.uk/2014/08/munich-council-say-talk-limux-demise-greatly-exaggerated

When it comes to #computers: Amateurs #reinstall. Professionals fix the problem and only reinstall as a last resort. #tech #support

You feel foolish when you have installed applications on a #web server a zillion times, but you make simple mistakes like typing in a url of phpmysql when it should of been phpmyadmin. Been a while, but the app is installed.
#linux
Batch file to slowly print out a text file. Perfect for a quickie teleprompter.
Still use the Chumby for many things. One is a portable Muzak.
As time goes on…..

——————————————————

If you are into arduino type stuff, this may interest you.
Avrian Jump

===========

A very simple ladder language for programming ATMega168s from a web browser.

This started out as a desire to be able to program an [Arduino][] from an iOS device.  Since it doesn’t seem like compiler tools of any sort would get into the app store, I figured something would need to be done in HTML5.  And if a [PC emulator][pcemu] could be written in javascript, so could something like this.

However, recreating the Arduino IDE in HTML seemed like too much work, at least for a first try.  So I reduced the project into something much simpler, while still putting real machine code into the AVR’s flash.  A simple ladder language that compiled into AVR assembly, which would be assembled into machine code, seemed like like a resonable reduction.  With that I could take advantage of the [Audioino][] bootloader, to load right from the web page.

This is still unfinished, go see the TODO file.

Also go read issue #2, playing sounds encoded in data URIs in iOS 5.1 is broken. *sigh*

Try it out! [Avrian Jump](http://tadpol.github.com/Avrian-Jump/avrianjump.html)

Some other ways (likely better) of putting Arduino IDEs into web browsers:
– [wifino](http://www.wifino.com/)
-

[codebender](http://codebender.cc/)

The Ladder
———-

Each rung on the ladder has a single test and multiple actions.  Tests can check the digital pins, analog pins, and a couple of variables.  Each action can set a digital pin, a PWM output, or a variable.  Analog, PWM, and variables are 16bit values.

There is no ‘setup()’.  Analog pins are always analog inputs.  When specified in a test, a digital pin is set to an input then read.  When specified in an action, it is set to an output then set.

PWM code is still non-existant, so how this will actually work is up in the air.  How I want it to work is:  Specifying a pin in an action as a PWM output makes it a PWM output.  Specifying a pin in a test stops it from doing PWM output.  Specifying a digital state for the pin in an action also stops it from doing PWM output.

There is an ascii format of the ladders.  This was done because it seemed like it could be neat to be able to tweet ladders.  You can view the ascii format, and also load ladders from it.  The ascii parser skips anything it doesn’t recognise; it is a bit too forgiving at times.

An example program:

#Fast Blink LED
:T;A+=1
:A=16383;D13=1
:A=32767;D13=0,A=0

Mostly though, a ladder is converted into AVR assembly.

The Assembler
————-

The assembler is pretty basic. Lots of features commonly found in other assemblers are currently missing.  It does assemble the mneonics from [Atmel's pdf][avrasm] into machine code.  It supports labels, but not local labels.  It has simple parameter replacement, so common names can be defined for IO registers and memory regions and things.  It can also specify where in memory to put the machine code, and can specify immeadiate words to save in the machine code.

This assembler doesn’t know about the various AVR devices, and so will happily assemble any of the known mnemonics into the output.  Even if your target device has no idea what to do with them.  It has assembled blink tests for the ATmega168 and the ATTiny13, so it seems pretty flexable. (Avrian Jump currently only supports the ATmega168 though.  Maybe add others in the future, but would have to figure the bootloader thing out first.)

Outputs
——-

A ladder can be compiled into a few different formats:

- ASCII
– This the only form can can be converted back into a ladder.
– This is for sharing your ladder with others, or saving a ladder for later.
– S19
– If you don’t have an [Audioino][] bootloader, but still want to use a ladder.  A S19 can be ded with [avrdude][].
– WAV
– A [Audioino][] compatible wav file for loading the ladder onto an ATmega168 with the [Audioino][] bootloader installed.
– Assembler
– This is mostly around for debugging the ladder compiler.  It can be interesting to look at  too.

License
——-

Copyright (c) 2012 Michael Conrad Tadpol Tilstra

Licensed under the MIT License.

[Arduino]:http://www.arduino.cc/
[pcemu]:http://bellard.org/jslinux/
[avrasm]:http://www.atmel.com/atmel/acrobat/doc0856.pdf
[avrdude]:http://ladyada.net/learn/avr/avrdude.html
[Audioino]:http://www.hobby-roboter.de/forum/viewtopic.php?f=4&t=128&p=531

——————————————————

Legacy Robot notes.

Have not made much time to work on special projects. One thing I need to start back on is robopet.  There is nothing real super snazzy about this unit although it could be. Mainly I will use it for carrying snacks back and forth from the kitchen during sporting events. There will be a second level not currently attached to hold the goodies. More information about the unit follows.

Electronics:

Using an old Pentium I computer, usb wireless, DC battery power, dc-dc atx ps and compact flash with an ide conversion interface. Powered wheels came from two Tonka RC cars that I dissected.

Made a special wiring hardness to connect the parallel port with the control electronics. Now I need to start testing the electronics for the motor control. Hoping the h-bridge can take the current. If not, I think I have a IC that will. Worst case scenarios is to do it the old fashion way with transistors. After that, everything should fall into place.

Using a standard power supply to test the unit, but it will run on battery when I finish it. Since the motherboard is AT and the DC-DC PS is ATX, I had to make a special cable from scratch to interface the two. Tested the cable and it works.

Have the wireless working via a usb interface set up to work with a specific router via the mac address and the zone. Albeit the wireless is 11 mb, more than fast enough to receive and send communication

Special home made turn signals to be added also.

No sensors added yet.

Software:

The Linux OS is installed.  The OS resides on a compact flash.The iso file for the version of the Ubuntu distribution also resides on the flash drive and gets mounted as a loop.

Using my own home grown robot control software to gather data from sensors and to operate the unit. Found a binary of the very lightweight web server Boa on launchpad.net for the version of Ubuntu I am using. Installed it. Apache2 is too bulky for this project. Eventually, I want to make an autonomous unit.  This unit will be more like a remote controlled car via wifi.

Code to control the motors has already been tested (using parcon.c) and is working.   Using a hardwired connection, already tested client/server socket programming to communicate with and control the unit. That should be way more efficient and possibly more secure than using a web server per se..

Etc.

Had to make special adapter plates to connect the wheel assemblies to the cart. Originally I used clear plastic, but those broke too easily. Wood worked much better, but not as pretty. Attached a third generic cart wheel.

Extra: We installed ptelnet on an old Palm pda to use it as a dumb terminal. That way we do not have to hook the robot to a monitor when we want to access the unit. Saves electricity and makes it more portable. With the installation of Boa, the Chumby can also be used to control the robot without requiring an umbilical cord. Which means that getting an Android or the like tablet more feasible.

Added schematic for turning blinker.

Links:
http://www.instructables.com/id/Atx-to-At-ps-test-cable/
http://www.instructables.com/id/Linux-beginning-home-automation-on-a-server/
http://www.instructables.com/id/No-solder-parallel-port-break-out/
http://www.instructables.com/id/Mini-parallel-port-break-out-cable/
http://www.instructables.com/id/DB9-serial-break-out-cable/
http://www.instructables.com/id/Vga-breakout-cable/

Parcon.c for controlling parallel port

 #include <stdio.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/io.h>

char *binprint( unsigned char x, char *buf )
{
  int i;
  for( i=0; i<8; i++ )
    buf[7-i]=(x&(1<<i))?'1':'0';
  buf[8]=0;
  return buf;
}

int main( int argc, char *argv[] )
{
  char c;
  unsigned char val;
  char buf[9];
  int x;
  if( argc<2 )
  {
    printf("  example usage: parcon 1l 2l 3h 5h 8l\n");
    return 2;
  }
  if( ioperm(888,1,1) )
  {
    printf("Couldn't get port 888\n");
    return 1;
  }
  val = inb(888);
  printf("old = %s\n",binprint(val,buf));
  for( x=1; x<argc; x++ )
    if( argv[x][1]!='h' )
      val &= ~(1<<(argv[x][0]-'1'));
    else
      val |= 1<<(argv[x][0]-'1');
 
  printf("new = %s\n",binprint(val,buf));
  outb(val,888);
  return 0;
}

Photos:

------------------------------------------------------

One way to recycle an old case cover.

Variation for pants.

------------------------------------------------------

 If you ever take the time to see what vim can do you would be very surprised.

------------------------------------------------------

Math can be interesting! This is oversimplified, but we can use math for many things. One is that might want to know the position of a motor. In electronics, we might want to know what part of an AC cycle we are in such as reading oscilloscopes. . What is even more interesting, we do not have to have some fancy computer language in most cases to calculate what we need.  Then if you want to, you can port the code to a fancier language and or system.

Sine wave graph

$ ./sine

 cat sine.bas
'rem  ----------------------------
'rem sine wave
'rem -----------------------------
?
?"Sine wave graph"
?
?
?tab(14);"- 1";tab(40);"0";tab(63);"+ 1"
?"Degrees";tab(14);
for j = 1 to 52
    ?"-";
Next j
?
for L = 0 to 360 step 7.5
    let x =  L / 57.19578
    'rem what makes the curve
    let r = sin(x)
    let s = int((r*25) + .5)

          if s<0 then? L;tab(s+40);"*";tab(40);":" 

          if s=0 then ? L;tab(40);"*"
    
          if S>0 then? L;TAB(40);":";tab(s+40);"*"
Next L
end

Cosine graph:

$ cat cosine.bas

'rem  ----------------------------
'rem cosine wave
'rem -----------------------------
?
?"Cosine wave graph"
?
?
?tab(14);"- 1";tab(40);"0";tab(63);"+ 1"
?"Degress";tab(14);
for j = 1 to 52
    ?"-";
Next j
?
for L = 0 to 360 step 7.5
    let x =  L / 57.19578
    'rem what makes the curve
    let r = cos(x)
    let s = int((r*25) + .5)

          if s<0 then? L;tab(s+40);"*";tab(40);":" 

          if s=0 then ? L;tab(40);"*"
   
          if s>0 then? L;TAB(40);":";tab(s+40);"*"
Next L
end

Note: Freebasic was used to compile the code on a Linux based system.

--------------------------------------

Update: For those of you who prefer C,  we found some code for the sine and cosine.

Sine:

$ ./sine

sine.c   (gcc sine.c -lm -o sine)

 

#include <stdio.h>
#include <math.h>

#define WIDTH 60
#define HEIGHT 20
#define X WIDTH/2
#define Y HEIGHT/2
#define XMAX WIDTH-X-1
#define XMIN -(WIDTH-X)
#define YMAX HEIGHT-Y
#define YMIN -(HEIGHT-Y)+1

char grid[HEIGHT][WIDTH];

int plot(int x, int y);
void init_grid(void);
void show_grid(void);

int main()
{
    float x,y;

    init_grid();
    for(x=-3.14159;x<=3.14159;x+=0.1)
    {

// line to change (sin, cos, tan, or etc)

        y = sin(x);
        plot(rintf(x*10),rintf(y*8));
    }
    show_grid();

    return(0);
}

/* Set "pixel" at specific coordinates */
int plot(int x, int y)
{
    if( x > XMAX || x < XMIN || y > YMAX || y < YMIN )
        return(-1);

    grid[Y-y][X+x] = '*';
    return(1);
}

/* Initialize grid */
void init_grid(void)
{
    int x,y;

    for(y=0;y<HEIGHT;y++)
        for(x=0;x<WIDTH;x++)
            grid[y][x] = ' ';
    /* draw the axis */
    for(y=0;y<HEIGHT;y++)
        grid[y][X] = '|';
    for(x=0;x<WIDTH;x++)
        grid[Y][x] = '-';
    grid[Y][X] = '+';
}

/* display grid */
void show_grid(void)
{
    int x,y;

    for(y=0;y<HEIGHT;y++)
    {
        for(x=0;x<WIDTH;x++)
            putchar(grid[y][x]);
        putchar('\n');
    }
}

Cosine:

cosine.c   (gcc cosine.c -lm -o cosine)

 #include <stdio.h>
#include <math.h>

#define WIDTH 60
#define HEIGHT 20
#define X WIDTH/2
#define Y HEIGHT/2
#define XMAX WIDTH-X-1
#define XMIN -(WIDTH-X)
#define YMAX HEIGHT-Y
#define YMIN -(HEIGHT-Y)+1

char grid[HEIGHT][WIDTH];

int plot(int x, int y);
void init_grid(void);
void show_grid(void);

int main()
{
    float x,y;

    init_grid();
    for(x=-3.14159;x<=3.14159;x+=0.1)
    {

// line to change (sin, cos, tan, or etc)

        y = cos(x);
        plot(rintf(x*10),rintf(y*8));
    }
    show_grid();

    return(0);
}

/* Set "pixel" at specific coordinates */
int plot(int x, int y)
{
    if( x > XMAX || x < XMIN || y > YMAX || y < YMIN )
        return(-1);

    grid[Y-y][X+x] = '*';
    return(1);
}

/* Initialize grid */
void init_grid(void)
{
    int x,y;

    for(y=0;y<HEIGHT;y++)
        for(x=0;x<WIDTH;x++)
            grid[y][x] = ' ';
    /* draw the axis */
    for(y=0;y<HEIGHT;y++)
        grid[y][X] = '|';
    for(x=0;x<WIDTH;x++)
        grid[Y][x] = '-';
    grid[Y][X] = '+';
}

/* display grid */
void show_grid(void)
{
    int x,y;

    for(y=0;y<HEIGHT;y++)
    {
        for(x=0;x<WIDTH;x++)
            putchar(grid[y][x]);
        putchar('\n');
    }
}

------------------------------------------------------

The above graphic is nice but what is the date for a particular day. How about the day 214? Supposedly close to the hottest day of the year, then what actual day is that?

Usage: ./main dayofyear year

$ ./main 214 2014
Result: day 214 of year 2014 is '08/02/2014'.

To confirm it:

So it looks like August 2, is near the hottest day of the year.

$ gcc main.c -o main

main.c

 #define _XOPEN_SOURCE /* glibc2 needs this for strptime */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>  
#include <errno.h>

int to_date(
  char * date,
  const size_t size,
  const char * fmt,
  const short unsigned int day_of_year,
  const short unsigned int year)
{
  char buffer[16] = "";

  sprintf(buffer, "%hu %hu", day_of_year, year);

  {
    struct tm t = {0};
    char * presult = strptime(buffer, "%j %Y", &t);

    if ((NULL == presult) || ('\0' != *presult))
    {
      errno = EINVAL;
      return -1;
    }

    strftime(date, size, fmt, &t);
  }

  return 0;
}

int main(int argc, char ** argv)
{
  if (2 > argc)
  {
    fprintf(stderr, "Missing arguments. Usage: %s day-of-year year\n", argv[0]);
    return EXIT_FAILURE;
  }

  short unsigned int day_of_year = atoi(argv[1]);
  short unsigned int year = atoi(argv[2]);
  char date[16] = "";

  if (-1 == to_date(date, sizeof(date), "%m/%d/%Y", day_of_year, year))
  {
    perror("to_date() failed");
    return EXIT_FAILURE;
  }

  printf("Result: day %d of year %d is '%s'.\n", day_of_year, year, date);

  return EXIT_SUCCESS;
}

------------------------------------------------------

 

Light on is a one and light off is a zero.

There is an old joke that says: "There are only 10 types of people in the world: those who understand binary" In any case, it does not hurt to at least look at binary once in a while. Ascii (American standard code for information interchange) is usually eight binary characters of ones or zeroes. So you can take the first 8 ones and zeros for the first character.

Then to further split out the whole code sequence:

01000001 01010010 01010000 01000001 01001110 01000101 01010100

Then you can convert on character at a time.  You can just look at a table or write a program to do it.


</pre>
<pre><code class="language-js"><html>
<head>

<script type="text/javascript">
var input_id = "bin_text";
var answer_id = "answer";

function convertToASCII() {
 var bin_text = document.getElementById(input_id);
 var answer = document.getElementById(answer_id);

 if (!answer) {
  alert("Error: No element with id \""+answer_id+"\".");
  return;
 }
 if (bin_text)
  var text = bin_text.value;
 else {
  error("No element with id \""+input_id+"\".");
  return;
 }
 var divisible = text.length % 8;
 var nonBinary = /[^0|1]/.test(text);
 if (text.length > 0 && divisible == 0 && !nonBinary) {
  var regex = /[0|1]{8}/g;
  var str = text.match(regex);
  var code = 0;
  var placeVal, exp, digit;
  var ascii = '';
  while (str.length > 0) {
   code = 0;
   for (var i=0; i<str[0].length; i++) {
    placeVal = 7-i;
    exp = Math.pow(2, i);
    digit = str[0].charAt(placeVal);
    code += exp*digit;
   }
   str.shift();
   ascii += String.fromCharCode(code);
  }
  answer.innerHTML = "<p class=\"binary\">" + ascii + "</p>";
 }
 else {
  error("Malformed binary.");
  return;
 }

 function error(errText) {
  answer.innerHTML = "<span class=\"error\">Error: " + errText + "</span>";
 }
}
</script>

<style type="text/css">
.block {
 width: 45%;
 border: 1px solid #000000;
 padding: 10px;
}
.binary {
 background-color: #C6FFC7;
 padding: 3px;
}
.error {
 background-color: #FFC6C6;
 padding: 3px;
}
</style>

</head>
<body>

<div style="float:left;" class="block">
 <form onSubmit="convertToASCII(); return false;">
  <p>Enter some binary to decode:</p>

  <input type="text" id="bin_text"/>
 </form>
</div>

<div style="float:right;" class="block">
 <p id="answer"><br/></p>
</div>

</body>
</html></code></pre>
<pre>

------------------------------------------------------

Macaroni maker?

maacaronipress

Good day.

Feetball time.

Leave a comment

Chit chat

———-

Went through the old closet and found a few legacy parts or two.

Was able to use a couple of posts from chat sites as the basis for an article or two.

—————————————————
Play the lottery? Here is a simple random number generator to pontificate the numbers. Run it as many times as there are picks.

lg.sh:

echo Lottery generator
echo
echo -n "Enter number of balls: "
read nodf
echo -n "Enter number of choices: "
read b
declare -i X=$b
for i in $(seq 1 1 $nodf)
do
NUM=$[ ( $RANDOM % $X ) + 1 ];
echo "The winner is for ball number $i:" $NUM
done

Enter number of balls: 5
Enter number of choices: 50
The winner is for ball number 1: 32
The winner is for ball number 2: 43
The winner is for ball number 3: 23
The winner is for ball number 4: 18
The winner is for ball number 5: 38

Don’t forget to “chmod +x” it. Great for choosing winners randomly in a contest. Write the number down after each toss. I will let you mod the code to save the numbers.

Note: it does not check for duplicates.

Another way to do it.

usage ./rndom choicesperball numberofballs

$ ./rndom.sh 50 5

Choices per ball are 50 and the number of balls is 5

Ball number 1 is 35
Ball number 2 is 31
Ball number 3 is 6
Ball number 4 is 42
Ball number 5 is 3

$ cat rndom.sh

#!/bin/bash
clear
echo “Choices per ball are $1 and the number of balls is $2″
echo
for (( c=1; c<=$2; c++ ))
do
echo “Ball number $c is $[($RANDOM % $1)]“
done

Note: this is a good way to give out prizes at a meeting. Just make sure everyone has their own number.

One last variation:

$ shuf -i 1-49 -n18 | xargs -n6
41 34 28 4 36 45
7 2 31 25 38 14
44 32 6 17 11 46
$ shuf -i 1-49 -n24 | xargs -n6
41 13 10 45 29 30
47 43 33 9 32 34
18 36 14 44 48 8
38 31 26 6 35 39

$ shuf -i 1-49 -n28 | xargs -n7
34 10 5 45 43 35 2
42 18 7 22 30 47 23
13 6 19 49 48 4 11
24 8 20 29 31 17 27

—————————————————

Not really what I had in mind…

Had to stay at my brother’s house during a recent summer while the AC was being replaced. While there, he was kind enough to let me access his wifi. It was real easy. You just log in and your on-line. The neat part of it was you are blocked out of using the local area network. He uses a wireless router from that company in Cupertino, California. I wanted to have the same thing but did not want to spend one hundred plus dollars on a new router like he did.

Recently I purchased a used Cisco Linksys wrt-54g from the local Goodwill store specializing in computer stuff real cheap. Knew that you could upgrade the firmware with dd-wrt, openwrt, and a host of others. In fact, I think I had installed dd-wrt. Wanted more like what my brother has. After doing some research, I found some firmware. Known as CoovaAP, it is known is what is called a Wisp (wifi inTERnet service provider. Well I wanted it for our intranet (local area full service network without internet access).

We have sort of our own mini cloud (web, media and etc.) servers. So it still is a Wisp (Wireless inTRAnet service provider. You can also set this software for a stand alone machine acting as a wireless access point.

Installed CoovaAP on the router and now it can be accessed within the range of the router. This is a great set up say for a school, church, or in a small town. More information at: http://www.coova.org/CoovaAP
and http://www.howtoforge.com/wireless_hotspot_howto
http://www.howtoforge.com/wireless_hotspot_howto 

—————————————————
When considering getting an old computer, one of the biggest telltale features to consider before acquiring the system (unless you get it for free) are the capacitors. Avoid the system if it has bad capacitors.

Learning how to de-solder and solder can be helpful. Why throw away a good motherboard if you can fix it without too much trouble.Hopefully that is what I can do with this motherboard.

A while back lots of brand name computers had bad capacitors.  People were getting the monitors and computers for scrap. Once the caps were replaced, the equipment was sold for full resale price.

 

—————————————————

If you are into arduino type stuff, this may interest you.
Avrian Jump

===========

A very simple ladder language for programming ATMega168s from a web browser.

This started out as a desire to be able to program an [Arduino][] from an iOS device.  Since it doesn’t seem like compiler tools of any sort would get into the app store, I figured something would need to be done in HTML5.  And if a [PC emulator][pcemu] could be written in javascript, so could something like this.

However, recreating the Arduino IDE in HTML seemed like too much work, at least for a first try.  So I reduced the project into something much simpler, while still putting real machine code into the AVR’s flash.  A simple ladder language that compiled into AVR assembly, which would be assembled into machine code, seemed like like a resonable reduction.  With that I could take advantage of the [Audioino][] bootloader, to load right from the web page.

This is still unfinished, go see the TODO file.

Also go read issue #2, playing sounds encoded in data URIs in iOS 5.1 is broken. *sigh*

Try it out! [Avrian Jump](http://tadpol.github.com/Avrian-Jump/avrianjump.html)

Some other ways (likely better) of putting Arduino IDEs into web browsers:
– [wifino](http://www.wifino.com/)
-

[codebender](http://codebender.cc/)

The Ladder
———-

Each rung on the ladder has a single test and multiple actions.  Tests can check the digital pins, analog pins, and a couple of variables.  Each action can set a digital pin, a PWM output, or a variable.  Analog, PWM, and variables are 16bit values.

There is no ‘setup()’.  Analog pins are always analog inputs.  When specified in a test, a digital pin is set to an input then read.  When specified in an action, it is set to an output then set.

PWM code is still non-existant, so how this will actually work is up in the air.  How I want it to work is:  Specifying a pin in an action as a PWM output makes it a PWM output.  Specifying a pin in a test stops it from doing PWM output.  Specifying a digital state for the pin in an action also stops it from doing PWM output.

There is an ascii format of the ladders.  This was done because it seemed like it could be neat to be able to tweet ladders.  You can view the ascii format, and also load ladders from it.  The ascii parser skips anything it doesn’t recognise; it is a bit too forgiving at times.

An example program:

#Fast Blink LED
:T;A+=1
:A=16383;D13=1
:A=32767;D13=0,A=0

Mostly though, a ladder is converted into AVR assembly.

The Assembler
————-

The assembler is pretty basic. Lots of features commonly found in other assemblers are currently missing.  It does assemble the mneonics from [Atmel's pdf][avrasm] into machine code.  It supports labels, but not local labels.  It has simple parameter replacement, so common names can be defined for IO registers and memory regions and things.  It can also specify where in memory to put the machine code, and can specify immeadiate words to save in the machine code.

This assembler doesn’t know about the various AVR devices, and so will happily assemble any of the known mnemonics into the output.  Even if your target device has no idea what to do with them.  It has assembled blink tests for the ATmega168 and the ATTiny13, so it seems pretty flexable. (Avrian Jump currently only supports the ATmega168 though.  Maybe add others in the future, but would have to figure the bootloader thing out first.)

Outputs
——-

A ladder can be compiled into a few different formats:

- ASCII
– This the only form can can be converted back into a ladder.
– This is for sharing your ladder with others, or saving a ladder for later.
– S19
– If you don’t have an [Audioino][] bootloader, but still want to use a ladder.  A S19 can be ded with [avrdude][].
– WAV
– A [Audioino][] compatible wav file for loading the ladder onto an ATmega168 with the [Audioino][] bootloader installed.
– Assembler
– This is mostly around for debugging the ladder compiler.  It can be interesting to look at  too.

License
——-

Copyright (c) 2012 Michael Conrad Tadpol Tilstra

Licensed under the MIT License.

[Arduino]:http://www.arduino.cc/
[pcemu]:http://bellard.org/jslinux/
[avrasm]:http://www.atmel.com/atmel/acrobat/doc0856.pdf
[avrdude]:http://ladyada.net/learn/avr/avrdude.html
[Audioino]:http://www.hobby-roboter.de/forum/viewtopic.php?f=4&t=128&p=531

————————————
Football time again. Here is a quick script to get some nfl scores. You will have to read the script to set the values for what part of the season and what week to show. I did not put a lot of time into formatting as it is easy for me to read as is.  The script might be use for other sports depending on the format.

------------------------------------------------
nfl data for phase = 1 week = 3 season = 2014
------------------------------------------------

       Home           Score              Away

Thursday, August 14 - (Preseason)
Jacksonville 19 - 20 Chicago Final
Friday, August 15 - (Preseason)
Philadelphia 35 - 42 New England Final
Tennessee 24 - 31 New Orleans Final
Detroit 26 - 27 Oakland Final
San Diego 14 - 41 Seattle Final
Saturday, August 16 - (Preseason)
Green Bay 21 - 7 St. Louis Final
NY Jets 25 - 17 Cincinnati Final
Baltimore 37 - 30 Dallas Final
NY Giants 27 - 26 Indianapolis Final
Buffalo 16 - 19 Pittsburgh Final
Miami 20 - 14 Tampa Bay Final
Atlanta 7 - 32 Houston Final
Arizona 28 - 30 Minnesota Final
Sunday, August 17 - (Preseason)
Denver 34 - 0 San Francisco Final
Kansas City 16 - 28 Carolina Final
Monday, August 18 - (Preseason)
Cleveland 23 - 24 Washington Final

Standings

* AFC
* NFC

East

East
Team W L T Pct
NY Jets 2 0 0 1.000
Miami 1 1 0 .500
New England 1 1 0 .500
Buffalo 1 2 0 .333


North

North
Team W L T Pct
Baltimore 2 0 0 1.000
Pittsburgh 1 1 0 .500
Cincinnati 0 2 0 .000
Cleveland 0 2 0 .000


South

South
Team W L T Pct
Houston 1 1 0 .500
Jacksonville 1 1 0 .500
Tennessee 1 1 0 .500
Indianapolis 0 2 0 .000


West

West
Team W L T Pct
Denver 2 0 0 1.000
Kansas City 1 1 0 .500
Oakland 1 1 0 .500
San Diego 1 1 0 .500


East

East
Team W L T Pct
NY Giants 3 0 0 1.000
Washington 2 0 0 1.000
Dallas 0 2 0 .000
Philadelphia 0 2 0 .000


North

North
Team W L T Pct
Chicago 2 0 0 1.000
Minnesota 2 0 0 1.000
Detroit 1 1 0 .500
Green Bay 1 1 0 .500


South

South
Team W L T Pct
New Orleans 2 0 0 1.000
Atlanta 1 1 0 .500
Carolina 1 1 0 .500
Tampa Bay 0 2 0 .000


West

West
Team W L T Pct
Arizona 1 1 0 .500
Seattle 1 1 0 .500
San Francisco 0 2 0 .000
St. Louis 0 2 0 .000


Full Standings

---------------------------------------------



 ####################################
# Score  Grabber
#
#===============================
# Assignments
# --------------------------------
datafile="nflscorefile"
a=1
flag=0
week=3
# phase 1 is preseason phase 2 is regular season #phase 3 is
phase=1
season=2014
#finished week = 1 unfinished week = 0
weekfinished=1
league="nfl"
# end assignments
#=================================
#
# Get data file
#---------------------------------
case $weekfinished in
1)
elinks "http://sports.yahoo.com/$league/scoreboard/?week=$week&phase=$phase&season=$season"  > $datafile
;;
0)
elinks "http://sports.yahoo.com/$league/scoreboard/"  > $datafile
;;
*)
#
;;
esac
#=================================
#
# Extract and display data
#---------------------------------
while read line
do fdata[$a]=$line
echo $line | grep -q "Home Score Away"
if  [ $? -eq 0 ]; then
# header
clear
echo
echo ------------------------------------------------
echo  $league  data for phase = $phase  week = $week  season = $season
echo ------------------------------------------------
echo
echo "       Home           Score              Away"
echo ""
let "flag = 1"
fi
if [ $flag -eq 1 ]; then
echo $line | grep -q "Latest NFL Videos"
if [ $? -eq 0 ]; then
let "flag = 0"
else
echo $line | grep -q "Home Score Away"
if  [ $? -ne 0 ]; then
case $weekfinished in
1)
echo $line | sed 's/\[.*\]//'
;;
0)
echo $line
;;
*)
#
;;
esac
fi
fi
fi
let "a += 1"
done < $datafile
# footer
echo ---------------------------------------------
echo
#===============================
# End.
################################

---------------------------------------------------

You could always go to the brand name software, but it does not always fit especially on embedded devices. Linux and BSD are more diversified.

http://www.instructables.com/id/Give-your-Cisco-Linksys-NSLU2-some-muscle-part-1/

--------------------------------------------------

Graphic is nice but what is the date for a particular day. How about the day 214? Supposedly close to the hottest day of the year, then what actual day is that?

Useage: ./main dayofyear year

$ ./main 214 2014
Result: day 214 of year 2014 is '08/02/2014'.

To confirm it:

Screenshot - 08232014 - 08:11:48 PM

So it looks like August 2, is near the hotest day of the year.

$ gcc main.c -o main

main.c

 #define _XOPEN_SOURCE /* glibc2 needs this for strptime */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>  
#include <errno.h>

int to_date(
  char * date,
  const size_t size,
  const char * fmt,
  const short unsigned int day_of_year,
  const short unsigned int year)
{
  char buffer[16] = "";

  sprintf(buffer, "%hu %hu", day_of_year, year);

  {
    struct tm t = {0};
    char * presult = strptime(buffer, "%j %Y", &t);

    if ((NULL == presult) || ('\0' != *presult))
    {
      errno = EINVAL;
      return -1;
    }

    strftime(date, size, fmt, &t);
  }

  return 0;
}

int main(int argc, char ** argv)
{
  if (2 > argc)
  {
    fprintf(stderr, "Missing arguments. Usage: %s day-of-year year\n", argv[0]);
    return EXIT_FAILURE;
  }

  short unsigned int day_of_year = atoi(argv[1]);
  short unsigned int year = atoi(argv[2]);
  char date[16] = "";

  if (-1 == to_date(date, sizeof(date), "%m/%d/%Y", day_of_year, year))
  {
    perror("to_date() failed");
    return EXIT_FAILURE;
  }

  printf("Result: day %d of year %d is '%s'.\n", day_of_year, year, date);

  return EXIT_SUCCESS;
}

---------------------------------------------------

Arpanet

Ascii is usally eight binary characters of ones or zeroes. So you can take the first 8 ones and zeros for the first character.

Then to further split out the whole code sequence:

01000001 01010010 01010000 01000001 01001110 01000101 01010100

Then you can convert on character at a time.  You can just look at a table or write a program to do it.

 


</pre>
<pre><code class="language-js"><html>
<head>

<script type="text/javascript">
var input_id = "bin_text";
var answer_id = "answer";

function convertToASCII() {
 var bin_text = document.getElementById(input_id);
 var answer = document.getElementById(answer_id);

 if (!answer) {
  alert("Error: No element with id \""+answer_id+"\".");
  return;
 }
 if (bin_text)
  var text = bin_text.value;
 else {
  error("No element with id \""+input_id+"\".");
  return;
 }
 var divisible = text.length % 8;
 var nonBinary = /[^0|1]/.test(text);
 if (text.length > 0 && divisible == 0 && !nonBinary) {
  var regex = /[0|1]{8}/g;
  var str = text.match(regex);
  var code = 0;
  var placeVal, exp, digit;
  var ascii = '';
  while (str.length > 0) {
   code = 0;
   for (var i=0; i<str[0].length; i++) {
    placeVal = 7-i;
    exp = Math.pow(2, i);
    digit = str[0].charAt(placeVal);
    code += exp*digit;
   }
   str.shift();
   ascii += String.fromCharCode(code);
  }
  answer.innerHTML = "<p class=\"binary\">" + ascii + "</p>";
 }
 else {
  error("Malformed binary.");
  return;
 }

 function error(errText) {
  answer.innerHTML = "<span class=\"error\">Error: " + errText + "</span>";
 }
}
</script>

<style type="text/css">
.block {
 width: 45%;
 border: 1px solid #000000;
 padding: 10px;
}
.binary {
 background-color: #C6FFC7;
 padding: 3px;
}
.error {
 background-color: #FFC6C6;
 padding: 3px;
}
</style>

</head>
<body>

<div style="float:left;" class="block">
 <form onSubmit="convertToASCII(); return false;">
  <p>Enter some binary to decode:</p>

  <input type="text" id="bin_text"/>
 </form>
</div>

<div style="float:right;" class="block">
 <p id="answer"><br/></p>
</div>

</body>
</html></code></pre>
<pre>

---------------------------------------------------

Sometimes simple just works. Rice boiled in liquid from poaching chicken breasts,

green peas, and sauteed ground turkey.

SUNP0030

Good day,

One more day.

Leave a comment

Chit chat

———-

Schools want to reduce math and science classes for alleged lack of interest. I think it is an instructor issue instead.

Working on some stuff for an or two.

If you think the command line is too hard, then try these.

What do you really own?
Using the Arduino and ethernet for a web interface to control audio inputs and outputs via 4066 ic’s.
Have a little fun with your home web server. Imagine you are a fancy restaurant.

 

—————————————————

Use the Arduino + ethernet when your server is down for a temporary site to let your users know what is going on.pertinent code:

client.println(“<center>”);client.println(“<h1>Your server name<h1>”);
client.println(“<hr”);
client.println(“<br />”);client.println(“<h2>Bear with us as the server is under reconstruction!</h2>”);
client.println(“<img src=’http://www.seemyheart.org/wp-content/uploads/2013/06/Website_Under_Construction.gif‘ height=500 width=500 />”);
client.println(“</center>”);

—————————————————

Just had to try this.

SUNP0027

We have a boat load of negatives that should be in picture files.

The form: (not actual size).

—————————————————

Just a simple batch file to collect information about your computer.  A bit dated and there are probably some commands that should have been included, but a good list of commands you can use to find out about your linux box. You have to install some of the commands for them to work. You do not have to use all the commands like I did, but it will be interesting to see what is in the file generated. Great for documentation about the system. Good list to have for insurance purposes.

usage: sudo ./hwinfo2file.sh filename

$ sudo ./hwinfo2file.sh My_desktop_computer_info

hwinfo2file.sh

echo "================================="
cat /etc/hostname
echo "getting stats"
file=$1.txt
# file="system.txt"
echo " " &gt; $file
echo "=====================================" &gt;&gt; $file
echo&nbsp; get computername &gt;&gt; $file
cat /etc/hostname &gt;&gt; $file
echo "=====================================" &gt;&gt; $file
echo&nbsp; get current ip connections &gt;&gt; $file
sudo ifconfig &gt;&gt; $file
echo "-------------------------------------" &gt;&gt; $file
echo&nbsp; get linux version &gt;&gt; $file
lsb_release -a &gt;&gt; $file
echo "-------------------------------------" &gt;&gt; $file
echo&nbsp; get memory specs &gt;&gt; $file
free &gt;&gt; $file
echo "-------------------------------------" &gt;&gt; $file
echo&nbsp; get file storage statistics &gt;&gt; $file
df -h &gt;&gt; $file
echo "-------------------------------------" &gt;&gt; $file
echo&nbsp; get mounted file system list &gt;&gt; $file
cat /etc/fstab &gt;&gt; $file
echo "-------------------------------------" &gt;&gt; $file
echo&nbsp; get pci specs &gt;&gt; $file
sudo lspci &gt;&gt; $file
echo "-------------------------------------" &gt;&gt; $file
echo&nbsp; get loaded modules &gt;&gt; $file
sudo lsmod &gt;&gt; $file
echo "-------------------------------------" &gt;&gt; $file
echo&nbsp; get current usb attachments. &gt;&gt; $file
sudo lsusb &gt;&gt; $file
echo "-------------------------------------" &gt;&gt; $file
echo get repos &gt;&gt; $file
cat /etc/apt/sources.list &gt;&gt; $file
# echo "-------------------------------------" &gt;&gt; $file
# echo&nbsp; get installed software &gt;&gt; $file
# sudo dpkg --get-selections &gt;&gt; $file
# echo "-------------------------------------" &gt;&gt; $file
# echo&nbsp; get hardware info &gt;&gt; $file
# sudo lshw &gt;&gt; $file
# echo "-------------------------------------" &gt;&gt; $file
# echo&nbsp; get scsi devices &gt;&gt; $file
# sudo lsscsi &gt;&gt; $file
echo "-------------------------------------" &gt;&gt; $file
echo&nbsp; display /etc/issue &gt;&gt; $file
cat /etc/issue &gt;&gt; $file
# echo "-------------------------------------" &gt;&gt; $file
# echo&nbsp; get boot up info &gt;&gt; $file
# dmesg &gt;&gt; $file
echo "-------------------------------------" &gt;&gt; $file
echo&nbsp; get users &gt;&gt; $file
cat /etc/passwd &gt;&gt; $file
echo "-------------------------------------" &gt;&gt; $file
echo&nbsp; get current users on system &gt;&gt; $file
who &gt;&gt; $file
# echo "-------------------------------------" &gt;&gt; $file
# echo&nbsp; get system messages &gt;&gt; $file
# cat /var/log/messages &gt;&gt; $file
# echo "-------------------------------------" &gt;&gt; $file
# echo&nbsp; get rootkit checker log &gt;&gt; $file
# cat /var/log/rkhunter.log &gt;&gt; $file
# echo "-------------------------------------" &gt;&gt; $file
# echo&nbsp; get syslog &gt;&gt; $file
# cat /var/log/syslog &gt;&gt; $file
echo "-------------------------------------" &gt;&gt; $file
echo&nbsp; get scheduled events &gt;&gt; $file
cat /etc/anacrontab &gt;&gt; $file
cat /etc/crontab &gt;&gt; $file

—————————————————

To install Statusnet, you need to go download the latest version. Once completing that, you can transfer the file to the server. (of course, you can download the file direct to the server.) We do everything from the command line to the server when we can.

$ scp statusnet-1.1.1.tar.gz  oeorgan1:~/.

statusnet-1.1.1.tar.gz                        100% 8869KB   4.3MB/s   00:02
$

Now to go to the server to do the install.

eddie@oelt02:~$ ssh oeorgan1

Welcome to Ubuntu 12.04.5 LTS (GNU/Linux 3.2.0-41-generic i686)

* Documentation:  https://help.ubuntu.com/

New release ‘14.04.1 LTS’ available.
Run ‘do-release-upgrade’ to upgrade to it.

Last login: Sat Aug 16 10:34:43 2014 from oelt02.local
$

Is it there?

$ ls statusnet-1.1.1.tar.gz
statusnet-1.1.1.tar.gz
$

Make a directory to work in .

$ makedir statusnet
$ cd statusnet

Expand the archive

/statusnet$  tar zxvf ~/statusnet-1.1.1.tar.gz



statusnet-1.1.1/theme/neo/images/lightbox_bg.png
statusnet-1.1.1/theme/neo/images/lock.png
statusnet-1.1.1/theme/neo/images/lock_open.png
statusnet-1.1.1/theme/neo/images/magnifier.png
statusnet-1.1.1/theme/neo/images/resultset_next.png
statusnet-1.1.1/theme/neo/images/rosette.png
statusnet-1.1.1/theme/neo/images/tick.png
statusnet-1.1.1/theme/neo/logo.png
statusnet-1.1.1/theme/neo/mobilelogo.png
statusnet-1.1.1/theme/neo/theme.ini

/statusnet$statusnet$
/statusnet$ cd statusnet-1.1.1/
/statusnet/statusnet-1.1.1$ ls
actions               doc-src          install.php            plugins
apple-touch-icon.png  EVENTS.txt       js                     PLUGINS.txt
avatar                extlib           lib                    README
background            favicon.ico      lighttpd.conf.example  scripts
classes               file             local                  tests
CONFIGURE             htaccess.sample  locale                 theme
COPYING               index.php        mail-src               UPGRADE
db                    INSTALL          Makefile

Get the instructions to follow

/statusnet/statusnet-1.1.1$ Vim README

Move the extracted directory to the web directory area.

$ sudo mv statusnet-1.1.1/ /var/www/sn
$ sudo apt-get install php5-curl
$ sudo service apache2 restart

Set ownership

chgrp www-data /var/www/sn/
or
$ sudo chown -R www-data:www-data sn

Set file permissions

$ sudo chmod a+w /var/www/sn/

$ sudo  chmod a+w /var/www/statusnet/avatar
$ sudo  chmod a+w /var/www/statusnet/background
$ sudo  chmod a+w /var/www/statusnet/file
or
$ sudo chmod -R 755 sn

Via command line set up mysql
Create a database to hold your microblog data. Something like this
should work:

mysqladmin -u “username” –password=”password” create statusnet

Note that StatusNet must have its own database; you can’t share the
database with another program. You can name it whatever you want,
though.

(If you don’t have shell access to your server, you may need to use
a tool like PHPAdmin to create a database. Check your hosting
service’s documentation for how to create a new MySQL database.)

Create a new database account that StatusNet will use to access the
database. If you have shell access, this will probably work from the
MySQL shell:

GRANT ALL on statusnet.*
TO ‘statusnetuser’@’localhost’
IDENTIFIED BY ‘statusnetpassword';or use phpmyadmin

or use phpmyadmin (requires superuser power)

Be sure to reload privileges before exiting.

Go to the web site and then install setup

Follow instructions:

Log in as an admin and setup the site. Would not hurt to set up a pointer on the menu to the site from your main page.

Have fun!

—————————————————

Sheldon’s favorite: pasta and weenies.

SUNP0020 SUNP0022

Good day.

The Computothoughts.

Leave a comment

Computothought

 

computothought

and introducing Miss Computothought Jr.

Screenshot - 08112014 - 03:46:55 AM

 

They are asking too much.

Leave a comment

Chit chat

———-

Still like to use lpq to check on print queues.

You feel foolish when you have installed applications on a #web server a zillion times, but you make simple mistakes like typing in a url of phpmysql when it should of been phpmyadmin. Been a while, but the app is installed.
#linux
Oldie, but goodie…. #internet   #linux   #mswindows #computers

——————————————————–

Source code for the file permissions application shown a while back.

<html>
<body>

<script type="text/javascript">
<!--
/* chmod helper, Version 1.0
 * by DK of able-design
* Last Modified: recently
*/

function do_chmod(user) {
 var field4 = user + "4";
 var field2 = user + "2";
 var field1 = user + "1";
 var total = "t_" + user;
 var symbolic = "sym_" + user;
 var number = 0;
 var sym_string = "";

 if (document.chmod[field4].checked == true) { number += 4; }
 if (document.chmod[field2].checked == true) { number += 2; }
 if (document.chmod[field1].checked == true) { number += 1; }

 if (document.chmod[field4].checked == true) {
  sym_string += "r";
 } else {
  sym_string += "-";
 }
 if (document.chmod[field2].checked == true) {
  sym_string += "w";
 } else {
  sym_string += "-";
 }
 if (document.chmod[field1].checked == true) {
  sym_string += "x";
 } else {
  sym_string += "-";
 }

 if (number == 0) { number = ""; }
 document.chmod[total].value = number;
 document.chmod[symbolic].value = sym_string;

 document.chmod.t_total.value = document.chmod.t_owner.value + document.chmod.t_group.value + document.chmod.t_other.value;
 document.chmod.sym_total.value = "-" + document.chmod.sym_owner.value + document.chmod.sym_group.value + document.chmod.sym_other.value;
}
//-->
</script>


<form name="chmod" action="">
<table cellpadding="0" cellspacing="0" summary="Chmod calculator"><tr><td width="100%" valign="top"><table width="100%" cellpadding="5" cellspacing="2" border="0" summary=""><tr><td width="100%" bgcolor="#8e97b4" align="center" colspan="5"><font color="#ffffff" size="3"><b>chmod (File Permissions) helper</b></font></td></tr>
 <tr bgcolor="#bcbcbc">
  <td align="left"><b>Permission</b></td>
  <td align="center"><b>Owner</b></td>
  <td align="center"><b>Group</b></td>

  <td align="center"><b>Other</b></td>
  <td bgcolor="#dddddd" rowspan="4"> </td>
 </tr><tr bgcolor="#dddddd">
  <td align="left" nowrap><b>Read</b> (r = 4)</td>
  <td align="center" bgcolor="#ffffff"><input type="checkbox" name="owner4" value="4" onclick="do_chmod('owner')"></td>
  <td align="center" bgcolor="#ffffff"><input type="checkbox" name="group4" value="4" onclick="do_chmod('group')"></td>

  <td align="center" bgcolor="#ffffff"><input type="checkbox" name="other4" value="4" onclick="do_chmod('other')"></td>
 </tr><tr bgcolor="#dddddd">
  <td align="left" nowrap><b>Write</b> (w=2)</td>
  <td align="center" bgcolor="#ffffff"><input type="checkbox" name="owner2" value="2" onclick="do_chmod('owner')"></td>
  <td align="center" bgcolor="#ffffff"><input type="checkbox" name="group2" value="2" onclick="do_chmod('group')"></td>
  <td align="center" bgcolor="#ffffff"><input type="checkbox" name="other2" value="2" onclick="do_chmod('other')"></td>
 </tr><tr bgcolor="#dddddd">

  <td align="left" nowrap><b>Execute</b> (x=1)</td>
  <td align="center" bgcolor="#ffffff"><input type="checkbox" name="owner1" value="1" onclick="do_chmod('owner')"></td>
  <td align="center" bgcolor="#ffffff"><input type="checkbox" name="group1" value="1" onclick="do_chmod('group')"></td>
  <td align="center" bgcolor="#ffffff"><input type="checkbox" name="other1" value="1" onclick="do_chmod('other')"></td>
 </tr><tr bgcolor="#dddddd">
  <td align="right" nowrap>Octal:</td>
  <td align="center"><input type="text" name="t_owner" value="" size="1"></td>

  <td align="center"><input type="text" name="t_group" value="" size="1"></td>
  <td align="center"><input type="text" name="t_other" value="" size="1"></td>
  <td align="left"><b>=</b> <input type="text" name="t_total" value="" size="3"></td>
 </tr><tr bgcolor="#dddddd">
  <td align="right" nowrap>Symbolic:</td>
  <td align="center"><input type="text" name="sym_owner" value="" size="3"></td>
  <td align="center"><input type="text" name="sym_group" value="" size="3"></td>

  <td align="center"><input type="text" name="sym_other" value="" size="3"></td>
  <td align="left"><b>=</b> <input type="text" name="sym_total" value="" size="10"></td>
 </tr>
</table></td></tr></table>
</form>
</body>
</html>

——————————————————–

Tried to use the famous Kipkay’s method for a sort of megaphone for the pad. Not stable enough. Used tees instead of right angles. Also sealed off the back side of the tees to concentrate sound.

——————————————————–

One of the things I like about a home web server is the ability enhance the capabilities of a touchpad. You can use the server to do all the heavy lifting. In this case cookdojo recipe program is running from the server (where all the data is kept), but allows the touchpad as an interface or thin client. You can easily move the touchpad to another location for some other web based application such as home automation or even a game.

——————————————————–

While back I did an article about doing parabolas. Here is a web page that can help in printing parabola sections.

 

SUNP0008

 

SUNP0010

The code: (use at your own risk)

<!DOCTYPE html>
<html>
<head>
<title>                  Parabola Segments    </title>
<script>
function                 drawPicture(form)
{ var canvas =           document.getElementById('example'); // link to id='example'
  var context =          canvas.getContext('2d');               // create graphic context
  var scale =            350;
  var gain =             1;
  var radius =           1;
  var focal =            form.foc.value; 
  var step =             0.1;
  var Num_seg =          24;
  var a =                1/(4*focal);
  var x0 =               scale*.6;
  var y0 =               scale*2;
  
  var x ,y, dx ,dy,ds,angle,x_g,y_g;
  var s     =              0;
  var x_last=              0;
  var y_last=              0;
  
  
  var X_calc =           new Array(11);
  var Y_calc =           new Array(11);
  var S_calc =           new Array(11);
  

  for                    (i=0; i<=10; i++)                               //Calc Parabola data
{ x =                    step*i;
  y =                    a*x*x;
  dx =                   x-x_last;
  dy =                   y-y_last;
  ds =                   Math.pow(dx*dx+dy*dy,.5);
  s =                    s + ds;
  X_calc[i] =            x;                                              //X_data
  Y_calc[i] =            y;                                              //Y_data
  S_calc[i] =            s;                                              //Surface_data
  angle =                (x/s)*2*Math.PI/Num_seg;
  x_last=                x;
  y_last=                y;
}

  gain =                 1.99/S_calc[10];
  
  context.clearRect(     0,0,scale*2,scale*2);                            //ÊclearÊcanvasÊ
  context.strokeStyle =  "Black"; 
  
  context.beginPath();  
  context.fillStyle =   "rgb( 255, 255, 255)";                         // red, grn, blu
  context.fillRect (     0, 0, scale*2, scale*2);                      // or draw white box
  context.fill();
  
  if                    (form.s1[0].checked)                          //Draw segements?
{ context.moveTo(        x0,   y0);                                   // move to origin 
  for                    (i=0; i<=10; i++)
{ angle =                (X_calc[i]/S_calc[i])*2*Math.PI/Num_seg;
  x_g =                  gain*scale*S_calc[i]*Math.sin(angle);
  y_g =                  -gain*scale*S_calc[i]*Math.cos(angle);
  context.lineTo(        x_g + x0,  y_g + y0 );
} context.stroke();
  context.strokeStyle =  "Black"; 
  context.moveTo(        x0,   y0);                                     // move to origin 
  for                    (i=0; i<=10; i++)
{ angle =                (X_calc[i]/S_calc[i])*2*Math.PI/Num_seg;
  x_g =                  -gain*scale*S_calc[i]*Math.sin(angle);
  y_g =                  -gain*scale*S_calc[i]*Math.cos(angle);
  context.lineTo(        x_g + x0,  y_g + y0 );
} context.stroke();
  //context.strokeStyle =  "Black"; 
  for                    (j=1; j<=10; j++)
{ angle =                (X_calc[j]/S_calc[j])*2*Math.PI/Num_seg;
  y_g =                  -gain*scale*S_calc[j];
  context.moveTo(        x0,  y_g + y0);                                // move to origin 
  for                    (i=0; i<=10; i++)
{ x_g =                   gain*scale*S_calc[j]*Math.sin(angle*i/10);
  y_g =                  -gain*scale*S_calc[j]*Math.cos(angle*i/10);
  context.lineTo(        x_g + x0,  y_g + y0);                                // move to origin 
} context.stroke();
  y_g =                  -gain*scale*S_calc[j];
  context.moveTo(        x0,  y_g + y0);                                  // move to origin 
  for                    (i=0; i<=10; i++)
{ x_g =                  -gain*scale*S_calc[j]*Math.sin(angle*i/10);
  y_g =                  -gain*scale*S_calc[j]*Math.cos(angle*i/10);
  context.lineTo(        x_g + x0,  y_g + y0);                           // move to origin 
} context.stroke();
}

  x0 =                   scale*1.4;                                      // draw second segment                            
  y0 =                   0;
  context.moveTo(        x0,   y0);                                     // move to origin 
  for                    (i=0; i<=10; i++)
{ angle =                (X_calc[i]/S_calc[i])*2*Math.PI/Num_seg;
  x_g =                  gain*scale*S_calc[i]*Math.sin(angle);
  y_g =                  gain*scale*S_calc[i]*Math.cos(angle);
  context.lineTo(        x_g + x0,  y_g + y0 );
} context.stroke();
  context.moveTo(        x0,   y0);                                    // move to origin 
  for                    (i=0; i<=10; i++)
{ angle =                (X_calc[i]/S_calc[i])*2*Math.PI/Num_seg;
  x_g =                  -gain*scale*S_calc[i]*Math.sin(angle);
  y_g =                  gain*scale*S_calc[i]*Math.cos(angle);
  context.lineTo(        x_g + x0,  y_g + y0 );
} context.stroke();
  for                    (j=1; j<=10; j++)
{ angle =                (X_calc[j]/S_calc[j])*2*Math.PI/Num_seg;
  y_g =                  gain*scale*S_calc[j];
  context.moveTo(        x0,  y_g + y0);                                // move to origin 
  for                    (i=0; i<=10; i++)
{ x_g =                   gain*scale*S_calc[j]*Math.sin(angle*i/10);
  y_g =                  gain*scale*S_calc[j]*Math.cos(angle*i/10);
  context.lineTo(        x_g + x0,  y_g + y0);                         // move to origin 
} context.stroke();
  y_g =                  gain*scale*S_calc[j];
  context.moveTo(        x0,  y_g + y0);                                // move to origin 
  for                    (i=0; i<=10; i++)
{ x_g =                  -gain*scale*S_calc[j]*Math.sin(angle*i/10);
  y_g =                  gain*scale*S_calc[j]*Math.cos(angle*i/10);
  context.lineTo(        x_g + x0,  y_g + y0);                         // move to origin 
} context.stroke();
}
}


if                       (form.s1[1].checked)                             // draw left side
{ x0 =                   50;
  y0 =                   scale*2-100;
  context.moveTo(        x0,   y0); 
  for                    (i=0; i<=10; i++)
{ x_g =                  gain*scale*X_calc[i];
  y_g =                  -gain*scale*Y_calc[i];
  context.lineTo(        x_g + x0,  y_g + y0);                            // move to origin 
} context.stroke();
  for                    (i=0; i<=10; i++)
{ x_g =                   gain*scale*X_calc[i];
  y_g =                  -gain*scale*Y_calc[0];
  context.moveTo(        x_g + x0,  y_g + y0);                            // move to origin 
  y_g =                  -gain*scale*Y_calc[10];
  context.lineTo(        x_g + x0,  y_g + y0);                            // move to origin 
} context.stroke();
  for                    (i=0; i<=10; i++)
{ x_g =                   gain*scale*X_calc[0];
  y_g =                  -gain*scale*Y_calc[i];
  context.moveTo(        x_g + x0,  y_g + y0);                            // move to origin 
  x_g =                  gain*scale*X_calc[10];
  context.lineTo(        x_g + x0,  y_g + y0);                            // move to origin 
} context.stroke();
}    



if                       (form.s1[2].checked)                             // draw left side
{ x0 =                   2*scale-50;
  y0 =                   scale*2-100;
  context.moveTo(        x0,   y0); 
  for                    (i=0; i<=10; i++)
{ x_g =                  -gain*scale*X_calc[i];
  y_g =                  -gain*scale*Y_calc[i];
  context.lineTo(        x_g + x0,  y_g + y0);                            // move to origin 
} context.stroke();
  for                    (i=0; i<=10; i++)
{ x_g =                   -gain*scale*X_calc[i];
  y_g =                  -gain*scale*Y_calc[0];
  context.moveTo(        x_g + x0,  y_g + y0);                            // move to origin 
  y_g =                  -gain*scale*Y_calc[10];
  context.lineTo(        x_g + x0,  y_g + y0);                            // move to origin 
} context.stroke();
  for                    (i=0; i<=10; i++)
{ x_g =                   -gain*scale*X_calc[0];
  y_g =                  -gain*scale*Y_calc[i];
  context.moveTo(        x_g + x0,  y_g + y0);                            // move to origin 
  x_g =                  -gain*scale*X_calc[10];
  context.lineTo(        x_g + x0,  y_g + y0);                            // move to origin 
} context.stroke();
}    
    
  context.closePath();  
    
 // form.REC.value  =      form.REC.value +"S_calc[i]"+S_calc[10]+" \n" ;
  
}
</script>

<style                   type = "text/css">
canvas {                 border: 2px solid gray; }           
</style>

</head>
<body> 

<h1>Parabola 1/12 Segments or Sides </h1>
<form >
<input type=text size = "10" value=".5" name="foc" onkeypress="drawPicture(this.form)">
=>Define a parabola focal point =>
<input type=button value="Plot_it" onClick="drawPicture(this.form)">
<input type="radio" Name=s1 checked="checked"  Value = "Seg" />     segments</label>
<input type="radio" Name=s1                    Value = "LSide"  /> <label for="sidecheck"> Left Side</label>
<input type="radio" Name=s1                    Value = "RSide"  /> <label for="sidecheck"> Right Ride</label>
<p> 
<canvas  id   =         "example" width="700" height="700">   </canvas> <br>
</form>

</body>
</html>

12 

3 4

6 5
Other code to look at: (This will help you to calculate the focal point. .5 gives a focal point
within the parabola. I think I used 1.9 for focal point away from the parabola to work better
 as a solar oven.

<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
<title>                  Plot A Parabola      </title>
<script>
function                 drawPicture(form)
{ var canvas =           document.getElementById('example'); // link to id='example'
  var context =          canvas.getContext('2d');               // create graphic context
  var scale =            300;
  var radius =           1;
  var focal = form.foc.value; 
  
  var step =             0.1;
  var a =                1/(4*focal);
  var x0 =               scale;
  var y0 =               scale*2;
  
  
  context.clearRect( 0,0,scale*2,scale*2); //ÊclearÊcanvasÊ

  context.strokeStyle =  "yellow";                              // set stroke to red
  context.beginPath();                                          // new geometry
  context.moveTo(        x0,   y0);                             // move to origin
  context.lineTo(        x0,   -scale*2 + y0 );                 // second point
  context.stroke();
  context.moveTo(        x0-scale,   -scale+ y0 );              // move to origin
  context.lineTo(        x0+scale,   -scale+ y0 );              // second point
  context.stroke();
  
  context.closePath();                                          // end geo

  context.fillStyle =   "rgb( 0, 255, 0)";                      // red, grn, blu

  context.strokeStyle =  "Black"; 
  context.beginPath();                                          // new geometry
  context.moveTo(        x0,   y0);                                // move to origin 
  for                    (i=0; i<=10; i++)
{ var x  =               i*step;
  var y  =               -a*x*x;
  context.lineTo(        scale*x + x0,  scale*y + y0 );           // second point
} context.stroke();                                                // stroke lines

  context.moveTo(        x0,   y0);                                 // move to origin 
  for                    (i=0; i<=10; i++)
{ var x  =              -i*step;
  var y  =              -a*x*x;
  context.lineTo(       scale*x + x0,  scale*y + y0 );             // second point
} context.stroke();                                                // stroke lines
  
  context.moveTo(       x0,   -scale*focal + y0 +5);               // move to focus 
  context.lineTo(       x0,   -scale*focal + y0 -5);               // plot focus 
  context.stroke();
  
  context.moveTo(       x0 +5, -scale*focal + y0 );                // move to focus 
  context.lineTo(       x0 -5, -scale*focal + y0 );                // plot focus 
  context.stroke();

  
  context.font =         "10px Times New Roman";                 // set font
  context.fillStyle =    "Black";                                // define fill using "black"
  context.fillText(      "-1", 10, 2*scale);                     // write "Sample String"  
  context.fillText(      "0",  scale, 2*scale);              // write "Sample String"  
  context.fillText(      "1",  1.97*scale, 2*scale);              // write "Sample String" 
  context.fillText(      "1",  1.97*scale, 1*scale);              // write "Sample String" 
  context.fillText(      "2",  1.97*scale, 10);              // write "Sample String" 
  context.fillText(      "focus",  x0-10, -scale*focal + y0 -10);              // write "Sample String" 


  
}
</script>

<style type="text/css">
canvas {                 border: 2px solid violet; }           
</style>

</head>
<body> 

<h1>Plot a Parabola With A +/-Unity Radius </h1>

<br>
<form>
<input size="10" value=".5" name="foc" onkeypress="drawPicture(this.form)" type="text">
=&gt;Define a parabola focal point =&gt;
<input value="Plot_it" onclick="drawPicture(this.form)" type="button">
<p>    
</p></form>

<canvas id="example" width="600" height="600"> 
</canvas> <br>
Radius is set to +/- 300 points.....A Parabola follows the equation  y = x^2/(4*focal)


</body></html>

——————————————————–

Fake #beer for those of us who do not drink.

Good day.

Quickie post.

Leave a comment

Chit chat

———-

In sympathy with Germany, I am getting out my old typewriter.

——————————————————–

Batch file to slowly print out a text file. Perfect for a quickie teleprompter.

——————————————————–

Did you know that you can use the thermistor from a personal computer fan to tell relative temperature?

 

——————————————————–

Normally I probably would not put something like this in the blog. But the more I thought about it, the more I thought it might fit. Like many people who work late at night, you do not want to disturb anyone while building projects. One tool that is very noisy is a drill. There had to be a better way, I looked for an auger in all the stores, but none were to be found except by mail order. Since I make a lot of things, why not make a sort of auger for light projects that would be quiet in use. That is when I came up with a pvc drill. It could always be used a toy for a child in any case.

The hardest thing to possibly implement is a chuck, Was not sure what I was going to do. Happened to be in Harbor Frieght and they actually had one on the shelf. It was reasonable enough, so I purchased one.  You can actually get chucks separately. Then I was on my way to completing the project.More on the project at:
http://www.instructables.com/id/Pvc-Hand-drill/

——————————————————–

Translating from one batch file system to another can be Interesting. Someone wrote a batch file for emulate a menu that could of been a bit more precise for dos, but I decided to translate it to bash.

Dos:

@echo off
color 0e
Title Website Starter (by Prof. Pickle)
:Menu
cls
echo ---------------------------------------------------------------------
echo This is the Website starter
echo.
echo Select the number of the website you wish to select
echo Or press E to exit.
echo ---------------------------------------------------------------------
echo.
echo.
echo 1. facebook
echo 2. youtube
echo 3. google
echo 4. redtube
echo 5. other
set /p web=
If %web% EQU 1 start www.facebook.com
If %web% EQU 1 goto Menu
If %web% EQU 2 start www.youtube.com
If %web% EQU 2 goto Menu
If %web% EQU 3 start www.google.com
If %web% EQU 3 goto Menu
If %web% EQU 4 start www.redtube.com
If %web% EQU 4 goto Menu
If %web% EQU 5 goto other
If %ERRORLEVEL% NEQ 0 goto ERROR
If %web% EQU E goto exit
If %web% EQU e goto exit
goto please
:other
cls
echo You have chosen other
echo.
echo Type the web address of the website (www.website.com)
set /p otherweb=
start %otherweb%
If %ERRORLEVEL% NEQ 0 goto ERROR
:exit
cls
echo Goodbye!
pause > nul
exit
:ERROR
cls
echo Sorry, an error has occurred.
echo.
echo If you were using the "other website" function you may have
echo typed it incorrectly.
echo.
echo Press any key to go back to menu
pause > nul
goto Menu
:please
cls
echo Please press a number from 1-5
echo.
pause
goto Menu

Sure the author worked really hard on it. then I thought how would I do a quick equivalent using bash. To be fair his batch code could of been improved with a while loop.  This is what I came up with:

Bash:
#!/bin/bash
#
# Script to run firefox and load a specific site.
#
while :
do
clear
echo "************************"
echo "* My website loader    *"
echo "************************"
echo "* [1] Facebook         *"
echo "* [2] Google           *"
echo "* [3] Twitter          *"
echo "* [4] Youtube          *"
echo "* [5] Some other site  *"
echo "*                      *"
echo "* [0] Exit/Stop        *"
echo "************************"
echo -n "Enter your menu choice [1-5, or 0]: "
read yourch
case $yourch in
1)  firefox http://www.facebook.com & ;;
2)  firefox http://www.google.com & ;;
3)  firefox http://www.twitter.com & ;;
4)  firefox http://www.youtube.com & ;;
5) echo  ; read -p "Enter website: " ws ; firefox $ws & ;;
0) exit 0;;
*) echo "Oopps!!! Please select choice 1,2,3, 4 or 5";
echo "Press Enter to continue. . ." ; read ;;
esac
done

Which generates a screen something like this.
************************
* My website loader    *
************************
* [1] Facebook         *
* [2] Google           *
* [3] Twitter          *
* [4] Youtube          *
* [5] Some other site  *
*                      *
* [0] Exit/Stop        *
************************
Enter your menu choice [1-5, or 0]: 

——————————————————–

The original teleprompter setup was a bit bulky, but works best for me. Decided to come up with a simpler setup that only required one reflector.

But with this unit you need to have reversed text displayed. No problem.

Create text in OfficeWriter.
Export text to a pdf file i.e. test.pdf

Get software.
$ sudo apt-get pdfjam
Reverse the pdf facing.
$ pdffip test.pdf
which generates test-flipped.pdf.

Show the file in your document viewer and do your video.
You will probably have more text that what I used.

——————————————————–

Got milk?

SUNP0006

Good day.

Augusto.

Leave a comment

Chit chat

———–

Some of us in IT have spent a lot of hours and expense getting educated. Some also have a lot of practical experience. IT people are more than just Googlers. In the corporate environment, IT spend a lot of time setting machines up. To have users try to repair a setup could do more damage than good.

#God is a single #father. No wonder he does not have time to fix all the problems.

Play on “Once I built a railroad”:

Once I built a network,

Made it run.

Made it race against time.

Once I built a network,

and now it’s done,

Brother can you spare a paradigm.

 

Tuxpaint import

$ tuxpaint-import [filename.ext]

—————————————————————

Protect your usb device from being hacked when you need a charge with a usb rubber.

—————————————————————

Did you know that you can use the thermistor from a personal computer fan to tell relative temperature?

 

images

—————————————————————

Sharks Cove board with Intel Atom CPU targeted at Windows developers.

One really thinks this is aimed at the Raspberry Pi/Arduino market. But at $300 dollars, who is really going to choose it. Microsoft  has a tradition of not supporting speciality products for any period of time. Zune and etc etc etc. Even if it was worth it I would shy away from it. Ironically you can take a pico motherboard and dc-dc power supply and in effect have the same thing for a fraction of the cost.

Now if you really want to get inane on this, I will take my old 486 laptop and add all kinds of breakout cables to do quite a bit. Parallel, serial,  vga, and etc. The 486 laptop was free. Cables did have some cost to them, but no where near $300. If you know anything about electronics, a “1” is plus five volts and a “0” is near zero volts. That is true for the Raspberry Pi, Arduino, personal computers, and a zillion developer boards. Not all interfaces will be using digital, but you get the idea.

Run my robot on an old Pentium 1 with linux as the os. With a laptop or most any standard legacy machine you can add a variety of interfaces:

Parallel
http://www.instructables.com/id/No-solder-parallel-port-break-out/

Serial
http://www.instructables.com/id/DB9-serial-break-out-cable/

Vga
http://www.instructables.com/id/Vga-breakout-cable/

Plus others such as usb. Also consider:
http://www.instructables.com/id/Electronic-Guides/

It’s your choice!

—————————————————————

Old electronics can yield quite a lot of good equipment. For example an old 5 1/4″ drive can yield stepper motors. You just saved twenty dollars.

—————————————————————

Many people have created tutorials on http://www.instructables.com. To see how each instructable is doing can be a chore. Devised a bash script to help conquer that chore. Though may not be the latest, it certainly shows viable trends. You can also import the data into a spreadsheet rather easily.

First you will want to create a text file with the instructables you want to follow.
One url to a line.

http://www.instructables.com/id/Line-editor-template/

You may need to install a program or two such as elinks and zenity so things will work. Then you will want to create an executable of the file to collect the data.

#================================
#
#  Instructables numbers catcher
#
#=================================
# Assignments
# ——————————–
szAnswer=$(zenity –file-selection –title=”Select a iurl file to read”)
datafile=$szAnswer
outfile=”inumdata”
total=0
# the date
tmon=$(date +”%b”)
tday=$(date +”%d”)
echo  “The views for $dj on $tmon $tday:” > $outfile
#=================================
#
# Data input
#———————————
while read line
do theurl=$line
echo  “$theurl”
# echo -n “$theurl'” >> $outfile
# get total views
# count=$(elinks  “$theurl” | grep -m 1 “hits-count” | sed ‘s/[^0-9]*//g’)
count=$(elinks  “$theurl” | grep -m 1 “views” | sed ‘s/[^0-9]*//g’)
# let total=$total+$count
echo “$count” >> $outfile
done < $datafile
# echo “total: $total” >> $outfile
zenity –text-info –filename=$outfile

Then it is a matter of running the script.

Just copy and paste the data into the spreadsheet.

—————————————————————

Sometimes wifi is just not required.

BHbFznGCcAEOomD.jpg:large

—————————————————————

Easy food conversion calculator

Screenshot from 2014-08-03 11:58:21

Code is available.

Good day.

 

Older Entries

Follow

Get every new post delivered to your Inbox.