Category — Django
Tweaking Django and pdf script progress
I have to put this up here. I was tweaking up timepass and at a particular stage when I was working on the CRUD (admin interface that django provides), I was faced with the situation of throwing in 7 BooleanFields one after the other. It looked disgusting. I then modded Django a bit to ease things out. I am not going to explain the stuff over here as I have to rush, but the code is commented well enough
from django import oldforms
from django.db import models
from django.utils.functionalimport curryclass CheckBoxManyToMany(models.ManyToManyField):
def get_manipulator_field_objs(self):
if self.rel.raw_id_admin:
return [oldforms.RawIdAdminField]
else:
choices = self.get_choices_default()
return [curry(oldforms.CheckboxSelectMultipleField, choices=choices)]
def get_manipulator_fields(self, opts, manipulator, change, name_prefix='', rel=False, follow=True):
"""
Returns a list of oldforms.FormField instances for this field. It
calculates the choices at runtime, not at compile time.
name_prefix is a prefix to prepend to the "field_name" argument.
rel is a boolean specifying whether this field is in a related context.
"""
field_objs, params = self.prepare_field_objs_and_params(manipulator, name_prefix)
# BooleanFields (CheckboxFields) are a special case. They don't take
# is_required.
if 'is_required' in params:
del params['is_required']
# Finally, add the field_names.
field_names = self.get_manipulator_field_names(name_prefix)
return [man(field_name=field_names[i], **params) for i, man in enumerate(field_objs)]
There !
Now, let me elaborate upon the pdf script that I was making to ease out stuff for my dad.
My plan is to create new ebooks out of each chapter. Each chapter is obviously going to be smaller than 1.5 MB and that should be it !
The route I am taking involves creation of a html file from the pdf file. This html is parsed and the required data obtained and so on. I promise to put up a working version soon.
I am going to spend the rest of the day reading Prashanth Mohan’s Final Year Project. See you later !
January 8, 2008 1 Comment
Post Christmas….
I am a Hindu, so what? I take every opportunity to celebrate. So I went with my dad to one of these eateries that exemplifies the “Today pleasure, tomorrow diarrhoea” category. Well I don’t actually have diarrhoea now but what happened in the morning was … well figure it out.
Later that day my dad came into my room to have a look at what I was doing. I was working on “timepass”, a web application that plans to do many things I am not too sure of (http://launchpad.net/timepass). He showed me an external drive and told me that the he was not allowed to access directories one level below the root directory of the device. He plugged it into his laptop (a gleaming Dell Inspiron) and showed me. I was stumped, FAT32 drives and no permissions ? I remember that something similar had occurred once upon a time with my iPod as well. I decided to work on this. I had two possible ideas about what could go wrong:
1. Drivelocks (we can’t do much apart from call the vendor of the drive and pray that he gives the password to us)
2. Filesystem needs repair. This could be done easily using the command “dosfsck -a <device>”.
I asked my dad about the drive. It was a Toshiba make and was the HD in his previous Compaq laptop. After this I knew what was wrong, drivelocks. I don’t know if drivelocks can be repaired with dosfsck and I decided to give it a try. I plugged it into my laptop (runs Debian remember) and it got mounted. I could even navigate as per my wish!
This leads us to conclude one thing: “Linux doesn’t give a damn about drivelocks”!
I offered my dad to do a direct dump using the dd command. I had a 200 gig maxtor and after a period of more than 15 minutes, the copying was done. I get to keep the new drive and my dad gets the previous drive. He had quite important stuff in there. Most of them pertaining to his work (designs and blah blah).
I don’t know what impact this blog has in the IT world but if Toshiba reads this, they are going to <censored> bricks.
After that I got to look at software my dad uses to design stuff. There was Staad Pro, Tekla Structures XSteel and something called DTH. He was talking about productivity as I saw him swiftly create figures that made no sense to me (he is building a port so I am not expected to have any idea about it).
I am submitting all my essays tomorrow. Man, it really gives me the jitters. There is something about this admissions process that makes me feel like “someone cares”. Is it true? Does someone care if you are a geek at 16. Does someone care if your mouth waters if you look at Apple’s 10 TB storage rack ? Does someone care if you broke both your bones and almost lost your life, prepared for the class 10 boards without going to school for a major part of the year and carried the injury to class 11?
The answer is: yes. Someone cares. Someone really important cares. I am going to click on the “Submit” button tomorrow and I feel priviliged to do so. I really cannot believe that a college from which Claude Shannon graduated is going to read my application, a college where Google finds its roots is going to read my application, or a college where Raj Reddy sits, is going to read my application. It is just too elite to think of. All I can do is thank those who have made this possible, dad, mom etc.
I am getting too emotional now and my blog posts suck if I get too emotional. I will write again later.
December 26, 2007 2 Comments
NIPL URMS
Well, argo is closed and the URMS that was made on it is pretty much of no use now. I have hence planned to host it on google code. I feel bad whenever I look the work I did on Argo. Well here’s the application I made.
December 12, 2007 No Comments
iLugHyd, Sloppy pace, Confusion.
I just returned from iLugHyderabad’s meeting. It was fun. I met a lot of interesting folks who had dabbled with the new release of Fedora. It is not like I am tempted to try out fedora but it was fun meeting the Fedora enthusiast Rahul Sundaram. Let me recollect what happened during the meet.
The venue for the meet was the astronomy building at Osmania University. The building was being renovated and I managed to whiten my navy blue coloured jacket by plainly brushing against the walls of the building. There was no electricity in the building too. We were discussing about moving to a different room when a professor who was there to attend the talk (teaches at Osmania and has been using Linux for 12 years !!) used an extension cord that somehow could span the length of two floors. The basic infrastructure needed to conduct the event was now complete. We waited for a few more people to arrive but not many turned up. Seemingly many students had exams the very next day and chose to stay back at home/hostel to study. I began discussing about Django newforms with Theju (I met him at mukt.in . He was one of those who did a project on server side validation at the google summer of code. I will take part in this when I go to college for sure. They give out some excellent projects and help in improving one’s coding skills.). Seemingly in December, django’s creators will launch newforms (or is it newforms admin?). Theju promised to teach me how to hack up the admin interface that comes with django.
Someone at the meet with long hair had a lot of troubles with Fedora 8. Seemingly his laptop wouldn’t boot into fedora and grub would get stuck at the “Loading Grub, Stage1.5″ stage. I also remember that I had some troubles with the new linux kernel way back when I used feisty. I placed a bug report here.
After that the talk began. Rahul explained about his association with linux since the days of Red Hat Linux. So automatically becomes part of the elite FOSS gang in Hyderabad.
Rahul turned out to be a jovial speaker and his speech was littered with comic examples dating back to his stint as the “font guy”, “the support guy” for Fedora and Red Hat Linux. Seemingly on one occasion, he was called up by a Fedora user from Greece who claimed that Greek didn’t look good in the Bitstream fonts but looked better in DejaVu Sans. Rahul’s reaction was “Which one is what and what looks better?”. We all had a hearty laugh at this. At the end of the meet, we all had an “introduce yourself” kind of session and there was this guy who worked at google and was all smiles. I just adore google employees. They seem to be in love with what they do and genuinely are “good” at what they do. Krish (mukt.in organizer). So we began talking. I voiced my anger at google’s choice to make us write applications using android in java and to provide an eclipse plugin to top it all. Now eclipse is a PITA. My experience with it lasted 30 minutes. 10 minutes it took to start, 10 minutes to install the pydev plugin and another 10 to close. Rahul then came in with his comment, “Some time back, your computer was considered very robust if it could run quake at 50 fps. Nowadays, if you can run eclipse at 50 fps, your box is top of the line.”. He earned another round of applause. That is the true FOSS spirit.
I did attend a Ruby on Rails session as well sometime back at TWINCLING. Mr. A.P. Rajshekhar gave a talk on ROR and it was one of the best sessions on web development (I attended one at mukt.in. It was conducted by Thyagu) that I had attended. In a span of two hours, Mr. Rajshekhar covered a lot about Ruby, MVC and also showed us a working application by the name talewiki. Mr. Rajshekhar is also writing a book on ROR and he plans to use talewiki to teach ROR. I promise you Mr. Rajshekhar that I will be the first to purchase your book.
Krish and I are coming up with a web application of our own. I will talk about it later as we are yet to come up with a working model.
I have to still figure out how to generate thumbnails for my firefox extension. I have discovered that nautilus uses a thumbnailer that picks a particular frame of a video, the first page of a file and so on. I think I will freeze the development of filerfox and do something else with firefox. I have to scout for them though.
Anyway, See you later.
November 27, 2007 No Comments
Pincode search engine and an idea
Well, the URMS at NIPL is complete and I have decided to step aside for the “web designers” to take my place. No matter how hard I try, I end up dissatisfied with my work on making templates. That doesn’t mean that I hate those websites where the creators put in hours of hardwork. I particularly like Jeff Croft’s website. The colors are not too showy and I can read the text without straining my eyes. Jeff Croft worked at LJW, the place where django was created. I suppose it comes naturally to him.
I want to improve my django skills. Recently jburd (IRC) gave me an interesting task, making a search engine for India’s pin codes. I wrote one in seconds and was immediately confronted with a problem, India is a nation with over a million town and villages, who would give me the pin codes of all these places and when would I enter them into my db?
Search engines have to operate intelligently in order to produce relevant results. I remember when someone on IRC told me about the Levenshtein algorithm and showed me an implementation in python.
I then came across an idea. English is not a scientific language. Hence we have multiple spellings for the same name. Let us pick the word “Secunderabad”. I can also write Secunderabad as Sikandarabad or Sickandarabad. All sound the same. To a person who had only heard of Secunderabad but never seen how it is spelt, using a pincode search engine would be a bit of a problem. We can then use a speech application (espeak ?) and obtain a prononciation, then we can rewrite the same in a scientific language (like Hindi, Sanskrit and other Indian languages). We could compare that to the data in our database and get an accurate result. Then use the speech application to find out the possible permutations in english and spit out the results.
I don’t know, but I might have provided myself with an idea for research when I go to college.
Oh, and by the way, I have bundled the pincode search engine here.
July 30, 2007 No Comments
First FOSS Project
I just volunteered for a free shell providing service named NIPL. NIPL stands for Nouvelles Informationzes Positives Libres. I have been assigned the task of creating a User Request Management System. I picked NIPL for the following reasons:
1. I get to serve the open source community directly or indirectly
2. NIPL users are free in the true sense of word. They give root access man !
3. NIPL is maintained by excellent devs and it would be an excellent opportunity to learn from them.
I am using django to make the URMS. Have to go now. I will write again later.
July 26, 2007 1 Comment


