Posts tagged Python

Django change the database backend.

Dec. 22, 2016, 8:37 a.m. odo , python , django , sqlite , mysql

In theory if you use django, changing your RDBS from say sqlite to mysql is a breeze. All you need is generate a dump of your existing data with ./manage.py dumpdata, change settings.py and do ./manage.py migrate on the new server. Then you can import the previously exported data through ./manage.py ...

Mint Upgrade

Dec. 15, 2016, 1:33 p.m. mint , vim , gvim , python

I hate updating my OS, but this time I had no choice but to go ahead with it because so many package conflicts are appearing speciallly when using Oracle and SQL Server clients on Mint 17.3 (Ubuntu 14.04). In the old days upgrading mint was particularly diffcult becaus it doesn't have the 'd ...

Sending Google Cloud Notifications with python and XMPP

May 2, 2016, 1:31 p.m. python , android , xmpp , xmpppy , gcm , ccs

Trouble with running Google's sample script for python CCS? You need to update to you xmppp libraries as follows ...

Modified round robin pairing.

Feb. 2, 2016, 6:34 a.m. scrabble , chess , round robin , pairing , python

Do you want to organize a tournament where the pairing system is round robin but some players need to play against other players at a specific time? This gist is what you are looking for.   On friday evening, I got a call from the tournament director of the Scrabble league, asking if I could write a bit of code .. ...

Vim and python debug

May 19, 2015, 12:30 a.m. vim , python , django , debug

Vebugger This is the first VIM based connection that I managed setup. Vebugger will stop at break points and I can use it's commands to inspect variables but it's somewhat tedious because it doesn't have an interactive shell like pdb does. For python debug what this actually does is ...

Which PostGIS function to use?

May 16, 2015, 4:11 a.m. postgis , python , road.lk

Which PostGIS function or operator do you use if you wanted to find the overlap between different lines? There are several candidates with ~, && , ST_Overlaps and and ST_Intersect being amongst the most prominent. They all do the job in different way and take different amounts of time a ...

Vim Autocomplete for Django

May 11, 2015, 12:12 p.m. vim , python , django

How do you auto import requiements in vim? Apparently rope has that feature but having already given up on rope in favour of jedi, I decided to swim with the tide and see what other options are available. Vimpy seems the most likely but it wasn't so easy Error detected while processing /home/rad ...

Good bye python-mode

May 9, 2015, 12:15 p.m. vim , python , pydev

Having recently decided to use vim for all python work I struggled with a nasty bug for nearly two hours and still couldn't figure it out. Then I started up eclipse/pydev, ran it through the debugger and had it fixed in 3 minutes (including eclipse start up time). Ok, maybe it's because I ha ...

Taking on side on the vim vs emacs debate

May 4, 2015, 6:30 a.m. python , vim , emacs

I have been on linux full time for more than 15 years now and never took part in a vim vs emacs battle. Life is incomplete!! — raditha dissanayake (@e4c5) April 23, 2015 it started with a casual comment on twitter. Then at Gaveen's suggestion I decided to finally take a side. After usin ...

Flipped the switch.

May 29, 2014, 1:32 a.m. Jekyll , Ruby , GAE , Python , Django

Finally. Wordpress has been switched off, as I have threatened to do so many times before. This blog post is being written with the aid of a home made blogging system running on Google App Engine (python). The data is stored in NDB and the editor is CKeditor, and the comments are powered by Disqus. ...

Django admin select count(*) from ...

Oct. 6, 2013, 2:24 p.m. Django , Python , roadlk

Shut up and just give me the code? Ok, look at the bottom of this post.What is the slowest query on road.lk? It's the select count(*) on the traffic alerts table that Django admin insists on executing each time someone visit the admin page for the alerts. Though we are fully operational only in Sri ...

Batch minimize js with python and Closure

March 1, 2013, 12:38 a.m. javascript , Python

There maybe much better ways of  batch minimizing Javascript files. But this is my way and sharing it just in case someone else finds it useful.  ...

django.template.base.TemplateSyntaxError: 'block' tag takes only one argument

Jan. 19, 2013, 1:51 p.m. cactus , markdown , Python

Update Feb 16: If you came looking for a solution to a template error in the title;  see this link for the solution. This post is about static blog generators.Still blogging with wordpress despite my repeated assurances that I am moving away from it. This time my excuse is the error message in the t ...

Cactus Volt

Jan. 6, 2013, 11:04 a.m. jekyll , Python , Wordpress

After Punching  Jekyll and Hyde, it was time to look at alternative static blog generator. Something that I came across in the process is Cactus. It looks rather promising, unfortunately as with many open source projects the documentation is somewhat scarce. Still for all this is python which means ...

Python list comprehension

June 10, 2012, 4:14 a.m. Python

Python list comprehension can be compared wtih  Ruby statement modifiers but it's even better. Here is an example: ...

Iterators and Generators and Yields

May 12, 2012, 3:04 a.m. Python , Ruby , Threads , Yield

Both python and ruby have a yield which is thoroughly confusing to Java programmers and looks like the stuff that nightmares are made of. But eventually you realize that it isn't so bad after all. But before we deal with our nightmares, we to look at iterators.Python for loops look so nifty thanks t ...

Python functions

May 8, 2012, 3:59 p.m. Python , Ruby , vargs

We've already taken quick glance at python functions elsewhere, and know that they are created with the def keyword, can have default parameters and which part of the code belongs to the function is identified by it's indentation level When using default parameters, the PHP approach is that you nee ...

