Press "Enter" to skip to content

Posts published in July 2012

ImportError: No module named MySQLdb (Python)

Yikes! Traceback (most recent call last): File "some_file.py", line 4, in import MySQLdb as mdb ImportError: No module named MySQLdb So how do you fix this on Linux (Ubuntu) ? sudo apt-get install python-mysqldb

RuntimeError: thread.__init__() not called (Python)

Today I got a really dumb error from Python. RuntimeError: thread.__init__() not called But luckily it’s really easy to fix! Below is the code before (with the error): [code lang=”python”] class SomeThread(Thread): def __init__(self, myVar): self.sMyVar = str(myVar) def run(self): self.sMyVar = “bla..” + self.sMyVar [/code] And now for the…

SQL to Append all Fields if Shorter than a set Length

This came in very handy for me at one point because I needed to have a certain field in each row 14 characters long, but half of them were only 12 characters long. In MySQL: [code lang=”sql”] update `table` set `field` = CONCAT(`field`, ‘1’) where LEN(`field`) = 13; [/code] In…

Search for "arabic" is url request and change codepage – ASP

If you are using Classic ASP (yuck) to create an arabic section of a website you can search for the arabic string in your Request URI and then change the session’s codepage as follows: [code lang=”asp”] if instr(1, request.ServerVariables(“PATH_INFO”), “arabic”) then session.codepage = 1252 end if [/code]

Search for "arabic" is url request and change codepage – ASP

If you are using Classic ASP (yuck) to create an arabic section of a website you can search for the arabic string in your Request URI and then change the session’s codepage as follows: [code lang=”asp”] if instr(1, request.ServerVariables(“PATH_INFO”), “arabic”) then session.codepage = 1252 end if [/code]