code
Although most, if not all, of the code snippets here are in use today and work without issue we provide warranties or guarantees. :)
Some of this code may be out of date but probably still useful as a starting point.
Contact us if you have any questions or comments.
Convert Text Files (UNIX / OS X)
Convert Word docs to text files, concatenate text files and convert to html. Woohoo! Use the code below in Terminal to convert all files in the current directory to txt files. I used this to de-M$ a bunch of Word docs. Very handy. Check out the man page for textutil at Apple's Developer site.
textutil -convert txt *.*
Resize an Image with PIL and Keep Aspect Ratio (Python)
This script will resize an image using PIL (Python Imaging Library) to a width of 300 pixels and a height proportional to the new width. It does this by determining what percentage 300 pixels is of the original width (img.size[0]) and then multiplying the original height (img.size[1]) by that percentage. Change "300" to any other number to change the default width of your images.
import PIL
from PIL import Image
img = Image.open('somepic.jpg')
wpercent = (300/float(img.size[0]))
hsize = int((float(img.size[1])*float(wpercent)))
img = img.resize((300,hsize), PIL.Image.ANTIALIAS)
img.save('sompic.jpg')
from PIL import Image
img = Image.open('somepic.jpg')
wpercent = (300/float(img.size[0]))
hsize = int((float(img.size[1])*float(wpercent)))
img = img.resize((300,hsize), PIL.Image.ANTIALIAS)
img.save('sompic.jpg')
all code
- Convert Text Files UNIX / OS X
- Resize an Image with PIL and Keep Aspect Ratio Python
- Check for Published Items DTML / Python
- Converting input to upper and lowercase Javascript
- Get a list of published documents. Python
- Clone and Catalog a Doc in Zope Python
- Delete and Uncatalog a Doc in Zope Python
- Edit and Update a Doc in Zope Python
- Batching Articles in groups of 3 DTML
- Checking File Extensions to Determine Display DTML
- Displaying Content at a Specific Time DTML
- General Link Alert Javascript
- Toggle Boxes Javascript
- Basic Comments to Text Property DTML
- Basic Table Based Form HTML
- Basic Clone DTML
- Displaying Random Images (or any other files) DTML
- Appending To A Lines Property DTML
- A Simple Mail Form using dtml-sendmail DTML
- Adding New Documents Method DTML
- Creating a Unique ID with ZopeTime DTML
- URL Test DTML
