01110100110101010101011101100010
fedora
Weekend Project II
Aug 29th
In march i posted about a weekend project which involved controlling a small toy car using my cell phone, this is a similar one again implemented in few hours, here we are trying to play the awesome game of pong using the tilt sensor on Samsung Wave. The pong application running on Laptop is written in Qt (C++) and the application on the Phone is written using the Bada SDK.
The working is simple, the pong application running on Laptop requires phones to make a TCP connection to it. Phones just create a TCP connection to the application on PC and sends tilt sensor data to it, movement of paddles is done by the PC application based on the value it receives from the phones. It still requires better calibration and we will work on it after the exams are over (Education prevents you from doing cool things!!), there are a lot of ideas buzzing in our empty heads (according to our teachers!!) , the original idea was by Abhimanyu which we implemented.
if you cannot see the above video here and here are short demo of how it works.
PS – code and proper working for the previous and this weekend project will be posted soon!
Simple Finite State Machines in C
Apr 5th
I was having discussion about State Machines with one of my friend, regarding pro’s and con’s of implementing programs as Sate Machines, it was then that i realised there is no simple way to implement programs as Finite State Machines, so here is a very basic implementation of FSM in C
file: fsm.h contains the function definition for our FSM
Weekend Project
Mar 11th
In Dec 2009 at foss.in at the maemo stall i saw a guy control a small toy car through accelerometer on his N900, i thought of replicating that but it just remained in my mind, so last Saturday i finally decided to implement it and went straight to a toy store and bought a toy RF car, one hour of hacking and i was able to control the small car through by phone (Nokia E61i) here is the video of it working.
the concept is simple, i send commands through my phone over wifi to my laptop which controls the car remote, controlling a toy car remote is very easy with a Parallel port and few transistors but laptops don’t have parallel ports, so i used a micro-controller in between to sort that out, so now micro controller controls the car remote by acting on signals received over UART from laptop.
the working is Phone —(WiFi)—>Laptop —(USB/UART)—> Micro controller —(Relays)—> Car Remote —(RF)—> Toy Car
will post details with code sometime later
How Manipal got its first Linux (fedora) server
Jun 25th
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
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??
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
Get updates of completed torrents via SMS
Apr 6th
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
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 >
Using Apple Keyboard in Linux (Fedora)
Feb 19th
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_apple/parameters/fnmodeand F-keys will start to work properly, enjoy
Update :- update for recent kernels,
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.
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












