26th September 2007
Sample script (copypasted from Well House Consultants training course):
click the PLAIN TEXT header for copy-pasteable version
PYTHON:
-
#!/usr/local/bin/python
-
-
author = {"php":"Rasmus Lerdorf",\
-
"perl":"Larry Wall",\
-
"tcl":"John Ousterhout",\
-
"awk":"Brian Kernighan",\
-
"java":"James Gosling",\
-
"parrot":"Simon Cozens",\
-
"python":"Guido van Rossum"}
-
-
langs = author.keys()
-
langs.sort()
-
-
for language in langs:
-
print language,"is the child of",author[language]
You can also define the Python ksort() function similar to that found in PHP:
Read the rest of this entry »
Share This
Posted in Notepad, Programming, Python | No Comments »
26th September 2007
Sample script (copypasted from Well House Consultants training course):
click the PLAIN TEXT header for copy-pasteable version
PYTHON:
-
#!/usr/local/bin/python
-
-
author = {"php":"Rasmus Lerdorf",\
-
"perl":"Larry Wall",\
-
"tcl":"John Ousterhout",\
-
"awk":"Brian Kernighan",\
-
"java":"James Gosling",\
-
"parrot":"Simon Cozens",\
-
"python":"Guido van Rossum"}
-
-
langs = author.keys()
-
langs.sort()
-
-
for language in langs:
-
print language,"is the child of",author[language]
You can also define the Python ksort() function similar to that found in PHP:
Read the rest of this entry »
Share This
Posted in Notepad, Programming, Python | No Comments »
19th September 2007
PHP proxy is simple but good. I converted it into a proxy-function for one of my projects.
Do pay attention to the comments, especially these two:
I had issues with this script (and others) returning 0 for the bytesTotal in flash. Basically, the Content-Length header was absent from the response. By simply adding
header("Content-length: ".strlen($response)) before the echo, it resolved the issue. I don't know if there is a more appropriate fix to account for character encoding, etc, but it seems to work.
@Schimmi: Well, if you can add some checks there (like who is referring your script) and allow the access to whitelisted clients (served from your domain)... I think, you can totally make it used applications from same-domain....So it would not be open to world. Yeah above script doesn't have those things.
Share This
Posted in Links, Notepad, PHP, Programming | No Comments »
19th September 2007
PHP proxy is simple but good. I converted it into a proxy-function for one of my projects.
Do pay attention to the comments, especially these two:
I had issues with this script (and others) returning 0 for the bytesTotal in flash. Basically, the Content-Length header was absent from the response. By simply adding
header("Content-length: ".strlen($response)) before the echo, it resolved the issue. I don't know if there is a more appropriate fix to account for character encoding, etc, but it seems to work.
@Schimmi: Well, if you can add some checks there (like who is referring your script) and allow the access to whitelisted clients (served from your domain)... I think, you can totally make it used applications from same-domain....So it would not be open to world. Yeah above script doesn't have those things.
Share This
Posted in Links, Notepad, PHP, Programming | No Comments »
7th September 2007
Andy Dustman gave a presentation on Python and MySQL at the MySQL Users Conference 2005, Santa Clara, CA. The presentation is an excellent collection of examples for those who use the MySQLdb Python module.
Read the rest of this entry »
Share This
Posted in Links, Notepad, Programming, Python | 2 Comments »
7th September 2007
Andy Dustman gave a presentation on Python and MySQL at the MySQL Users Conference 2005, Santa Clara, CA. The presentation is an excellent collection of examples for those who use the MySQLdb Python module.
Read the rest of this entry »
Share This
Posted in Links, Notepad, Programming, Python | 2 Comments »
7th September 2007
Here's an excellent description of various methods to handle date and time in Python scripts.
Share This
Posted in Links, Notepad, Programming, Python | No Comments »
7th September 2007
Here's an excellent description of various methods to handle date and time in Python scripts.
Share This
Posted in Links, Notepad, Programming, Python | No Comments »
30th August 2007
I just had a small problem with my Python script:
1. I have a list of tuples, called records_cache; each tuple looks like this:
(note: for copy-pasting, click the PLAIN TEXT box headers)
PYTHON:
-
(ensembl_transcript_id, ensembl_gene_id, chrom_start, chrom_end, utr_start, utr_end, sequence, strand)
2. I need to INSERT only some of those values into MySQL table, using the MySQLdb executemany() method. The values I need are utr_start, utr_end, ensembl_gene_id (in exactly this order).
To do this, I need to create another list of tuples, but with shorter 3-item tuples. Let us call the new list genes_update.
Here is the elegant, though probably not the most efficient, solution:
Read the rest of this entry »
Share This
Posted in Programming, Python | 1 Comment »
30th August 2007
I just had a small problem with my Python script:
1. I have a list of tuples, called records_cache; each tuple looks like this:
(note: for copy-pasting, click the PLAIN TEXT box headers)
PYTHON:
-
(ensembl_transcript_id, ensembl_gene_id, chrom_start, chrom_end, utr_start, utr_end, sequence, strand)
2. I need to INSERT only some of those values into MySQL table, using the MySQLdb executemany() method. The values I need are utr_start, utr_end, ensembl_gene_id (in exactly this order).
To do this, I need to create another list of tuples, but with shorter 3-item tuples. Let us call the new list genes_update.
Here is the elegant, though probably not the most efficient, solution:
Read the rest of this entry »
Share This
Posted in Programming, Python | 1 Comment »
12th August 2007
Today, after starting ./configure to make one of the programs, I noticed this in the logs:

I don't know what is that intended to mean, but this is definitely funny: configure script, able to detect if the Force is with Skywalker...
Share This
Posted in Humour, Programming | No Comments »
12th August 2007
... which covers some of the FAQs Python starters have.
The guide was complete in December'2004, but does have lots of useful information for Python newbies and beginners.
Share This
Posted in Links, Programming, Python | No Comments »
12th August 2007
... which covers some of the FAQs Python starters have.
The guide was complete in December'2004, but does have lots of useful information for Python newbies and beginners.
Share This
Posted in Links, Programming, Python | No Comments »
12th August 2007
I found a sample of Python code to iterate through all the files within the specified folder (directory), with ability to use wildcards (*, ?, and [ ]-style ranges). Below is a portion of code from a working script:
Read the rest of this entry »
Share This
Posted in Programming, Python | 2 Comments »
12th August 2007
I found a sample of Python code to iterate through all the files within the specified folder (directory), with ability to use wildcards (*, ?, and [ ]-style ranges). Below is a portion of code from a working script:
Read the rest of this entry »
Share This
Posted in Programming, Python | 2 Comments »
10th August 2007
Today I was looking for some simple but convenient source-code editor. I came across this post, and decided to try Geany. I'm using Slackware 11 at the moment, and as there were no packages available, I downloaded Geany source to compile and install.
However, the 'configure' script failed. When trying to compile 'conftest.c' with gcc, the following error was produced:
libc.so: file format not recognized; treating as linker script
(Note 1: in the error above, I removed all the paths which were prepended to the actual error message.)
(Note 2: I suspect that this error is the result of incomplete/failed/erroneous update of glibc slackware package I attempted a while ago. Will have to fix that more properly than described below.)
Here's the solution which helped me to install Geany successfully:
Read the rest of this entry »
Share This
Posted in *nix, Programming, Software | 2 Comments »