Showing posts with label Computer Tips. Show all posts
Showing posts with label Computer Tips. Show all posts

2/23/10

How to view passwords behind asterisks ****

Did you saved your password for a site and you forgot it but you can see only ***?
Fortunately is very easy to see your password. How?

Step1: Copy the following JavaScript code.
Step2: Open the site in a new browser window.
Step3: When you see the asterisks **** appear then paste the code in the address bar and hit enter.

Voila. You should now see your forgotten password.
Javascript code:

javascript: var p=r(); function r(){var g=0;var x=false;var x=z(document.forms);g=g+1;var w=window.frames;for(var k=0;k<w.length;k++) {var x = ((x) || (z(w[k].document.forms)));g=g+1;}if (!x) alert('Password not found in ' + g + ' forms');}function z(f){var b=false;for(var i=0;i<f.length;i++) {var e=f[i].elements;for(var j=0;j<e.length;j++) {if (h(e[j])) {b=true}}}return b;}function h(ej){var s='';if (ej.type=='password'){s=ej.value;if (s!=''){prompt('Password found ', s)}else{alert('Password is blank')}return true;}}

Javascript code with line numbers

javascript:
var p=r();
function r(){
var g=0;
var x=false;
var x=z(document.forms);
g=g+1;
var w=window.frames;
for(var k=0;k<w.length;k++) {
var x = ((x) || (z(w[k].document.forms)));
g=g+1;
}
if (!x) alert('Password not found in ' + g + ' forms');
}
function z(f){
var b=false;
for(var i=0;i<f.length;i++) {
var e=f[i].elements;
for(var j=0;j<e.length;j++) {
if (h(e[j])) {
b=true
}
}
}
return b;
}
function h(ej){
var s='';
if (ej.type=='password'){
s=ej.value;
if (s!=''){
prompt('Password found ', s)
}
else{
alert('Password is blank')
}
return true;
}
}

Here are some screens to see how it works.
I used the facebook log in page for the example.
Step1:

Step2 and Step3

I hope this helped you find you forgotten passwords.

6/6/09

How to create a cool Button for your website

With this post I will show you how to create a cool button to use in your webpages or anywhere you want for free!
In my I case I wanted to add a download button for the code parts I post here.

Step1:
Go to Cool Text Graphics Generator
And go down to Choose a Button Design and select the button you like

Step2:
Write your text and select the disired fonts and colours.
In my case the text was "DOWNLOAD".
Filled the colours and selected Text Offest Y = -5 (move the text 5 pixels up from the center)
For Mouse over I selected Glow.
Now hit the button "Render Button"
Here you see two images. One for the normal button and one for the mouseover trigger.
Just save/download the first image. e.g. mybutton.png
Mine is




Step3:
Click "Edit this logo" and change Text Offest Y to 0 and click again "Render Button"
Now save the second image. e.g. mybuttonMouseOver.png
Mine is


Step4:
Now we have the two images we need. We just have to upload them somewhere.
There are a lot of free web host and space providers for your files. Just choose who you like.
Let's say you uploaded the two pictures to the address http://myurl/

To display the picture you write the following html:

<img src="http://myurl/mybutton.png" border=none
onmouseover="this.src='http://myurl/mybuttonMouseOver.png';"
onmouseout="this.src='http://myurl/mybutton.png';" />


Step5:
Wait a minute here... We are not done. We just show the picture without any link...
Fortunately is easy to add link to the above picture. Let's say you want a link to http://mylink
then add before the <img...
<a href="http://akomaenablog.blogspot.com"> and at the end close it by adding </a>

That's it! Now you have a cool button linking anywhere you want like my cool Download button!


This is a test button


Tip:
Use alt tag to show some text if picture is not available. e.g.
<img src="http://myurl/mybutton.png" alt="Download The Code" ....

Thank you for reading my posts. Any comments are appreciated

5/31/09

How to display source code with line numbers into a Blog

Today I realized that it will be better to have line numbers shown with the parts of code I publish into this blog.
I tried with google but didn't find any "easy" way to do it.
So I figured out my way which I am going to describe here!
First of all I wanted to show line numbers for the code but I also wanted the visitors to be able to copy the code without the line numbers.

