Sunday, November 30, 2014

Your first bash script.

Writing your first script and getting it to work to successfully write a shell script, you have to do three things:

    Write a script
    Give the shell permission to execute it
    Put it somewhere the shell can find it

Writing a script

A shell script is a file that contains ASCII text. To create a shell script, you use a text editor such as vim or nano. A text editor is a program, like a word processor, that reads and writes ASCII text files. There are many, many text editors available for your Linux system, both for the command line environment and the GUI environment.



Now, fire up your text editor

[you@yourllinuxbox you]$ nano yourfirstscript

and type in your first script as follows:

#!/bin/bash
# My first script

echo "Hello World!"

The clever among you will have figured out how to copy and paste the text into your text editor. Then (^X) exit. Say (Y)es to save the modified buffer.

If you have ever opened a book on programming, you would immediately recognize this as the traditional "Hello World" program. Save your file with some descriptive name. How about yourfirstscript?

The first line of the script is important. This is a special clue given to the shell indicating what program is used to interpret the script. In this case, it is /bin/bash. Other scripting languages such as perl, awk, tcl, Tk, and python can also use this mechanism.

The second line is a comment. Everything that appears after a "#" symbol is ignored by bash. As your scripts become bigger and more complicated, comments become vital. They are used by programmers to explain what is going on so that others can figure it out. The last line is the echo command. This command simply prints what it is given on the display.
Setting permissions

The next thing we have to do is give the shell permission to execute your script. This is done with the chmod command as follows:

[you@yourllinuxbox you]$ chmod 755 yourfirstscript

The "755" will give you read, write, and execute permission. Everybody else will get only read and execute permission. If you want your script to be private (i.e., only you can read and execute), use "700" instead.
Putting it in your path

At this point, your script will run. Try this:

[you@yourllinuxbox you]$ ./yourfirstscript

You should see "Hello World!" displayed. If you do not, see what directory you really saved your script in, go there and try again.

Before we go any further, I have to stop and talk a while about paths. When you type in the name of a command, the system does not search the entire computer to find where the program is located. That would take a long time. You have noticed that you don't usually have to specify a complete path name to the program you want to run, the shell just seems to know.

Well, you are right. The shell does know. Here's how: the shell maintains a list of directories where executable files (programs) are kept, and just searches the directories in that list. If it does not find the program after searching each directory in the list, it will issue the famous command not found error message.

This list of directories is called your path. You can view the list of directories with the following command:

[you@yourllinuxbox you]$ echo $PATH

This will return a colon separated list of directories that will be searched if a specific path name is not given when a command is attempted. In our first attempt to execute your new script, we specified a pathname ("./") to the file.

You can add directories to your path with the following command, where directory is the name of the directory you want to add:

[you@yourllinuxbox you]$ export PATH=$PATH:directory

A better way would be to edit your .bash_profile file to include the above command. That way, it would be done automatically every time you log in. (Not really used anymore)

[you@yourllinuxbox you]$ PATH=$PATH:~/bin
[you@yourllinuxbox you]$ export PATH

Most modern Linux distributions encourage a practice in which each user has a specific directory for the programs he/she personally uses. This directory is called bin and is a subdirectory of your home directory (/home/you/). If you do not already have one, create it with the following command:

[you@yourllinuxbox you]$ mkdir bin

Move your script into your new bin directory and you're all set.

[you@yourllinuxbox you]$ mv yourfirstscript ~/bin/.

Now you just have to type:

[you@yourllinuxbox you]$ yourfirstscript

and your script will run.

Friday, November 28, 2014

Simple shell ("sh") database.

From the Rosetta stone:



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

$ sdb create CDs
Create DB `CDs'
$ sdb add CDs Bookends
$ sdb prop CDs Bookends artists "Simon & Garfunkel"
$ sdb add CDs "Ode to joy"
$ sdb prop CDs "Ode to joy" artist "Beethoven"
$ sdb tag CDs Bookends rock folk  # I'm not sure about this
$ sdb tag CDs "Ode to joy" classical
$ sdb show CDs Bookends
Description:
 
artists:
    Simon & Garfunkel
 
Tags: folk  rock
$ sdb prop CDs "Ode to joy" Description "Sym. No. 9"
$ sdb show CDs "Ode to joy"
Description:
    Sym. No. 9
 
artist:
    Beethoven
 
Tags: classical
$ sdb list-all CDs
Tag: classical
    Ode to joy
 
Tag: folk
    Bookends
 
Tag: rock
    Bookends
 
$ sdb drop CDs
Delete DB `CDs'
$
 
