June 25th, 2009 / 1 Comment » / by Ankur Shrivastava
It all started with a failing Student’s Teacher Feedback System, designed by few fourth year students of my college, in oct-nov 2008 the system was not able to scale and everything was reverted back to paper, it was then when i was contacted by a teacher from my Department ( Information and Communication Technology ), regarding if i can improve it.
i asked DJ if he wants to join me and after few weeks of coding there it was Manipal university’s first (working) Feedback System, when the point of hosting it came, i was surprised to find Manipal University has no Linux servers, i mean come on no Linux what are you people click sys admins, then we decided to setup our own server in the department, thus giving Manipal university its first Linux ( fedora 10 ) server.
currently it just hosts the Feedback System, but we are planning to use it as local ( internal ) fedora repository mirror, we need permission from the WiFi provider ION because almost all the students use only WiFi and not LAN, last time we tried we were denied by saying ” You are a threat to our network “, lets see how it goes this time. we will also require people to manage it but i think this can be handled very well by LUG Manipal, some pics

Fedora 10 server in Manipal

Fedora 10 server in Manipal
PS – i am looking for a way to convince them that setting up a mirror will be helpful for them as well as students can anyone suggest me how to go about it??
Posted in: Linux, college, fedora
Tags: fedora, feedback, Linux, manipal, mit, server
June 15th, 2009 / 2 Comments » / by Ankur Shrivastava
last week i gave my 250GB HDD to one of my friend and when i got it back it was filled with viruses, it was that virus which creates .exe inside every , since there were a lot of folders in the HDD ( it was 200GB full ) it was practically impossible for me to go and delete every virus in there, so i decided to make a simple script to remove these viruses here it is
Download here
PS – please be careful if you have windows programs they can also get deleted
Posted in: Special
Tags: folder, perl, virus, Windows
May 24th, 2009 / 5 Comments » / by Ankur Shrivastava
Few weeks ago i came across this article on Techcrunch which says tinyurl is worth $46Million (of course before twitter started using bit.ly as default) which made me think how hard is it to make a simple service like tinyurl and i figured out its not hard. so i used apache’s mod_rewrite to rewrite the url and forward the code to a php script ( url.php ) which will then search for the url in database and take the use to the original url and for shorting, url it is inserted into a table with a auto increment primary key and the key is converted to base36 which contains [a-z] and [0-9], making the short code…
First create a database say ’shorturl’
CREATE TABLE IF NOT EXISTS `shorturl` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`url` varchar(300) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
then create file .htaccess where you want your url to be and write
RewriteEngine On
RewriteCond %{REQUEST_URI} \/([0-9a-z]*)$ [NC]
RewriteRule ^(.*) url.php?url=%1 [L]
and to create the url we will use a simple file say create.php
<html>
<head>
<title>Url Shortner</title>
</head>
<body>
<?php
ob_start();
$host=""; //host
$dbuser=""; // database username
$dbpass=""; // database password
$db=""; //database name
$con = mysql_connect($host,$dbuser,$dbpass);
mysql_select_db("url",$con);
if (!isset($_POST['shorten']))
{
echo "<center><h3>Enter the url to shorten</h3><form method='POST'><input type='text' name='url' />
<input type='submit' name='shorten' value='Shorten' /></form></center>";
}
else
{
if (isset($_POST['url']))
{
$url=" ".mysql_real_escape_string($_POST['url']);
if (strpos($url,"http://") or strpos($url,"https://") or strpos($url,"ftp://"))
{
$url=mysql_real_escape_string($_POST['url']);
}
else
{
$url="http://".mysql_real_escape_string($_POST['url']);
}
$q="select * from url where url='{$url}'";
$res = mysql_query($q,$con);
$row=mysql_fetch_row($res);
if (!$row)
{
$query="insert into url set url='{$url}'";
$res = mysql_query($query,$con);
}
$query1="select id from url where url='{$url}' limit 1";
$res=mysql_query($query1,$con);
$row=mysql_fetch_row($res);
echo "shortened url is http://yoursite.com/".base_convert($row[0],10,36);
}
}
ob_end_flush();
?>
</body>
</html>
then our url.php file
<?php
ob_start();
$host=""; //host
$dbuser=""; // database username
$dbpass=""; // database password
$db=""; //database name
$con = mysql_connect($host,$dbuser,$dbpass);
mysql_select_db($db,$con);
if (isset($_GET['url']))
{
$query="select * from url where id ='".base_convert(mysql_real_escape_string($_GET['url']),36,10)."'";
$res = mysql_query($query,$con);
$row=mysql_fetch_row($res);
header("Location: ".$row[1]);
}
ob_end_flush();
?>
Download here
Posted in: Stuff, fedora
Tags: howto, service, tinyurl
April 6th, 2009 / 4 Comments » / by Ankur Shrivastava
This Sunday when i was giving DBUS a look and thinking about all the cool things possible with it, one of my friend came asking how can he control his torrents from anywhere and i thought controlling is ok, do you want SMS updates??, i fired up qdbusviewer and there it was a simple way to get sms notifications of finished torrents using well twitter and ktorrent, so here are the steps
1) setup your cell phone to recieve SMS updates in twitter,
2) get one more twitter account lets say ktorrent, follow ktorrent and turn device updates on,
3) now save the script below say as torrenttwit.py
4) now enter this ktorrent account username and password in the script below,
5) start ktorrent if not already started, now run the script by typing “python torrenttwit.py”
import dbus,base64,urllib2,urllib
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)
username="username"
password="password"
def tweet(msg):
request = urllib2.Request('http://twitter.com/statuses/update.json')
request.add_header('Authorization', 'Basic %s' % base64.encodestring('%s:%s' % (username,password))[:-1])
request.add_data(urllib.urlencode({'status': msg.encode('utf-8')}))
opener = urllib2.build_opener()
req= opener.open(request)
s = dbus.SessionBus()
kt = s.get_object("org.ktorrent.ktorrent","/core")
def update(k):
torrent = s.get_object("org.ktorrent.ktorrent","/torrent/"+k)
name = torrent.get_dbus_method("name","org.ktorrent.torrent")
tweet("ktorrent: finished " +name())
kt.connect_to_signal("finished",update)
import gobject
loop = gobject.MainLoop()
loop.run()
you are done, now whenever a torrent finishes the script will twit and you will receive an SMS update
enjoy
Posted in: Linux, Special, fedora
Tags: dbus, ktorrent, Python, sms, torrent, twit, twitter
March 1st, 2009 / 1 Comment » / by Ankur Shrivastava
There was a workshop conducted by engineers form SUN in our college regarding JavaFX, which went quite well. I was planning to start with JavaFX but as there was no Official release of any Linux SDK, it kept me back but this semester i had to install Windows because of my University which wants me to use Visual Studio for my mini project this semester, so as i had Windows (unwillingly) on my system i planned to go and attend this JavaFX workshop.
From what i have learned in these two days, JavaFX looks promising for developing Rich Internet Applications, the language is somewhat a mixture of JavaScript and Java. With Type Inference , Audio/Video support etc making it very easy to use and create applications with.
In the workshop after every thing was over we were asked to make a simple application in JavaFX, so here is my code for a Simple pong game in JavaFX
the resolution is set to 1440×900 you can change it to your resolution in the code
Read more…
Posted in: Stuff, fedora
Tags: javafx, manipal, mit, pong
February 19th, 2009 / 6 Comments » / by Ankur Shrivastava

