01110100110101010101011101100010
Stuff
Begining Python workshop
Jan 27th
LUG Manipal is organising a workshop on python, Workshop is aimed at people interested in beginning programming with python.No programming experience required.
Details are ->
Time: 5:30 pm
Place: NLH 103
Date: 29th JAN to 3rd FEB
PS :- Slides for the workshop are available Begining Python Slides
Mobi Vision 2.0 Slides
Oct 15th
First and Second Phase for MobiVision 2.0 is long over, and we can call it a workshop well done, the slides are here
A simple python socket chat example
Jul 30th
i was trying to explain sockets to one of my friend and this is what i used, the code should be self explanatory, this is a very simple application of sockets…
download here
Creating your own service like tinyurl
May 24th
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
JavaFX and Pong
Mar 1st
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
More >
HowTo MPD with Pulse audio
Feb 13th
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.
LUG Manipal’s Python Workshop
Jan 26th
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…
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…..
MobiVision, Techtatva 08, LUG Manipal and lots more….
Oct 20th
I am posting to my blog after a long long time and a lot has happened, first Lets start with MobiVision.
MobiVision (Brain child of Subhendra Bhaiya) was a workshop conducted by people from LUG Manipal ( well not officially but everyone involved in it was from LUG Manipal ) as the name suggests it was on developing Application for mobile Plateform, basicly targeting Python for Series 60 and Android, We were expecting turnout of around 100 people and more the double turnout took us by surprise, it saw a partisipation of over 200 which comprised of guys/gals from First to Fourth year which was really amazing we even had people doing PG showing Interest, we had some trouble managing them in 2 rooms which were alloted to us but in the end every thing turned out pretty well. We had 2 Teams ready one for Python S60 and one for Android, Both teams did a great job and made Mobivision the most sucessfull Workshop in Techtatva 08.
Next was Techtatva 08 which is the annual Technical Fest of Manipal Institue of Technology, Manipal, Here again LUG Manipal was in full control ( and again not officially!!! ) we were to conduct events for the Computer / IT Catagory called ” PARAM ” and we planned to change the previously conducted events so as to make them fit in the 4 basic catagories of people –
1) ” MobiVision ” for Inovators here teams where to come up with a inovative Idea for Mobile Application and a prototype
2) ” Jour ” for Developers here teams were to make any one of the three Projects and give a Presentation and Demonstration of their product
3) ” CodeBytes ” for Programers the usual problem solving event with not so usual questions
4) ” Puzzle Mania ” for Every Day internet users comprising of all sorts of Puzzels
all the events saw good participation from all years and were prased for not having a single glitch.
I also made a Deligate and Event Registration system for managing and registering all the people coming for Techtatva 08 and also a CBT ( Computer Based Test ) system for priliminary rounds of some events, it was all basicly made in PHP and used MySQL as primary Database and was hosted on a Fedora 9 ( for those of you who dont know what it is — Its a GNU/Linux Distribution and also my Primary OS ) based server running Apache in Student Councels room because we/I were/was denined permition to host it on the main Manipal University server, they said “You are a Threat for our Network!!!” ??? which left me wonder what kind of stuff they do there and what did i do to them??? ( reason for which i got to know later ) anyways we managed to get a lab computer for using as a server, it had a AMD Athlon x3800 CPU, 80 GB HDD and 1GB RAM, which was all i needed for my work, the PC was formatted and fresh Fedora 9 was installed on it, after this all updates were applied which didn’t took much time as the connection there is not at all like I-ON and is at least 10 times faster ( well it was MAHE LAN and I-ON is WiFi but still!!! ) some changes in http.conf and iptables and it was ready. The System ran without a glitouch except when someone made the LAN cable for the server loose which made all on Registration Desks shouting but luckly everything was back online in 2-3 mins. The CBT’s also ran very good and results were decleared as soon as the alloted time was over and there were no objections.
Well this is enough for a post now 3rd Sessionals are approaching and i need to study as i screwed my 2nd sessionals, so bye
Ankur Shrivastava