--------------------
 #!/bin/sh
 
db_create() {
 mkdir ./"$1" && mkdir "./$1/.tag" && echo "Create DB \`$1'"
}
 
db_delete() {
 rm -r ./"$1" && echo "Delete DB \`$1'"
}
 
db_show() {
 if [ -z "$2" ]; then show_help; fi
 for x in "./$1/$2/"*; do
  echo "$x:" | sed "s/.*\///"
  cat "$x" | sed "s/^/    /"
  echo
 done
 
 printf "Tags: "
 ls "./$1/$2/.tag"
}
 
db_tag() {
 local db="$1" item="$2"
 shift
 shift
 for tag in $@; do
  mkdir "./$db/.tag/$tag"
  ln -s "$PWD/$db/$item" "./$db/.tag/$tag/"
  touch "./$db/$item/.tag/$tag"
 done
}
 
show_help() {
 echo "Usage: $0 command [args]"
 echo "Commands:"
 cat $0 | grep ") ##" | grep -v grep | sed 's/) ## /:\t/'
 exit
}
 
if [ -z "$1" ]; then show_help; fi
 
action=$1 it=database
shift
case $action in
 create) ## db -- create $it
  db_create "$@" ;;
 
 drop) ## db -- delete $it
  db_delete "$@" ;;
 
 add) ## db item -- add new item to $it
  mkdir -p "./$1/$2/.tag" && touch "./$1/$2/Description" ;;
 
 rem) ## db item -- delete item from $it
  rm -r "./$1/$2"
  rm "./$1/.tag/"*"/$2"
  ;;
 
 show) ## db item -- show item
  db_show "$@" ;;
 
 newtag) ## db new-tag-name -- create new tag name
  mkdir "./$1/.tag/$2" ;;
 
 prop) ## db item property-name property-content -- add property to item
  echo "$4" > "./$1/$2/$3" ;;
 
 tag) ## db item tag [more-tags...] -- mark item with tags
  db_tag "$@" ;;
 
 last) ## db -- show latest item
  ls "$1" --sort=time | tail -n 1
  ;;
 
 list) ## db -- list all items
  ls "$1" -1 --sort=time
  ;;
 
 list-all) ## db -- list items in each category
  for x in "$1/.tag/"*; do
   echo "$x" | sed 's/.*\//Tag: /'
   printf "    "
   ls "$x" --sort=time | tail -n 1
   echo
  done
  ;;
 
 help) ## this message
  show_help
  ;;
 
 *) echo Bad DB command: $1
  show_help
  ;;
esac

Sunday, November 23, 2014

Freebasic on the Raspberry Pi.

So happy that I can run even if it is an old version of Freebasic on the Raspberry Pi. Freebasic  is a lot like but not exactly like qbasic. The first thing I did was to port a spreadsheet to the unit.




To set up Freebasic, the first thing I did was to download the tarball and the extract it. (from sourceforge.net)

$ tar xvf fbc-0.91.0-pi-debian.tar.gz

Install it.

$ sudo ./install.sh -i

And lastly install a few goodies to make the install complete.

 $ sudo apt-get install libxext-dev libncurses5-dev libx11-dev libxpm-dev libxrandr-dev libstdc++6-4.4-dev

You should be able to write a test program to see if the install worked.

In an editor, type a simple program.

$ vim test,bas

PRINT "hello!"

Compile it

$ fbc test.bas

Run it.

$ ./test
hello!

There is more to it than that but that is a quickie starter.

If only.



Raspbmc




Decided to put my 512 meg ram RPi to the test, so I downloaded and installed the raspbmc image. Of course the first thing you want to do is to setup the hardware including setting the screen size. If you already have an lcd screen, that may not be necessary. Secondly you want to start installing different interfaces. For example I installed the interface for "Good eats". Looked like they only had the episodes meant for this part of the year.

