Tag Archives

15 Articles

Posted by Dave on

Unicode in Python

Unicode in Python

It’s a very long time since I have had to deal with binary code translations, but when dealing with HTML and JSON with Python, I need to get to grips with it. The € symbol for instance requires the extended character set support and rss should be written in utf-8. This page collects the notes I made in learning about Python’s support for unicode/ascii translations.

Posted by Dave on

Converting dates to strings using Python

Converting dates to strings using Python

While working on converting ello.json to rss, I needed to convert the date formats, I needed to do it in Python and found the following code worked, using strptime and strfmtime. I had to augment the date string with the name of the day of the week attribute, so felt it had to via a date data type. (This is an important part of the requirement, since otherwise string manipulation would have been enough.) Finding exampes was hard, so I hope it helps,

Posted by Dave on

Log Rotate and *NIX

This has changed since my days at Pyramid. There has been quite a lot of thinking and engineering about dealing with daemon logs. The places to look are via the syslogd, newsyslog project, you can see a the newsyslog man pages and using the keyword “rotate log”. The idea is that logs are rotated, although the names are not and that old logs are deleted. So the newest is called mypackage or mypackage.0 and the older logs increment the counter. Logs are generally kept in /var/log or /var/log/package_name and not in the package or product install tree. What a nob? There is a command ‘logrotate’; it can be installed using macports. It needs a a configuration file.

Posted by Dave on

Python

Python

I returned to Python in Oct 2010.

I have two problems to solve,

  1. converting my bliki to wordpress, (I never used Python for this)
  2. scripting for KDB & Hadoop

This article contains notes started in 2011, I did not make this an omnibus entry and it is very sketchy, covering file I/O, date & time, dictionaries vs. lists and PYTHONPATH.

Posted by Dave on

Shell Programming

At somr point, I wrote. “This page never seems to age, …” it just contains some idioms I like to use in my .login and/or .bashrc files. I don’t do this so often as when I started the page but the MAC keeps it in the house, and I have installed cygwin on nearly all my windows systems. However, microsoft implemented bash on windows 10 and so things finally changed. …

Posted by Dave on

HTML Slide Shows

HTML Slide Shows

I wanted to create a scrolling picture show as a banner on all the pages in a micro site. Many sites use this for their front page decoration. I didn’t want to use animated gif because of the age of the technology.It’s obviously becoming easier. Basic Tips below, shows how to use the HTML META tag with http-equiv=”refresh”attribute set.

Posted by Dave on

Using “boomy” icons with tcl/tk

I spent some time over the last few days trying to populate the TK images folder with a usable image library. The activestate version and the standard only permits the use of .gif images in the image manipulation commands. (Not true now, see the comments!) I might need to look at the tkImg package to use an alternative format.

Posted by Dave on

Python and datetime

Links

Here are some links

Examples

An example of using datetime is

import time
import datetime
now=datetime.datetime.now() 

#now.tzinfo = 'GMT'; # fails, now.tzinfo is immutable

print now.ctime() print now.isoformat() print now.tzinfo

but otherwise produces the following output

Fri Jan  2 15:15:07 2009
2009-01-02T15:15:07.896000
None

I performed these tests on a windows XP box. tzinfo is empty is this a windows/configuration thing? I can test this with UNIX. I tried setting the TZ variable before running the program and it makes no difference. I found one reference that says Python datetime doesn’t do TimeZones.

Obviously, using the from statement would change the call syntax

from datetime import datetime
now=datetime.now()

should work

Posted by Dave on

Small screen HTML runes

Optimising HTML for small screens

I have been interested in optimising HTML for small screens and/or using CSS as the vehicle. This has been driven by my personal publication properties and started at Sun with the then Sun Blog. I marked it as deprecated in 2020.

Posted by Dave on

External Disk on an XP system

External Disk on an XP system

This article was originally written in 2008, and was copied to this wiki in June 2013. It covers both moving XP windows directories from the internal local drive to the external disk, and some wish scripting to check the disk was on and remind people to turn it on if not already done. This article talks about the disk, filesystems, transferring the data, and writing some tcl/tk scripts including an motd to manage the remote “My Documents” folder. I changed the title from “External Disk on the Dell” since I had re-purposed the disk by 2013. This is now deprecated.