Showing posts with label Internet. Show all posts
Showing posts with label Internet. 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.

6/20/08

Simple sender/receiver program to calculate the Round Trip Time

Here are two simple programs, the one named sender and the other named receiver.
Sender is the one who want to calculate the mean Round Trip Delay for the connection between sender and receiver.
So sender sends a hundred (100) packets, sized 1byte each (a char in C programming Language), and wait to get it back from the receiver.
Now it's clear that the receiver just receives packets and send them back without any delay.
Code is after the output.

When running you will get this output from the receiver:

Connection to sender established
Receive 100 packets of 1 byte and send then back
Done
Close socket and exit

and from the server:

Sending 100 messages 1 byte each and wait for ack.
RTT = 2.65503e-05 ms
close sockets and exit


Here is the code for the receiver which is less complicated than the sender's

#include <string.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>

#define SENDER_PORT 3490
#define SENDER_IP "127.0.0.1"

int main(int argc, char *argv[]) {

int sockfd;
int rcv_num,loop_count,i;
char buf;
struct sockaddr_in sender_addr;

//open socket and connect
if( (sockfd = socket(PF_INET, SOCK_STREAM, 0)) ==-1){
perror("socket error"); // do some error checking!
exit(1);
}

sender_addr.sin_family = AF_INET;
sender_addr.sin_port = htons(SENDER_PORT);
sender_addr.sin_addr.s_addr = inet_addr(SENDER_IP);
memset(sender_addr.sin_zero, '\0', sizeof(sender_addr.sin_zero));

if ((connect(sockfd,(struct sockaddr *)&sender_addr,sizeof(sender_addr))) ==-1){
perror("connect error"); // do some error checking!
exit(1);
}

//connection established
printf("Connection to sender established\n");
//reads 100 packets of 1 byte and sends them back as ack packets
printf("Receive 100 packets of 1 byte and send then back\n");
for(i=0;i<100;i++){
rcv_num = recv(sockfd,&buf,sizeof(char),0);
if(rcv_num!=0) {
//send ack
send(sockfd,&buf,sizeof(char),0);
}
else{
perror("Receive error");
exit(1);
}
}
printf("\tDone\nClose socket and exit\n");
close(sockfd);
exit(0);
}

As you will understand if you look the code above receiver considers sender to be at ip 127.0.0.1. This is the local host. This means that these two programs (sender and receiver) runs locally. This doesn't matter. If you change the SENDER_PORT and the SENDER_IP to the real ones and you run them at two different computers in the world you will have the same output (with different RTT of course)
Well, now it's time for the senders code. I will explain both better in a while.

#include <string.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>

#define MYPORT 3490
#define SIZE_TO_SEND 1000
#define MY_IP "127.0.0.1"

int main(int argc, char *argv[]) {
int sockfd,sockfd2;
char tosend = 's'; //a char (1byte) to send to receivers
char ack;
struct sockaddr_in my_addr,rcvr_addr;
struct timeval start,end;
int sin_size = sizeof(my_addr),i,k,num_packet_sent,optval;
double t1,t2;

//open TCP socket,bind and accept RECEIVERS connections
if( (sockfd = socket(PF_INET, SOCK_STREAM, 0)) ==-1){
perror("socket error");
exit(1);
}
my_addr.sin_family = AF_INET;
my_addr.sin_port = htons(MYPORT);
my_addr.sin_addr.s_addr = inet_addr(MY_IP);
memset(my_addr.sin_zero, '\0', sizeof(my_addr.sin_zero));
//allow reuse of port
optval = 1;
if (setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR,&optval,sizeof(int)) == -1) {
perror("setsockopt");
exit(1);
}
//bind(socketfd, struct about my address,sizeofmy address);
if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof my_addr) == -1) {
perror("bind");
exit(1);
}
listen(sockfd,10);

sockfd2 = accept(sockfd, (struct sockaddr *)&rcvr_addr, &sin_size);

//connections OK
//send 100 packet of size 1 byte and for each send wait for ack
t1=0.0; t2=0.0;
printf("Sending 100 messages 1 byte each and wait for ack.\n");
for(num_packet_sent=0;num_packet_sent<100;num_packet_sent++){
if(gettimeofday(&start,NULL)) {
printf("time failed\n");
exit(1);
}
send(sockfd2,&tosend,sizeof(char),0);
optval=recv(sockfd2,&ack,sizeof(char),0);
if(optval==-1) {
perror("Receive error");
exit(1);
}
else{
if(gettimeofday(&end,NULL)) {
printf("time failed\n");
exit(1);
}
t1+=start.tv_sec+(start.tv_usec/1000000.0);
t2+=end.tv_sec+(end.tv_usec/1000000.0);
}
}
//calculate and print mean rtt
printf("RTT = %g ms\n",(t2-t1)/100);
printf("close sockets and exit\n");
shutdown(sockfd2,2);
shutdown(sockfd,2);
exit(0);
}

Now let's explain these lines.
Both sender and receiver uses the command socket() to open a socket for the communication. Receiver uses connect() with arguments a struct sockaddr_in to connect to the sender. Sender uses bind() to give the sockfd the local address so that it can then call accept and connect to the receiver. After bind() the sender calls accept() which block until somebody connects (call connect()) to the socket.
When connection is established sender send 100 packets , every one is 1byte (char tosend) and receives another one back. Double t1 sume the start times (before send()) and double t2 sums the end times(after recv()). When all 100 packets are sent RTT is calculated by (t2-t1)/100
This is better than calculate rtt for every packet and then sum them and divide by 100.

Sum ( t2i-t1i ) / 100 equals ( sum(t2i)-sum(t1i) ) / 100 for 0 <= i < 100

I don't think I have to say more. If you want to ask something just post it and I will come back to you or send me a mail.
Thank you.

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.

3/23/08

Free Web Hosting

Are you looking for FREE web space , FREE web hosting or FREE domain name for your site?
Here is a list with providers. Most of them provide free web hosting or free web domain. The list is here and I try to keep it uptodate. Please leave your comments if you know, and want to share it, any other provider and I will update the list as soon as possible. Thank you.

Δωρεάν Web Hosting

Ψάχνετε ΔΩΡΕΑΝ χώρο για τις ιστοσελίδες σας;
Εδώ θα βρείτε μια λίστα με πάροχους δωρεάν υπηρεσιών (hosting, domain, space) στο διαδύκτιο. Η λίστα αυτή βρίσκεται εδώ και προσπαθώ να την ενημερώνω με νέα στοιχεία. Παρακαλώ αφήστε σχόλια αν γνωρίζετε άλλους πάροχους αυτών των υπηρεσιών και θα τα προσθέσω το συντομότερο δυνατόν.