Python Packages, Modules and Classes

May 4, 2012, 3:32 a.m. Python

Modules Python says Don't Repeat Yourself. This is made possible by module. A module is just a python script that is 'included' into another one. The syntax for doing that though is with the import keyword. For example if you have a file named crazyModule.py with some code in it you can import it in ...

Django

May 3, 2012, 7:25 a.m. Django , Python , ROR , Ruby , Zope

On thursday morning I set out to learn python and by saturday morning I had read through the official tutorial on the python website as well as gone on numerous side trips on additional references. Blog posts are still paying catch up. You will not find me writing a killer python app in a few days b ...

Python Collections

April 29, 2012, 6:41 a.m. Map , Python , Reduce , Ruby

Lists and Arrays. Correct me if I am wrong here but lists in python are what everyone else calls arrays right? Check this out: a = ['spam', 'eggs', 100, 1234] That's an example for a list given in the python docs. But that's how most other languages define an array. Getting an array list slice is ...

Python in 48 hours

April 28, 2012, 5:27 a.m. Python , Ruby

Spurred on by my recent success in quickly learning ruby,  I am about to embark on a (crash) course on python. Consider the following to be my study note. It may or may not be useful to you. If you are coming from a PHP, Java or C background it's perhaps more likely to be of use. Anyway, let's get s ...

Ruby vs Python

April 27, 2012, 9:17 a.m. Django , Python , religion , ROR , Ruby

Ruby and Python have been around for a long time almost as long as Java and PHP hang on a second, Python is older than java.  Both PHP and Java are decidely on the decline and according to the fan boys both Ruby and Python are on the ascendancy. But that's not exactly consistent with what Google Tre ...

ImportError: No module named MySQLdb

April 28, 2010, 11:15 a.m. netbeans , Python

When you see that title, you are gonna say; 'you need to install the MySQLdb module'. Well, let me assure you that it's already it's already there. Provided by MySQL-python-1.2.3-0.4.c1.fc12.x86_64.rpm . On the other hand if you are here because you ran into the same problem and want a solution, bu ...

Graphical Subversion

June 2, 2009, 7:08 a.m. Collaboration , netbeans , Python , subversion

Trying out different graphical subversion clients the first one that I tested was rapidsvn. Seems like a pretty decent tool but it had one shortcoming - it will not allow me to enter an unversioned directory. If you are like me, when you go off on a tangent you probably create a few things in a dire ...

Python and Tidy.

Dec. 11, 2008, 12:32 a.m. Python

The other day, I was having a spot of bother parsing HTML fragments using the python DOM. Though I did overcome that problem I immediately ran into other problems due to the odd missing tag and the odd special character. Rather than get into a mess of regular expressions, I thought to try the HTML T ...

Bye Bye Wiki

Dec. 9, 2008, 1:30 a.m. Python , web 0.8

I have been having a Wiki on this site at http://www.raditha.com/wiki/ for nearly four years but was finally forced to take it down because I couldn't keep pace with the spam bots. The last straw came when I ran into the following error while trying to clean up after the vandals. Database error A da ...

Parsing HTML with Python.

Dec. 8, 2008, 1:08 a.m. Python

Needed to make a small change to my photoblog - a change that should be reflected on every single post.  Thought I might be able to use python DOM to get it done. With PHP it's quite easy, I have done that sort of thing many times in the past. Can't that be handled by the template? no because this ...

Python or Ratsnake?

Nov. 3, 2008, 9:19 p.m. Python , religion , weird

So is this language a Python or a Ratsnake? Actually Rat snakes are very harmless species of non venomous snakes. As the name suggests they eat rats and mice so if you see one slithering into your house you shouldn't chase it away. They are always welcome into mine. I spotted one in the store room a ...

ImportError: No module named dom.minidom

Oct. 31, 2008, 11:51 p.m. Python , weird , XML

I Thought, I would try my hand at XML parsing with the python DOM. Whatever programming llanguage you use the DOM pretty much the the same. However things didn't get off to an auspicious start. Even the sample code on the python docs didn't work and produced an error: Traceback (most recent call las ...

"IOError: [Errno 95] Operation not supported"

Oct. 28, 2008, 2:07 a.m. Python , weird , X11

To my great surprise (nay shock), I found that you cannot redirect output to /dev/null with cat for certain file types. For example  cat dsl-n-01RC4.iso > /dev/null will result in the following error: cat: dsl-n-01RC4.iso: Operation not supported Surely this cannot be? Yet, cat works fine for ot ...

Mythtv delete all episodes of a recorded program

Oct. 26, 2008, 11:48 p.m. Python , quadruple play

Sure there is more than one way to delete all episodes of a recorded program with mythv - they are just not very obvious. So I decided that my first learning task with python will be to write a script that does just that. In order to do so, you need to learn how to connect to a database - that was r ...

Python and Fortran

Oct. 17, 2008, 9:14 a.m. Python

I was quite surprised to learn that python does not use curly braces in the same manner that most other programming languages do - instead it relies on the levels of indentation to identify code blocks. The last time I had seen something like that was when I was using FORTRAN back in 1999.At the tim ...

The Serpent.

Oct. 15, 2008, 1:49 a.m. Python

I know quite a few languages but I suddenly realized that I have not learned any new language for more than 10 years. Sure I did make half baked attempts to learn ColdFusion, Ruby and I am ashamed to say even C# (but using mono). Never put in the effort required and never mastered any of them. What ...