As I'm using the <pre> tag to show my code I wrote a JavaScript function which will get the pre tags and change their innerHtml.

Here is the function:

function showLineNumbers() {
/************************************
* Written by Andreas Papadopoulos *
* http://akomaenablog.blogspot.com *
* akoma1blog@yahoo.com *
************************************/
var isIE = navigator.appName.indexOf('Microsoft') != -1;

var preElems = document.getElementsByTagName('pre');
if (preElems.length == 0) return;
for (var i = 0; i < preElems.length; i++) {
var pre = preElems[i];
var oldContent = pre.innerHTML;
oldContent = oldContent.replace(/ /g,"&nbsp;");
var strs = oldContent.split("<br>");
if (isIE) {
strs = oldContent.split("<BR>");
}

oldContent = oldContent.substring(4); //remove the 1st <br>
var newContent = "<table><tr>";
newContent = "<td bgcolor='#d4d0c8'>";
for(var j=1; j < strs.length - 1; j++) {
newContent += j+".<br>";
}
newContent += "</td><td> </td><td>";
newContent += oldContent;
newContent += "</td></tr></table>";

pre.innerHTML = newContent;
}
}

I saved the above in a file let's say showLineNumbers.js and uploaded somewhere.
Let's explain the code:
Line7: Check if browser is Internet Explorer
Line9: Get all the pre elements
Line13: Get the html inside the pre tag
Line14: Replace all the spaces with the sequence "&nbsp;"
Line14: Remove the first <br> from the inner Html
Line15-18: How many lines are in the pre tag (depending on browser)
Line21-22: Html code to create a table , row and a cell with background colour = #d4d0c8 (You can change it if you don't like it)
Lines23-25: Fill the cell with the numbers 1 till the lines of pre tag
Line26-28: Add the old content in the next cell
Line30: Set the new html code as the code for the tag element

Notice that you can copy the code without the line numbers if you want. You just copy the right cell of the table! That's something I really wanted. Visitors can copy only the code!

After that I had to link the code with my template.
How?
Log in to Blogger - Select Layout and then Edit HTML
Now add before the </head> the line:
<script src='http://..../showLineNumbers.js' type='text/javascript'/>

and now we have to call the function in the showLineNumbers.js so we add before the </body>
<script type='text/javascript'>
showLineNumbers();
</script>

Preview template and if it's ok save it. Remember to backup your template before changes.

Tip1:
If you use pre tag for other purposes too or you use other tag you defined in a css file for your code
then edit the javascript function for your needs.

For example if you defined the tag code in your css file and use it inside a pre block then you add
these lines to the function at line 12:

var code = pre.getElementsByTagName('code')[0];
if (code == null) continue; // no code; move on

Tip2:
You can use the tool postable to replace any characters that create problem with html.

Tip3:
I tested the above code with Another Computers Blog and firefox 3.0.10 and Internet Explorer 8 and worked fine.

I hope this will help you. I am waiting for your comments.

5/25/09

My First Program in C Programming Language

Programing in C is not that difficult if you know the basic rules.

I'll show you how to create a simple program in C.

First of all open a text editor(kate,kwrite,vi,whatever you want). To compile the file I will show you, you will need to have gcc installed in your pc. If you are on Linux you open the software management,select gcc and install it. If you are on Windows I suggest you use a C developing program like Dev-Cpp witch is free.

If you installed Dev-Cpp on Windows or gcc on linux just do the following.

Open Dev-Cpp or a text editor and create a new empty file and save it as myfirstcprogram.c

Now first you have to include the stdio (standard library for input/output) so write in the first line

#include <stdio.h>

The next step is to write the header of the main function,open brackets {} and write your code.

This is your first program and I'm going to explain it.


#include <stdio.h>
int main(int argc, char *argv[]) {
int a,b;
printf("give number a : ");
scanf("%d",&a);
printf("give number b : ");
scanf("%d",&b);
printf("%d %d = %d\n",a,b,a b);
exit(0);
}

Now, What does the above code do?

Line 1: include the stdio library(explained above)

