Below you will find pages that utilize the taxonomy term “python”
Creating thumbnails from photos with Python PIL
This time around I want to share with you a little Python library I found called PIL. If you’re a Python developer chances are you already know of it, but I use Python only from time to time, usually to automate some tasks so I was very excited to come across such a library. First thing’s first, download PIL and install it. I’m using it on a Windows platform so I used the packaged binary version, but you can get the source code and use it on any platform that supports Python.
tail -f for windows
Here’s a simple implementation of “tail -f” UNIX command equivalent in python. I used it a lot on windows servers to monitor log files. The good thing is that it works over SMB (windows shares).
#!/usr/bin/env python import sys, os, time def main(argv): if len(argv) < 2: print "Usage: tail filename.log" exit(1) try: fp = open(argv[1], "r") st_results = os.stat(argv[1]) st_size = st_results[6] fp.seek(st_size) while 1: where = fp.tell() line = fp.
Strings in JAVA
A few days ago I needed to extract all strings from .java files and also thought that it would be a good idea to keep count how many times a string is used. So I came up with this simple python script. It’s kind of a quick and dirty solution, but it met my needs for the particular task.
import sys, os, re from operator import itemgetter files = [] strings = {} exp = re.