Chit chat

=======

Happy that I was able to get my pogoplug arch linux box going again. Also did some firmware upgrades to a friend’s beaglebone black board.

Reinstalled firefox. Solved a lot of problems. System seems faster now.

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

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.

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

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/

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

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 http://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

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

Decided to put my 512  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.

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

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 presa to modify kernel argument. If you cancel pressESC‘ 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.

Appened 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/ResetRootPasswor

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

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 last-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
  ;;
 
 last-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

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

Start of a lentil burrito. About to add the cheese.

SUNP0008

Good day.

Advertisements