Line 2: main function from where your program will start execution

Line 3: we say that we have two integers named a and b

Line 4: print at the desktop the message give number a

Line 5: read the number entered. the function scanf waits until enter is pressed

Line 5 and 6 : do the same as 4 and 5 to read the number b

Line 7: prints the message number a + number b = a+b

Line 8: the program ended successfully

Now that you wrote the above code you have to compile it.

In Linux in the directory you saved the file type in the Konsole

gcc myfirstcprogram.c -o myfirstprogram

in Windows from the Dev-C++ menu select exectute - compile.

In windows open command prompt windows (start - run -cmd - ok)

use cd command to go to the directory you saved it.

In windows type myfirstprogram and press enter

and in Linux type ./myfirstprogram

Now you see the message " give number a : " type a number and press enter and you will see the same message for the number b so do the same again.

After that you will see the result : a + b = sum

Example of output:

give number a : 3

give number b : 4

3 + 4 = 7

That's it. You wrote and compiled your first program in C!!!

6/17/08

C Program to execute shell script

As I promised in my previous post Suse Linux View CPU speed and Hard disk/CPU temperature I am back to publish my little C program which executes the script. Actually I extended it a little so it can execute any script witch is given as argument and it is located in the same directory with the executable (after compiling the code below).

Well,
The first think needed was how to execute a script.
I first though was fork() and execv().
But after a while I remember that I could use the command system() with argument the script path.

The second think I needed to know was the directory path of execution.
This isn't that difficult, you can have the directory path with the command getenv("PWD");

Here is the first version of my little program witch executes only the script in Suse Linux View CPU speed and Hard disk/CPU temperature post.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAXPATH 127
int main(int argc,char* argv[]){
char *path = malloc(MAXPATH);
path = getenv("PWD");
if(path!=NULL) {
strcpy(path+(strlen(path)),"/temperature");
}
else {
printf("Couldn't find script\n");
exit(1);
}
printf("Executing script : %s\n",path);
if(system(path)){
perror("error\n");
}
}

After compiling the above and executing you get the output:

Executing script : /blabla/blabla/temperature
current CPU frequency is 798 MHz (asserted by call to hardware).
CPU Temperature = 51
Hard disk Temperature = 53

Cool isn't it?
But it wasn't really useful to exec the program every time to see the results...
So I modified it again to take as argument two integers.
The one was how many times to exec script and the other how many seconds to sleep between executions.
After that I told my self, why don't you make it to keep a log file for you?
So I did. I added ability to print time (to see how see the code below), and to run in a infinite loop if repeat times = -1.
I didn't make a file cos I am a little lazy, I just used the operator > to redirect output to a file!!!
And after that I though it would be useful to others if it was able to exec any script, so I modified it again to take the script name as argument.

Finally here is the final version (for me at least):

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#define MAXPATH 127
#define DEFAULTVALUE 5
int main(int argc,char* argv[]){
if (argc!=4 && argc!=2) {
printf("Usage : \n %s \"script file\" \"sleeptime in sec\"
\"repeat times\"\n",argv[0]);
exit(0);
}
char *path = malloc(MAXPATH);//MAXPATH chars
path = getenv("PWD");
if(path!=NULL) {
strcpy(path+(strlen(path)),"/"); //add / to the end
strcpy(path+(strlen(path)),argv[1]); //add the script file to the end
}
else {
printf("Couldn't find path\n");
exit(1);
}
int repeat,sleep_sec,i;
if(argc==4) {
sleep_sec = atoi(argv[2]);
if(sleep_sec<0) sleep_sec = DEFAULTVALUE;
repeat = atoi(argv[3]);
if(repeat<0 && repeat!=-1) repeat = DEFAULTVALUE;
}
else {
repeat = DEFAULTVALUE;
sleep_sec = DEFAULTVALUE;
}
i=0;
time_t t;
if(repeat!= -1) {
printf("Executing script : %s %d times every %d seconds\n",
path,repeat,sleep_sec);
}
else {
printf("Executing script : %s every %d seconds\n",path,sleep_sec);
}
while( repeat == -1 || i<repeat) {
sleep(sleep_sec);
time(&t);
printf("\t%s", asctime(localtime(&t))); //print current time
fflush(stdout); //force write date and time
if(system(path)){ //execute script
perror("error\n");
}
i++;
}
printf("\n");
return 0;
}

