I had mentioned last month that I am working on a bookmarker. Yeah I am still working and it is progressing. The search page is ready. I am using a work-around for adding the bookmarks and categories till the bookmark add page is ready. But I am happy with the work so far as it is becoming what I wanted although a bit slower due to lack of time. Here are some screenshots of working search page.
The search box has an autocomplete for giving suggestions for categories. It will give suggestions as per added categories. Pressing up down keys lets you navigate the categories and when you press enter the category is added on the page alongwith all bookmarks.
Below are some screenshots.
There is currently not much bookmarks added so only two categories came in autocomplete for search and one bookmark was added when category was chosen.
I forgot to mention earlier that the little cross in red lets you delete the category and the bookmarks tagged with the category. Obviously needed.
Making Graphical User Interface(GUI) can be really attractive to many people. I had also been really interested in making GUIs and after using Visual Studio Express briefly for a project I could not forget the ease with which it allowed someone to make GUIs. So in Python I was interested in making GUIs. I had looked at many choices starting with Tkinter the default Python GUI toolkit. Believe me you don’t want to use it as it does not have a decent WSIWYG editor for building the GUIs. After failing to get anything from TkInter I looked at wxPython but it supported Python 2 only and last time I checked it’s Python 3 support was a Work-In-Progress.
PySide and PyQt looked promising as PyQt Designer is a decent WYSIWYG editors but PyQt needs a commercial license and PySide is kinda dead – community support and tutorials.
Kivy is said to be cross-platform and it has a good tutorial – official documentation has a tutorial for making a game and it has a WIP editor also. I think it needs a little time to mature a bit but using it even now can give you a decent toolkit for making GUI. As per the website it supports Android also so many will find it really attractive.
Django is one other choice. Although it is a web framework but using it can also give you a decent GUI. Just check out its tutorial for the admin website.
So I had decided that I will do the Python2 to 3 migration of my code base in April itself and I am glad that I was able to do it by 12th April. Solutions to codechef are still present but I decided to leave them be. If I restart online competitions again then I’ll think about them.
I have been thinking about making a BookMarker. I usually keep a lot of BookMarks and my bookmark bar becomes so messed up that I am just unable to arrange them properly. Yeah I like to keep things clean. I have folders inside folders inside in my bookmark bar… you can probably see how many bookmarks there are. It’s just that currently browsers do not allow good enough management of bookmarks. It gets tough. So I thought to make a bookmarker.
So how to manage bookmarks in a better way? Tags and proper search options. Let everything be flat(or in folders) and let there be tags for managing and searching Links. I understand that there are already many online ways to manage bookmarks but I like to try such things out. Also I have some other related ideas so I thought I would be able to use them if I can control this. Why not try?
I have looked at different ways to make this – PySide, Kivy, django.
I have given up on PySide. I am totally fed up with the documentation that it has. Although there is a really good designer for making the UIs but still the lack of documentation totally puts me off. It is just a collection of links from over the internet so far.
Kivy is looking good and I was seriously considering to use it for this but as this is related to browser and using django will keep it closer to browser. Also a simple startup script can start the browser with the bookmarker up and running.
I had decided that I will port my code from Python 2 to Python 3 and with the help of PyCharm the refactoring that I wanted to do was going completely smoothly. I decided in the middle to try something new. I thought when I was restarting Python then maybe try something new.
While doing this I hit Python 3 limits again. The library support is still not as good as for Python 2. The first problem that I faced was with mechanize library. That was when I was trying to get some automation scripts done for logging into websites as per a schedule. Everyone wastes a lot of time online and I wanted to control it. Had the schedule but just opening websites by webbrowser module was not good enough. Why not use Python to login also? Mechanize was just what was needed. But it didn’t support Python 3. Shit. I found a solution to that. Using Selenium I did a test run and was able to login into http://projecteuler.net/ using my username and password. That I can work with now. But still mechanize might have been easier to work with.
Just 2 days back I had the idea of trying a bit of AI. Maybe a small bot or something? Natural Language processing for intelligent answers maybe? Maybe some simple image recognition. Just the flight of thoughts that come and go every now and then. These are not like anything that I have tried before but what’s the problem with trying? I decided to go with Natural Language processing. Shit again. NLTK – the library needed for this had support for Python 2 only.
I was left thinking whether the advice that I got on Python mailing list for using Python 3 for new software actually good? Why actually did I change to Python 3? UNICODE is not something that I have even messed with once in Python. So why? I installed Python 2 but pip was missing. That’s a good thing that they did in Python 3,4, not that it actually helps with half of things not supporting Py3.4 yet.
Anyways I just noted down the ideas that came and decided to thing a bit more before going further. Hope someone reads it and decides to not go with “newest and latest” unless they have the time to port libraries as well.
I had started Python with the main aim of breaking into functional programming. Had read someplace wrong that Python is functional programming language. The time spent on learning it and using it was great. I didn’t get what I started out for but learned the ease of using a high level language and a dynamic one. Coming from mainly C background that changed my perspective a lot about programming.
I decided to try it once more, functional programming. This time I am going with Haskell which is said to be the ultimate functional programming language. Let’s see how far I can get. For the 1-2 days that I have actually tried using Haskell it has been a weird experience. In a good way. It’s different somehow. Couldn’t place how.
I placed the project for which I had made my old blog on github. I had the versions backed up but not via git. Back then I didn’t know about versioning software like git and mercurial. I was cleaning up my codebase and thought that converting the code dumps of previous versions of the software into git would make it much easier to manage the whole thing if I needed.
I also added the C++ programs’s source code which I had used for the project into the github repository. They had helped me back then take care of repetitive tasks a lot. That was kinda the project where I understood the real value of automating tasks and one of the reasons I started using Python.
I don’t think I am going to update it anymore but good to have that on github. It gets backed up. I am thinking about adding the setup files that I have for various versions on github or not. Still not decided on that.
If I ever thought of continuing the project I’ll do that from scratch in Python/PySide which I have been learning for some time.
If anyone’s interested in seeing what the project was just have a look at the old blog.
So Python is getting useful to me for avoiding manual repetitive tasks. I used it to rename a lot of folders. There were around 700 folders in 28 zip files which I needed to rename and re-zip. That would have been really cumbersome if not for Python.
The folders’ name were like 0001 – abc 1 . Only that the numbers didn’t match. The first number was used for arrangement and it was the second number according to which I had to change the first number. Doing that for 700 folders would have been a real pain. Luckily I knew Python and wrote a script for doing this.
Here’s the Python script that I used.
CUR_DIR = os.getcwd()
FILES_IN_CUR_DIR = os.listdir(CUR_DIR)
num = 0
for c in original_name[7:]:
if not c.isdigit():
if started is True:
started = True
num *= 10
num += int(c)
return str(num).zfill(4) + original_name[4:]
def extract_files(zip_f, cur_path):
with zipfile.ZipFile(zip_f, 'r') as zip_file:
for files in os.listdir(cur_path):
new_name = get_new_name(files)
files = [f for f in FILES_IN_CUR_DIR
for f in files:
cur_path = os.path.join(CUR_DIR, f[:-4])
print('Extracting ' + f)
print('Removing zip file ', f)
print('Writing back to ' + f)
shutil.make_archive(cur_path, 'zip', cur_path)
print('\n')if __name__ == "__main__":
This is just the first version that I used to get it to work. It creates temporary folders that I needed to delete but that was just one select and delete. Not a big thing. I plan to take care of the temporary folders too. The new one you can find in my github -> general -> Python33 -> Utilities maybe in a few days.