Even on an old composite Commodore monitor, I was surprised at the clarity. There are still some other tweaks to make, but out of the box was actually pretty good. A zillion times better that my Netgear ntv300 video streaming box. The are always removing services and the few left are mostly pay for. In any case, The RPi with raspbmc.more than makes up for it anyway.

You may want to reset your router so that in case your lease is about up there will not be any interference.


Southern buttermilk pie








Southern buttermilk pie

Ingredients:

1/2 - cup buttermilk
1 3/4 - cup sugar
2 - large eggs
3 - tablespoons flour
1 - pinch of salt
1 - stick butter melted
1 - teaspoon vanilla
1 - teaspoon nutmeg


Method: 

Preheat oven to 400° Fahrenheit. 

Mix everything together and pour into an unbaked 9" pieshell. 
Sprinkle the top lightly with nutmeg. 
Bake 15min. 
Reduce oven to 350° Fahrenheit and bake 45min. 
Cool to allow filling to set.

Change the forgotten root password.

Reset forgot root password in CentOS 6.1/6.2/6.3/6.4/6.5

To reset forgot root password in CentOS 6.0/6.1/6.2/6.3/6.4/6.5 and Fedora 16/17/18/19/20 follow the given below steps:
Step1: Boot your CentOS linux system and press esc key when you see the message “Press any key to enter the menu
Message on system booting
Message on system booting
Step 2: Now, select your operating system if it is dual/multiple boot and presa to modify kernel argument. If you cancel pressESC‘ key.
Boot menu
Boot menu[
[ads]
Step 3:  In kernel configuration, we have 2 methods to change to single mode. 1 we can use a number “1″, 2 we can use character “S”. Enter after done.
Appened 1 at the GRUB
Opened 1 at the GRUB
Step 4:  After reboot type ‘passwd command without username and press ‘Enter key in command prompt.
Change root password
Change root password
Step 5: Reboot your system and login using the new password.
Reference: http://wiki.centos.org/TipsAndTricks/ResetRootPasswor

Conio.h ugh.

Disappointed how c/c++ programmers do not take the time to make their code portable. Take for instance the legacy code:

    #include<iostream>
    #include<conio.h>
    using namespace std;
    int main()
    {
        char key_press;
        int ascii_value;
        cout<<"\n\t\t\tPress Any Key To Check  Its ASCI Value\n\n\t\t\tPress ESC to EXIT\n\n\n";
        while(1)
        {
        key_press=getch();
        ascii_value=key_press;
        if(ascii_value==27) // For ESC
         break;
       cout<<"\t\t\tKEY Pressed-> \" "<<key_press<<" \" Ascii Value =  "<<ascii_value<<"\n\n";
        }
        return 0;
    }



Would not compile on our linux machine.  There is not a conio.h for linux, but you can find compatible code on the net to act as a replacement. After downloading the code and moving to the right place, things began to work. Here is the updated code to work on linux.

#include<curses.h>
#include<conio.h>
#include<iostream>
    using namespace std;
    int main()
    {
    char key_press;
    int ascii_value;
    cout<<"\n\rPress Any Key To Check  Its ASCI Value\n\rPress ESC to EXIT\n\r";
    while(1)
    {
    key_press=getch();
    ascii_value=key_press;
    if(ascii_value==27) // For ESC
     break;
   cout<<"\tKEY Pressed-> \" "<<key_press<<" \" Ascii Value =  "<<ascii_value<<"\r\n";
    }
    return 0;
    }

Then to compile it you would use:

$  g++  getthecharcode.c -lncurses -o myprog

Hope this helps those who have problems moving code from legacy platforms to linux.




Saturday, November 22, 2014

EFF open source router.

The EFF aka Electronic Frontier Foundation has come out with open firmware (allegedly based on openwrt) for a particular router. The router is the Netgear WNDR3800 router. you can get the firmware at: https://openwireless.org/content/open-wireless-router-firmware-installation


But actually if you use an old pc, a host of free router software is already available. Examples:  http://www.instructables.com/id/DIY-network-firewall-from-legacy-parts/ or http://www.instructables.com/id/Openwrt-on-a-pc/


Management console.




Originally I was looking for a script that I could use via the web to manage a machine. Really did not find anything, but after backdooring into a script from searching the www.archive.org, this is what I came up with. The original code was only about ten lines or so, but what a script. You can find the details at:

http://www.instructables.com/id/Simple-linux-commands-from-a-web-page

In your face.

Is this call secure?

Thursday, November 20, 2014

Bare arduino plus ethernet board.

Going to try and experiment to hook a bare arduino to an ethernet board. According to the documentation for the board only six intelligent pins are connected directly. We will see how true that is.






Lines required by the ethernet board. Pins usage on Arduino 

D2 - Connects the INT pin of the W5100
D3 - Contral the reset of the W5100
D10 - Used for SPI Chip Select
D11 - Used for SPI MOSI
D12 - Used for SPI MISO
D13 - Used for SPI SCK

Also see: http://arduino.cc/en/Reference/Ethernet


Getting ready to test the unit. Need a 3.3 volt source instead of 6v.




Mafalde




Mafalde pasta

Ingredients:
  • 1 - can spinach
  • 1/2 - 1 cup of ricotta cheese
  • A pinch of nutmeg
  • 1/2 to 1 cup of peanuts
  • Handful of raisins
  • Handful of Parmesan cheese.
  • 1/2 to 1 pound of  fettucine
  • Salt
  • Pepper
  • Basil
  • Garlic powder.
Method:

Bring a large pot of salted water to boil for pasta.
When the water is boiling, start on the sauce.
Finely grind up some peanuts with some cooking oil.
Put the mixture in a saute pan.
Let it heat for a minute or two.
Add the spinach.
Once the spinach is mixed in, then add the ricotta cheese.
Let the cheese melt and mix in.
Add the spices.
Add a little water if needed.
Add  the raisans.
Keep stirring to make a cohesive mix.
Top with the Parmesan cheese.
Add the pasta and serve warm.



Another variation:



Ingredients

kosher salt
3 cups crushed tomatoes
1 cup condensed milk
1 pound fettuccine
1 - can green beans
½ cup grated Parmigiano-Reggiano
Salt
Pepper
Basil
Garlic powder.

Directions

Bring a large pot of salted water to boil for pasta. Bring the red sauce to a simmer in a large skillet. Stir in the condensed milk, bring to a simmer, and cook until thickened, about 5 to 6 minutes.

Slip the fettuccine into boiling water. When the pasta is to the tooth and sauce is ready, drop the pasta directly into the sauce. Add the green beans with the other spices,  then toss to coat the pasta with the sauce. Remove from heat, stir in the grated cheese, and serve immediately.
serves: 6

I had this dish at Del’s Bar & Ristorante DelPizzo, on Liberty Avenue in Pittsburgh, the local restaurant that caters to the neighborhood crowd, not too far from our restaurant, Lidia’s, on Smallman Street. This velvety combination of tomato and cream sauce is good on any pasta. The day we were there, it was offered with shells. But I think it is even better served with fettuccine.

Ingredients
kosher salt
3 cups Marinara sauce
1 cup heavy cream
1 pound fettuccine
10 large fresh basil leaves, shredded
½ cup grated Grana Padano or Parmigiano-Reggiano
Directions
To make the marinara sauce, Lidia's recipe for Salsa Marinara is available on her website and in Lidia Cooks from the Heart of Italy.

Bring a large pot of salted water to boil for pasta. Bring the marinara to a simmer in a large skillet. Stir in the heavy cream, bring to a simmer, and cook until thickened, about 5 to 6 minutes.

Slip the fettuccine into boiling water. When the pasta is al dente and sauce is ready, drop the pasta directly into the sauce. Add the shredded basil, then toss to coat the pasta with the sauce. Remove from heat, stir in the grated cheese, and serve immediately.
- See more at: http://www.lidiasitaly.com/recipes/detail/1060#sthash.QqI1GsjE.dpuf
serves: 6

I had this dish at Del’s Bar & Ristorante DelPizzo, on Liberty Avenue in Pittsburgh, the local restaurant that caters to the neighborhood crowd, not too far from our restaurant, Lidia’s, on Smallman Street. This velvety combination of tomato and cream sauce is good on any pasta. The day we were there, it was offered with shells. But I think it is even better served with fettuccine.

Ingredients
kosher salt
3 cups Marinara sauce
1 cup heavy cream
1 pound fettuccine
10 large fresh basil leaves, shredded
½ cup grated Grana Padano or Parmigiano-Reggiano
Directions
To make the marinara sauce, Lidia's recipe for Salsa Marinara is available on her website and in Lidia Cooks from the Heart of Italy.

Bring a large pot of salted water to boil for pasta. Bring the marinara to a simmer in a large skillet. Stir in the heavy cream, bring to a simmer, and cook until thickened, about 5 to 6 minutes.

Slip the fettuccine into boiling water. When the pasta is al dente and sauce is ready, drop the pasta directly into the sauce. Add the shredded basil, then toss to coat the pasta with the sauce. Remove from heat, stir in the grated cheese, and serve immediately.
- See more at: http://www.lidiasitaly.com/recipes/detail/1060#sthash.QqI1GsjE.dpuf
serves: 6

I had this dish at Del’s Bar & Ristorante DelPizzo, on Liberty Avenue in Pittsburgh, the local restaurant that caters to the neighborhood crowd, not too far from our restaurant, Lidia’s, on Smallman Street. This velvety combination of tomato and cream sauce is good on any pasta. The day we were there, it was offered with shells. But I think it is even better served with fettuccine.

Ingredients
kosher salt
3 cups Marinara sauce
1 cup heavy cream
1 pound fettuccine
10 large fresh basil leaves, shredded
½ cup grated Grana Padano or Parmigiano-Reggiano
Directions
To make the marinara sauce, Lidia's recipe for Salsa Marinara is available on her website and in Lidia Cooks from the Heart of Italy.

Bring a large pot of salted water to boil for pasta. Bring the marinara to a simmer in a large skillet. Stir in the heavy cream, bring to a simmer, and cook until thickened, about 5 to 6 minutes.

Slip the fettuccine into boiling water. When the pasta is al dente and sauce is ready, drop the pasta directly into the sauce. Add the shredded basil, then toss to coat the pasta with the sauce. Remove from heat, stir in the grated cheese, and serve immediately.
- See more at: http://www.lidiasitaly.com/recipes/detail/1060#sthash.QqI1GsjE.dpuf

    Good linux.


    Wednesday, November 19, 2014

    Metronome - musical tool.


    If you are a musician, one of the most useful tools is a metronome. It graphically displays the beats for you to follow while playing music.One particular program is all text based so it will run on a variety of systems even without a sound card. To invoke the program, you use the program name followed by the speed you want to use.


    Then the program will start. The program uses a simple cursor to mark the time of the beats.


    The program seems to do some compensation to keep the metronome accurate.
    To build the program, you would:

    $ gcc metronome.c -o metronome

    Here is the code:

    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <stdint.h>
    #include <signal.h>
    #include <time.h>
    #include <sys/time.h>

    struct timeval start, last;

    inline int64_t tv_to_u(struct timeval s)
    {
        return s.tv_sec * 1000000 + s.tv_usec;
    }

    inline struct timeval u_to_tv(int64_t x)
    {
        struct timeval s;
        s.tv_sec = x / 1000000;
        s.tv_usec = x % 1000000;
        return s;
    }

    void draw(int dir, int64_t period, int64_t cur, int64_t next)
    {
        int len = 40 * (next - cur) / period;
        int s, i;

        if (len > 20) len = 40 - len;
        s = 20 + (dir ? len : -len);

        printf("\033[H");
        for (i = 0; i <= 40; i++) putchar(i == 20 ? '|': i == s ? '#' : '-');
    }

    void beat(int delay)
    {
        struct timeval tv = start;
        int dir = 0;
        int64_t d = 0, corr = 0, slp, cur, next = tv_to_u(start) + delay;
        int64_t draw_interval = 20000;
        printf("\033[H\033[J");
        while (1) {
            gettimeofday(&tv, 0);
            slp = next - tv_to_u(tv) - corr;
            usleep(slp);
            gettimeofday(&tv, 0);

            putchar(7); /* bell */
            fflush(stdout);

            printf("\033[5;1Hdrift: %d compensate: %d (usec)   ",
                (int)d, (int)corr);
            dir = !dir;

            cur = tv_to_u(tv);
            d = cur - next;
            corr = (corr + d) / 2;
            next += delay;

            while (cur + d + draw_interval < next) {
                usleep(draw_interval);
                gettimeofday(&tv, 0);
                cur = tv_to_u(tv);
                draw(dir, delay, cur, next);
                fflush(stdout);
            }
        }
    }

    int main(int c, char**v)
    {
        int bpm;

        if (c < 2 || (bpm = atoi(v[1])) <= 0) bpm = 60;
        if (bpm > 600) {
            fprintf(stderr, "frequency %d too high\n", bpm);
            exit(1);
        }

        gettimeofday(&start, 0);
        last = start;
        beat(60 * 1000000 / bpm);

        return 0;
    }

    Good luck and have fun.

    Encode/decode it.



    One of the first uses of computers was to encode messages such as with the enigma. Also used was the Navajo indian codetalkers to naturally send and receive messages so that the enemy could not decipher them. Even kids have used pig-latin to send secret messages. You do not have to get that compilcated though. Do not know morse code, then let the computer do the translation for you. You could use a program like codeit.





    and then go to the morse code option:




    If you have source file named test with:

    This is a test.

    Then the conversion to test.out might be:

     -  ....  ..  ...   ..  ...   .-   -  .  ...  -  .-.-.-

    One thing to notice is that there is not differentiation between upper and lower case letters.  To do a program like this, you will want to set up a translation table. In fact, you could use any set of characters for your own secret code.

        SELECT CASE UCASE$(Character$)
                CASE "A"
                    morsedat$ = ".-"
                CASE "B"
                    morsedat$ = "-..."
                CASE "C"
                    morsedat$ = "-.-."
                CASE "D"
                    morsedat$ = "-.."
                CASE "E"
                    morsedat$ = "."
                CASE "F"
                    morsedat$ = "..-."
                CASE "G"
                    morsedat$ = "--."
                CASE "H"
                    morsedat$ = "...."
                CASE "I"
                    morsedat$ = ".."
                CASE "J"
                    morsedat$ = ".---"
                CASE "K"
                    morsedat$ = "-.-"
                CASE "L"
                    morsedat$ = ".-.."
                CASE "M"
                    morsedat$ = "--"
                CASE "N"
                    morsedat$ = "-."
                CASE "O"
                    morsedat$ = "---"
                CASE "P"
                    morsedat$ = ".--."
                CASE "Q"
                    morsedat$ = "--.-"
                CASE "R"
                    morsedat$ = ".-."
                CASE "S"
                    morsedat$ = "..."
                CASE "T"
                    morsedat$ = "-"
                CASE "U"
                    morsedat$ = "..-"
                CASE "V"
                    morsedat$ = "...-"
                CASE "W"
                    morsedat$ = ".--"
                CASE "X"
                    morsedat$ = "-..-"
                CASE "Y"
                    morsedat$ = "-.--"
                CASE "Z"
                    morsedat$ = "--.."
                CASE "1"
                    morsedat$ = ".----"
                CASE "2"
                    morsedat$ = "..---"
                CASE "3"
                    morsedat$ = "...--"
                CASE "4"
                    morsedat$ = "....-"
                CASE "5"
                    morsedat$ = "....."
                CASE "6"
                    morsedat$ = "-...."
                CASE "7"
                    morsedat$ = "--..."
                CASE "8"
                    morsedat$ = "---.."
                CASE "9"
                    morsedat$ = "----."
                CASE "0"
                    morsedat$ = "-----"
                CASE "."
                    morsedat$ = ".-.-.-"
                CASE "?"
                    morsedat$ = "..--.."
                CASE ","
                    morsedat$ = "--..--"
                CASE "-"
                    morsedat$ = "-...-"
                CASE "/"
                    morsedat$ = "-..-."
                CASE " "
                    morsedat$ = " "
                CASE Backspace$, CHR$(29)
                    morsedat$ = "...-.-"
                CASE Escape$
                    morsedat$ = ".-.-."
                CASE Quote$, CHR$(39)
                    morsedat$ = ".-..-."
                CASE ":"
                    morsedat$ = "---..."
                CASE ";"
                    morsedat$ = "-.-.-."
                CASE "(", ")"
                    morsedat$ = "-.--.-"
                CASE "+", "&"
                    morsedat$ = ".-..."
                CASE ELSE
                    morsedat$ = " "
            END SELECT

    If you really wanted to get complicated, you could go through several translations.

    Monday, November 17, 2014

    QB2C

    QB2C has been around for along time. QB2C is a Quickbasic to C translator. So you can take the Old BASIC source and translate it to C for recompiling. For low end machines such as embedded system this can be a boon for not having to reinvent the wheel. Just put it on my Cisco NSLU2. Of course you have to compile the source code on the unit. That took a while but the working programs seem fast enough. There are some quirks as it is not perfect, so you may have to massage some C code for it to work.

     $ cat /proc/cpuinfo
    Processor    : XScale-IXP42x Family rev 1 (v5l)
    BogoMIPS    : 266.24
    Features    : swp half thumb fastmult edsp
    CPU implementer    : 0x69
    CPU architecture: 5TE
    CPU variant    : 0x0
    CPU part    : 0x41f
    CPU revision    : 1

    Hardware    : Linksys NSLU2

    But there can be some other advantages. One such advantage is that you can learn C code by comparing the original BASIC code to the resulting C code. Take for example your traditional helloworld program and compare it to the resulting C code.

    PRINT "Hello, World!"

    $ ./qb2c test.bas test.c
    qb2c: translating  test.bas  -->  test.c
    Translation done in 0 sec.
    $  cat test.c
    #include <stdio.h>
    #include <string.h>
    #include <stddef.h>
    #include <stdlib.h>
    #include <ctype.h>

    /* This file was generated by QuickBasic to C translator */
    /* qb2c  ver.3.2k 29.Mar.1999 Free version.                            */

    #define LMAX 1024

    /* Function declarations */

    /* Shared variables and arrays declarations */

    /* Open files pointers */
    main()
    {
     printf("%s\n","Hello, World!");
    } /* End of MAIN */

    Despite the extra code:

    PRINT "Hello, World!"

    Translates to:

    printf("%s\n","Hello, World!");

    Some ways a lot a like. 

    If we wanted to do a loop then it might turn out like this: (only showing the relevant parts).


    From:

    FOR X = 1 TO 5
    PRINT "Helllo, world!"
    NEXT X

    to:

      static float X;

     for(X = 1; X <= 5; X++)
     {
      printf("%s\n","Hello, world!");
     }

    Think you get the idea!

    Have fun.

    One pot pasta.


     First saw this done in one of those infomercials. Sounded like a good idea to try.  This dish is not good for uncooked meat. Though I might use canned tuna added at the last minute as an exception. You also want to use dried pasta instead of fresh pasta as the fresh pasta will cook too fast. As a side note, Sicilians on occasion do eat fish with cheese.

    Ingredients

    12 - ounces your favorite pasta such as angel hair. (Dried pasta works best.)
    12 - ounces tomatoes, halved or quartered or crushed
    1 - onion, thinly sliced (about 2 cups)
    4 - cloves garlic, thinly sliced Garlic powder could be a substitute
    2 - teaspoons basil, plus torn leaves for garnish
    2 - tablespoons extra-virgin olive oil, plus more for serving
    Coarse salt and freshly ground pepper
    4 to 5 - cups water
    Good amount of freshly grated Parmesan cheese, for serving




    Directions:

    1. Combine pasta, tomatoes, onion, garlic, basil, oil, 2 teaspoons salt, 1/4 teaspoon pepper, and water in a large straight-sided skillet. Bring to a boil over high heat. Boil mixture, stirring and turning pasta frequently with a large pasta fork, until pasta is al dente (aka to the tooth) and water has nearly evaporated, about 9  to 10 minutes.

    2. Season to taste with salt and pepper and then garnish with fresh basil if available. Serve with oil and Parmesan.