Menu

20 August 2007

Speed up Hostel PC using Port Forwording using ssh

Heart of this trick is this command
ssh -L 8080:localhost:80 narendra@10.64.22.27

see my hostel pc is 10.137.1.36 use 100 Mbps
and lab pc is 10.64.22.27 use 10Mbps very slow

now hostel pc is very slow so, i put this command so that all the communication on my port 8080 will be directed to port 80 of my lab pc , so my hostel pc is as slow as previous but only one difference that my port 8080 is very fast , because all the communication of this port is actually is connected to PC lan, and not hostel lan,

So to make my hostel pc fast now we need to edit the proxy setting. go to "Network Proxy Preference" from menubar by click on system then preferences then Network Proxy on Fedora 7. This my updates of yumex goes very fast and download speed is also very fast, but from lab PC i can access my neighbour PC which is 10.64.21.27 but i tried to access smb://10.64.21.27 from hostel but not working so i will try latter to edit some setting so that you will be present to virtually on lan of institute from hostel PC.

Now its time to hack VNCVIEWER, from hostel PC you cannot connect the remote desktop to linux using vncviewer because of lan and network setting. and more over it you able to connect , then also the connection is not secure because nature of vnv protocol, so you can actually tunnel the vnc traffic inside a ssh in which you can forward your VNC port.
for more details

http://johnny.chadda.se/2006/10/24/access-your-linux-computer-graphically-and-securely-using-ssh-and-vnc/

But most simple way , which i use with-out port forwarding,, ;)
$ ssh -X user-name@ip-address
$ vncviewer localhost

13 August 2007

How to copy all pdf from a folder and subfolder

Sometimes We get a big directory which has a lot of many subdirectories and so on, generally I use to copy a courses form websites. i use to copy full or part of a site (that include every files and folder) using wget command. but only pdf files are need mainly. So here is command which copy all the pdf files to a single directory.
here is the situation

|--->BIGFOLDER
|
--->BIGFOLDER/f1.pdf
|
--->BIGFOLDER/f2.pdf
|
--->BIGFOLDER/classes
|--->BIGFOLDER/classes/f3.jpg
|--->BIGFOLDER/classes/f4.pdf
|--->BIGFOLDER/classes/pdf.doc
|--->BIGFOLDER/classes/f5.ppt
|--->BIGFOLDER/Fun/
|--->BIGFOLDER/Fun/f6.jpg
|--->BIGFOLDER/Fun/f7.pdf
|--->BIGFOLDER/Fun/Movies/
|--->BIGFOLDER/Fun/Movies/f8.pdf
|--->BIGFOLDER/Fun/Movies/f9.avi
|--->BIGFOLDER/Fun/f10.pdf
now using command line go to the BIGFOLDER directory using cd command
then copy past this line

mkdir ../allpdf;find -name '*.pdf'|while read Filename ; do cp "$Filename" ../allpdf/ ; done
after applying we will get a new folder named allpdf parallel to the search folder. like this

|--->BIGFOLDER
|
--->BIGFOLDER/f1.pdf
|
--->BIGFOLDER/f2.pdf
|
--->BIGFOLDER/classes
|--->BIGFOLDER/classes/f3.jpg
|--->BIGFOLDER/classes/f4.pdf
|--->BIGFOLDER/classes/pdf.doc
|--->BIGFOLDER/classes/f5.ppt
|--->BIGFOLDER/Fun/
|--->BIGFOLDER/Fun/f6.jpg
|--->BIGFOLDER/Fun/f7.pdf
|--->BIGFOLDER/Fun/Movies/
|--->BIGFOLDER/Fun/Movies/f8.pdf
|--->BIGFOLDER/Fun/Movies/f9.avi
|--->BIGFOLDER/Fun/f10.pdf
|--->allpdf
|--->allpdf/f1.pdf
|--->allpdf/f2.pdf
|--->allpdf/f4.pdf
|--->allpdf/f7.pdf
|--->allpdf/f8.pdf
|--->allpdf/f10.pdf
If you want to copy all .ppt files you apply this command
mkdir ../allppt;find -name '*.ppt'|while read Filename ; do cp "$Filename" ../allppt/ ; done
I hope you got the logic if you want to search copy all .doc files.
now suppose you want to delete all .pdf files instead of copying then your command will be

find -name '*.pdf'|while read Filename ; do rm "$Filename" ; done

You may not want to delete .pdf files but you may want to delete all .ini files form some virus infection, as i have removed from my pen drive once and latter from a 80 GB harddisk of my friend when it was infected by virus.

If you know shell programming then you can add much more functionality to this little command.


12 August 2007

PIC microcontroler : Day 1

Day 1
So Here our journey is starting.
I assumes that you should have some knowledge of programing , micro-controller and digital electronics and how to turn on a computer. We are going to use PIC mico-controller (these are microchip company product). We will start form very small device. PIC10F2xx series where xx can be 00, 02, 04, 08, 20, 24.
This is a 6 pin IC (in PDIP package 2 pins are not connected)


You must go through the data-sheet of PIC10F200. you can get functionality of pin also in datasheet.
The software tool we are going to use is piklab. you can easily install in Linux by any package manager. In windows you can use MPLAB IDE. ya we will use MPLAB assembler also. see step
  • first you need to write a code in assembly language. We can latter use C language also. I have found a very good tutorial on assembly. 1 . Assembly language 2. MPASM assembler , MPLINK object linker , MPLIB object librarian USER GUIDE
  • you need to convert your asm code to hex file using MPASM or gpasm depending on plateform
  • you need to download you hex code to flash memory of micro-controller (mcu). you need to have a programmer for it and a software to drive it, we will discuss it latter. for the timing I will use software simulator for it.
Before we start programming we need to look inside it. our mcu has some 16/24 Byte data memory and 256/512 flash memory.

have you remembered about registers in processors. well our PIC10F22x has some limited register set. these register are present on data memory.
pattern of data memory or more precisely register file map is given in data sheet page 17. We have two set.
1. special function (named) regiter
2. general purpose register

in special you can see STATUS which hold many status of accumulator and various thing,
you can see GPIO register. whenever you need to put data or read data to GPIO pins (general purpose input out pins), you need to access this register. now in our devide we have only 4 GPIO. GP0, GP1 and GP2 are bidirectional and their direction must be set before using them, GP3 is in input pin only. TRISGPIO is a register which set the direction, We will not jump in to every details of everything. slowly slowly we expand our knowledge by programming exercises also.

in PIC10F200/204 have 9 bit memory address but 512x12 memory is not there for you, you can access first upper 256x12 memory only. simply for now forget about 9th bit.
in PIC10F202/206 have 10 bit memory address but 1024x12 memory is not there for you, you can access first upper 512x12 memory only. simply for now forget about 10th bit.





10 August 2007

PIC microcontroller

Hi Friends,
I am new to micro-controller's world. I am doing a course embedded systems and we have decided to go with small MCU.
In This column i will put a details of everything form the basic and and detailed projects. so keep watching it.

Most probably I will use PIC10F20x series where x can be 0, 2, 4, 6.
related links