Posts

Showing posts from November, 2014

Your first bash script.

Image
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 boo...

Linux shot.

Image

Simple shell ("sh") database.

Image
From the Rosetta Code --------------------------------- $ 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'...

Ferrous wheel?

Image

The more things change, the more they stay the same.

Image

Freebasic on the Raspberry Pi.

Image
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.

Image

Raspbmc

Image
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

Image
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.

Image
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 Step 2: Now, select your operating system if it is dual/multiple boot and  pres ‘ a ‘ to modify kernel argument . If you cancel press ‘ ESC ‘ key. 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. Opened 1 at the GRUB Step 4 :  After reboot type ‘ passwd ‘ command without username and press ‘ Enter ‘ key in command prompt. Change root password Step 5 : Reboot your system and login using the new password . Reference: http://wiki.centos.org/TipsAndTricks/ResetRootPass...

Conio.h ugh.

Image
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-...

EFF open source router.

Image
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.

Image
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.

Image
Is this call secure?

Bare arduino plus ethernet board.

Image
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

Image
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...

Good linux.

Image

Metronome - musical tool.

Image
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 ...

Encode/decode it.

Image
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$...

More powerful than a '70's mainframe.

Image

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 comparin...

One pot pasta.

Image
 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 st...