And the output looks like that:

:/blabla/blabla # ./temperature2
Usage :
./t2 "script file" "sleeptime in sec" "repeat times"
:/blabla/blabla # ./temperature2 temperature 2 3
Executing script : /blabla/blabla/temperature 3 times every 2 seconds
Tue Jun 17 15:38:39 2008
current CPU frequency is 798 MHz (asserted by call to hardware).
CPU Temperature = 50
Hard disk Temperature = 52
Tue Jun 17 15:38:41 2008
current CPU frequency is 798 MHz (asserted by call to hardware).
CPU Temperature = 51
Hard disk Temperature = 52
Tue Jun 17 15:38:43 2008
current CPU frequency is 798 MHz (asserted by call to hardware).
CPU Temperature = 51
Hard disk Temperature = 52

:/blabla/blabla #

Now you can use it like that to keep a log file:

:/blabla/blabla # ./temperature2 temperature 30 -1 > temp_log_file.txt &
16716 <--- this is the pid of the new proccess.
:/blabla/blabla #

Now it is running in the background and you will notice the file temp_log_file.txt in the directory.

To stop the process use:

kill 16716

replace 16716 with the correct pid. If you don't remember it use ps to find it.
You may don't want to kill it as it only uses about 1kb of memory...
After all OS will send the kill signal at shutdown!

I forgot to show you my log file. Here it is.

Executing script : /blabla/blabla/temperature every 30 seconds
Tue Jun 17 15:55:04 2008
current CPU frequency is 2.00 GHz (asserted by call to hardware).
CPU Temperature = 51
Hard disk Temperature = 52
Tue Jun 17 15:55:34 2008
current CPU frequency is 798 MHz (asserted by call to hardware).
CPU Temperature = 51
Hard disk Temperature = 52
Tue Jun 17 15:56:04 2008
current CPU frequency is 798 MHz (asserted by call to hardware).
CPU Temperature = 51
Hard disk Temperature = 52
Tue Jun 17 15:56:35 2008
current CPU frequency is 2.00 GHz (asserted by call to hardware).
CPU Temperature = 51
Hard disk Temperature = 52

I hope you like. Thank you for visiting and reading my posts.
Comments appreciated.

Summer Computer Tips

#1 – Summer Computer Travel
Holiday travelers should be on alert when arriving home from long weekends, such as the Fourth of July, a popular time for computer viruses to spread.

Most computer users have a tendency to turn off their computers when away on trips, which means you’re not getting newly-released anti-virus patches or anti-spyware updates; the two most common areas that cause computers problems. We recommend you update anti-virus and anti-spyware scans before opening e-mail or going online after an extended absence.

We consistently see an increase in calls for virus related problems immediately following long weekends. Avoid the problems altogether by updating your security software before using your computer. For a free listing of viruses, spyware threats and trends, visit: www.VisitingGeeks.com/downloads.htm

#2 -- Should You Leave Your Computer Running?
One question we hear frequently is, "Should I leave my desktop computer on or turn it off?"
There are 2 schools of thought…
Turning it on and off numerous times during the day subjects the microcircuits to flexing and fatigue due to change in temperatures. Over time this could lead to a break in the circuitry and result in system failure.
Leaving the computer on all the time puts excess wear on the mechanical components (the hard drive spindle motor and cooling fans).
Best compromise. First user in the morning turns it on; last user turns it off.
We leave our desktops on all the time allowing for scheduled utility tasks to run during overnight hours. We also restart the systems (to flush the RAM and reset the operating system) on a regular basis and routinely remove the case covers to clean out any dust that may have accumulated, especially around the fans and screens.

#3 -- Stop Popups!
Never click inside the window of a popup. Instead, close it by clicking on the X in the upper right corner. Many people are fooled into installing spyware applications by popups that promise to clean their system. If you receive a message saying it can help, assume it’s spyware and don’t click!