My Apple Keyboard
Few Days Ago i received my
Apple Keyboard and i am enjoying typing on it, but having to hold down the Fn key then tap one of the F-keys to get F-keys working was irritating.
a simple solution to get it working just add this to your /etc/rc.local file
echo 2 > /sys/module/hid/parameters/pb_fnmode
and F-keys will start to work properly, enjoy
Posted in: Life, fedora
Tags: Apple, F key, fedora, Fn, keyboard, Linux
February 16th, 2009 / 43 Comments » / by Ankur Shrivastava
a few days ago ION (WiFi provider in Manipal University) started an ISA based proxy using NTLM authentication, which according to them was a client install!!! some people were facing problem with it, like their browsers were asking for authentication (login) again and again, and repositories were not working on Linux.
So here is a simple screencast with solution for this problem it works great in Linux (esp. Fedora) i have also included configuring yum here, if someone wants to use apt-get (debian/ubuntu) they can do
export http_proxy=http://127.0.0.1:5865
Ok coming to the main point, go and download http://sourceforge.net/projects/ntlmaps/ and then watch the video here
People on windows can install python from here and then follow the steps
ION proxy problem solved
Note:- If You face any problem please post back here….
PS:- every thing in Text form coming soon… (i am lazy)
Posted in: Linux, Special, college
Tags: fedora, ION, Linux, login, manipal, problem, proxy
February 13th, 2009 / 3 Comments » / by Ankur Shrivastava
A Little background, i just shifted to mpd from Amarok 2.0 somewhy i dont seem to like Amarok 2 but thats a different story, For those who dont know MPD s a flexible, powerful, server-side application for playing music. which runs as a daemon and has a lot of front ends for it, Sonata being a popular one.
now coming to the point i use Fedora 10 and it has Pulseaudio by default, now the problem is i some time get “NO Read Permission” in Sonata and then mpd would stop working, in mpd.log file i will find “Error opening ALSA device “hw:0,0″: Device or resource busy” error, which means this is an pulseaudio permission issue, to solve it we need to change the mpd.conf (/etc/mpd.conf) to
audio_output {
type "pulse"
name "My Device"
device "hw:0,0" # optional
format "44100:16:2" # optional
}
then we need to add
load-module module-native-protocol-tcp auth-anonymous=1
to /etc/pulse/default.pa which gives everybody permission to use pulseaudio and thats it.
Posted in: Linux, Stuff, fedora
Tags: alsa, audio, daemon, mpd, music, player, pulse, sonata
January 26th, 2009 / No Comments » / by Ankur Shrivastava

Python Workshop Poster
LUG Manipal is organising a workshop on Python, which is a dynamic object-oriented programming language that can be used for many kinds of software development. It runs on Windows, Linux/Unix, Mac OS X, OS/2, Amiga, Palm Handhelds, and Nokia mobile phones. It comes with extensive standard libraries, and can be learned in a few days.
The workshop requires no prerequisites, even knowledge of C is not required, it is aimed at people interested in beginning programming with Python.
There is no charge for the workshop and no registration is required, everyone is invited.
People using Windows are requested to Install the Following Software before coming to the workshop
1) Python 2.6.1 from here
2) Notepad++ from here
Note: These will also be distributed on the first day of the workshop, If you are not able to install/download them you can get them there…
Posted in: Stuff
Tags: lug, manipal, Python, workshop
December 29th, 2008 / 2 Comments » / by Ankur Shrivastava
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
Posted in: Stuff
Tags: computer, home, hosting, ip, server, site