01110100110101010101011101100010
Archive for December, 2008
Host your Site on your own computer
Dec 29th
These days a large number of people have ADSL connections thanks to BSNL/Airtel they all have a direct internet IP, that means they can host whatevery they wish to host on the internet, It can be blog, site etc on their ip but as far a i know they are all dynamic IP’s so they keep on changing after few hours and its a trouble telling everyone you updated IP, i was trying to solve this problem for one of my friends and the solution is simple i made a simple php file which is hosted on a free php host, he sends a simple get request every 30mins to update his IP which is written to a file and stored on the server (most free hosts does not offer mysql databases, otherwise they could also be used) when someone visits the url of the free host he is redirected to his machine ip, he is running Fedora 9 as the server (but windows can also be used.. which i wont recommend if you are going to tell the world what your IP is) here is the code save it as index.php
<?php
ob_start();
$file = "ip";
if (isset($_GET['pass']) and ($_GET['pass'] == "yourpassword"))
{
$sip=$_SERVER['REMOTE_ADDR'];
unlink('ip');
$fw = fopen($file,'w');
fwrite($fw,$sip);
fclose($fw);
echo "Done";
}
else
{
$fr = fopen($file,'r');
$ip = fgets($fr);
fclose($fr);
header("Location: http://$ip");
}
ob_end_flush();
?>
you can update you IP by going to ” http://something.some-free-host.com/index.php?pass=yourpassword ” from your browser
i will recommend changing yourpassword to something no one can guess and run the following python script to update your IP every 30 mins
import urllib
import time
url = "http://something.some-free-host.com/index.php?pass=yourpassword"
while (1):
urllib.urlopen(url)
print "IP submited at", time.ctime()
time.sleep(1800)
print "submitting again"
PS – if not sites or blogs it will definitely be useful to control your torrents from anywhere, by using their web interfaces, Ktorrent, utorrent and others offers them
Perl, Django and hopefully a new blog
Dec 21st
Almost 15days have passed since my vacations and i am really enjoying it, i get great Home cooked Food, enjoy pastries and stuff form a not so far bakery can sleep for as much as i want ( which is mostly around 7-9 hrs ) spend my whole time watching Movies, Series and Learning new things and well my results are out got more GPA then what i got till now with attending around half the classes in a regular sem because of the attendances that i got….
Now talking about the Important Things, What All i have Done Till now
Perl – after asking many people about how to begin with Perl and hearing all sorts of answers i finally decided its time for me to go for it, So in Bangalore i bought myself the Llama Book and started Perl, the Llama Book from what i feel is perfect for beginning Perl it clearly explains everything and after that you have Google to help to everywhere. So i now can say happily that i know Basic Perl
And well after that i started with Django and i really like it at first MTV (Model Template View) seemed strange but i got it looks gr8, so after my new found love for Django i wanted to shift my blog from wordpress to Django but was not able to find anything that would allow me setup a simple blog, so i have started writing code for my own blog and write now trying to find a way for importing existing wordpress entries to my blog and hope to release the code as soon it starts working without a glitch and move to it, i am plannig to keep compatibility all the post urls if someone has got some link to my wordpress blog they wont break…..
Ejecting non responding drives in Linux
Dec 10th
One of the biggest (not necessarily) problems that most (new) Linux users face is the problems of non responsive drives, espically when u insert a curropt CD / DVD which refuse to come out because something is trying to access it… or the extremely slow flash drives there are some software for it in windows like Unlocker ( dont remmember the correct name scine i dont use it ) but here we dont need any specific software we have had that feature from a long time and well its as simple as 2-3 lines on terminal and its name is ” fuser ” which is basicly used to displays the PIDs of processes using the specified files or file systems. and we can easily use it for our perpose, lets take an example suppose we need to remove the non responsing CD, for that you need to be root, do
su -
or
sudo -i
then type
fuser -k /dev/sr0
or
fuser -k /dev/cdrom0
which will kill all the process accessing that particular device, now you can easily eject the by doing
eject /dev/sr0
or
eject /dev/cdrom0
and you are done.
PS - " fuser " is useful in many more ways then just ejecting drives see " man fuser " for more info