About the author:
Sharron Senter is co-founder of http://www.VisitingGeeks.com- an on site computer repair, security and networking company serving north of Boston, Southern NH and Maine. Visiting Geeks’ technicians are crackerjacks at squashing viruses, popups and securing and making computers perform faster. Learn more about Sharron at http://www.SharronSenter.com
Circulated by Article Emporium

6/10/08

Use your gmail space as a local drive to store your files

How can I use my Gmail space to save any file I want?
The answer is very very simple and exciting!!!!
Download and install GMail Drive Shell Extension
After installing open My Computer folder and you will see another drive appear named GMail Drive as shown in the image below.
You can use it as a normal drive (like C:\)!


Double click to open and you will get a window telling you to login.
Fill in your google account user name and password and click OK.


After this you will see a new window like the one in the picture below and then an opened window where you can paste any files you want.


If you use it you will notice that you get a new mail in your inbox for every file you paste.

If you don't like it there is a solution.

Go to your gmail and click Settings (up right)
Go to the tab Filters and select Create a new filter
To the Subject write GMAILFS (leave others blank)
and click Next Step >>
Tick Skip the Inbox (Archive it) and Mark as read (and any other you want)
If you want to add a label (I suggest you do)
select Apply the label: Choose Label... and from the drop down list
select a label you already have or New Label... and in the pop -up window enter the label you want(e.g. my_files)

Finally click Create Filter

If you done the above steps right you won't get a new mail every time you add a new file to your GMail Drive!
You can see these new mails in the folder All Mail and also in the folder Starred if you selected Star it before.

Also GMail Drive Shell Extension bypasses the limitation of storing .exe files or other formats by renaming the file as filename.exe_renamed
This don't affect you in any way because you can see/execute it normally in/from your new drive.

Enjoy your new Drive and also keep in mind that what you're doing may violate Gmail's TOS, so you may want to register another account...
I'm expecting your comments.

6/5/08

Suse Linux View CPU speed and Hard disk/CPU temperature

I have a laptop which sometime goes really hot and I wanted a simple way to be able to view CPU and Hard disk temperature. I' m on SUSE 10.3 and I tried installing LM-sensors but no sensors were detected. After a very little search I found that you can view the CPU speed by using the cpufrequtils so I installed the package using Yast and executed cpufreq-info.
Here is the output:

cpufrequtils 002: cpufreq-info (C) Dominik Brodowski 2004-2006
Report errors and bugs to http://bugs.opensuse.org, please.
analyzing CPU 0:
driver: acpi-cpufreq
CPUs which need to switch frequency at the same time: 0
hardware limits: 798 MHz - 2.00 GHz
available frequency steps: 2.00 GHz, 1.60 GHz, 1.33 GHz, 1.06 GHz, 798 MHz
available cpufreq governors: conservative, userspace, powersave, ondemand, performance
current policy: frequency should be within 798 MHz and 2.00 GHz.
The governor "ondemand" may decide which speed to use
within this range.
current CPU frequency is 798 MHz (asserted by call to hardware).

I was a little excited but I wanted to view the CPU and the hard disk temperature too.
I found that I could see CPU temperature with the command:

cat /proc/acpi/thermal_zone/THRM/temperature

and the hard disk temperature (and some other stuff if you don't use grep) with

smartctl -d ata -A /dev/sda3 | grep -i temperature

where sda3 is my hard disk partition where linux are installed but actually it doesn't matter. ( I think :-P)

Now we know the commands and we have the tools we need.
But hold on a second, Can't we make it better?
Of course we can, we are talking about computers here!
So I wrote this simple shell script

cpufreq-info |
grep -i "current CPU frequency";
cat /proc/acpi/thermal_zone/THRM/temperature |
awk '{ printf(" CPU Temperature\t= " $2"\n") }';
smartctl -d ata -A /dev/sda3 |
grep -i temperature |
awk '{ printf(" Hard disk Temperature = " $10"\n") }'

and saved it in a file named temperature.
I gave it execution permission using
chmod +x temperature
and I was able to see the CPU speed and temperature and the Hard disk temperature too
by using
./temperature
and that's it.
This is my output.

blablabla/Temperature # ./temperature
current CPU frequency is 798 MHz (asserted by call to hardware).
CPU Temperature = 51
Hard disk Temperature = 54

blablabla/Temperature #

Yeap, a little hot, but it can be hotter so it's ok... :-P
After that I wrote a little C code to have the script executed
from a program but I will explain it in another post very soon!

I hope this work for you too.
Thank you all for visiting,reading and posting your comments.

5/27/08

Microsoft Word 2003 does not print page border

As the title says today I had a problem with Microsoft word. The page border wasn't printed correctly. Here are the steps to correct it(At least worked for me)
Go to:
- File menu
- Page Setup...
- Select the tab Paper
- Down the Paper Size select Custom Size
- and set Width = 21cm and height = 29cm
- Down to Preview select Apply to Whole Document
and click ok

That worked for me, the page border was printed correctly. I hope this work for you too.

3/14/08

Read and Write Windows Partitions From Linux

First of all windows uses FAT32 and NTFS file systems. FAT stands for File Allocation Table. Actually it is a table of information about the hard disk blocks. But the size of any table in computers can not be unlimited. With FAT32 users can not store files larger than 2GB. This cannot change because that's the way the system was designed. You can read more about FAT from wikipedia here.
Now let's come to the point. Linux can read ntfs partitions but cannot write them. The solution is not that easy as Read and Write Linux Partitions From Windows.
First you will need to download the ntfs-3g from it's homepage here.
After downloading ntfs-3g you follow the well known procedure of configure , make , make install . If compile fails you probably don't have FUSE (Filesystem in USErspace) installed or you have an old version. FUSE can be downloaded for it's homepage here. You can follow the previous procedure to install it. If you are with Gentoo you can install ntfs3g and FUSE with these simple commands:

echo "sys-fs/ntfs3g" >> /etc/portage/package.keywords
echo "sys-fs/fuse" >> /etc/portage/package.keywords
emerge ntfs3g fuse

The two first commands write to the file specified and the third download and install ntfs3g and FUSE.
Very simple isn't it? Wait a minute, we are not over. To use the new driver we type the command:

ntfs-3g /dev/hda3 /mnt/windows -o uid=xxxx, gid=yyyy

This command will mount the hda3 partition to the directory windows and give owner rights to user with id xxxx and the group with id yyyy.
Alternately you can edit fstab for autostart. The line you must enter in fstab to have the above command autostarted is:

/dev/hda3 /mnt/windows ntfs-3g uid=xxxx,gid=yyyy 0 0

Lastly if we want users without root rights to be able to execute ntfs-3g we use the chmod command. e.g. chmod xxxx /usr/bin/ntfs-3g
For help about chmod type man chmod

Read and Write Linux Partitions From Windows

How can i read linux partitions from windows is the question a lot of windows and linux users have. The answer is very simple for that. Ext2 Installable File System for Windows is free and can be downloaded from it's homepage which is http://www.fs-driver.org.
It's a really cool program.

But if you are interested in this you are probably interested in learning Read and Write Windows Partitions From Linux.

3/3/08

A "secret" about Barcodes

Did you ever wondered what barcodes mean?
I 'll not say much.
The most common barcode systems are two. EAN and UPC.
EAN meaning European Article Numbering System and is used in most countries including all Europe countries and other.
UPC stands for Universal Product Code and is used in USA and Canada.



This is a EAN bar code which i don't know if it's in use or no but it's okay to tell what I want.
As you noticed it has black and white lines and also some numbers.
The lines are read by machines called Bar Code Readers. But numbers can be read by anyone.
What do these numbers mean?
The meaning is very simple.
#0 and #1 show the product origin and the number coding system of the barcode.
#2 - #6 are the Manufacturer code
#7 - #12 are the product code
#13 is the checksum. It is used to check if the other number were read right. How is it calculate?
To calculate it you simply calculate the sum of even placed numbers (let's say it A) and the odd placed numbers (let's say it B).
Then you find C = A + 3 * B.
The #13 number is the number which you add to C that (C+#13)/10 = 0.
Actually is C%10 (modulo).

Please post any comments.