Archive date grep is a python script that allows you to archive (choosing zip or tar) all files within a directory structure which have been modifies since a user defined date. The archive maintains the original directory structure which makes it ideal for releasing websites. You can downlaod the script as a zip archive[zip 2 KB] or as a tar archive [tar 8 KB]. This script is alot better than the original SimpleZipDateGrep that I had on the site. Enjoy 🙂
Yearly Archives: 2006
One year today
We’ve been in our house one year today. One of the fastest years I have ever had.
Textarea size increase in PHPMyAdmin
I needed to increase the size of the textareas in phpMyAdmin. Drag this bookmarklet to your bookmarks, click on it when you’re using phpMyAdmin and you’re done.
[code lang=”javascript”]
javascript:(function()
{
var textareas = window.frames[‘frame_content’].document.getElementsByTagName(‘textarea’);
for (n=0;n
Stuff I want to post about
Stuff I want to post about but don’t have the time :
- Having a dedicated Ubuntu machine
- mod_python and mod_php having a barny ‘cos I want to use mysql with both
- Hacking the web developer extension
- Getting SVNserve working
- Getting Trac working
- Working from home
- Semi-converting my loft
- Working late
- Booking time off
- I hate Sage (the accounting software)
- Bobby growing out of his collar already
- VTBook pcmcia graphics card
- Synergy across 4 machines(1 Linux, 2 Windows and 1 OSX)
- Multi-monitor setups
- My Love for Python and my hatred for it’s lack of documentation
- The fact that I haven’t linked to anything mentioned on this list
- …and loads more too
Quinn Direct Masters tickets
I am selling 2 tickets to the Quinn Direct masters golf championship which starts on 10th may. Face value is £20 each, you can get 2 of them for £36£31 delivered. Buy it now
Now Sold
No nonsense… fo sho
Myself, Gill, Enda and Tara went to the Aintree grand national on saturday. Tara bought us tickets for the John Smiths “No Nonsense” enclosure. We stayed in the beer tent mostly and got pissed. Gill’s favourite band were on too which we didn’t know so that was great. I had a great day out and I think I might still be a little hungover. It was well worth it. I learned three things on saturday:
- I
fuckingfipping love bitter - I am shit at choosing horses
- I
fuckingfipping love bitter
All about the inches
My brother played this in his car the other day and it is truly awesome. Al Pacino’s inches speech in Any Given Sunday. If you’re feeling tired or uninspired, I guarantee this will pick you up.
Download AnyGivenSunday_Inches.mp3 usual copyright disclaimers etc…. blah blah blah
Karova Design launches
As part of our bid to take over the world we have added a new team of experts to our arsenal…… I give you Karova Design.
Karova Design is part of the Karova family. We specialise in designing and developing exceptional Internet experiences for both commercial and non-profit organisations. We are well known for accessible website design and standards compliant website development with strong emphasis on design, usability and identifiable value for money.
Zip all changed files
Calling all server admins
Our server admin was off today and I had to set a site live. We have a dategrep.py script that lists all changed files since a certain date so that those files can then be ftp’d to the live server. This seemed far too tedious for me so I re-wrote the dategrep.py script so that given a date it will zip up all changed files since that date. The zip archive will have the same directory structire so that all you have to do is extract that archive on the live server and you’re done.
[code lang=”python”]
“””
Checks for files modifies after a given date time and then adds them to a zip
file that can be easily extracted
“””
import os, time, sys
import zipfile
import glob
from datetime import datetime
class SimpleZipDateGrep:
today = time.time()
yesterdayTimestamp = today-24*60*60
yesterday = datetime.fromtimestamp(yesterdayTimestamp)
iYear = yesterday.year
iMonth = yesterday.month
iDay = yesterday.day
iHour = yesterday.hour
iHourOrig = iHour
iMin = yesterday.minute
zFileName = “SimpleZipDateGrepChange.log.zip”
logFileName = “SimpleZipDateGrepChange.log”
sExcludeFiles =””
bExcludeFiles = False
lExcludeFiles = [‘list.txt’,’log.txt’]
sYear,sMonth,sDay,sHour,sMin = “”,””,””,””,””
def __init__(self):
self.GetArgs()
self.ZipFiles()
print “Finished”
def GetArgs(self):
self.sYear=str(raw_input(“Year (yyyy)[default: “+str(self.iYear)+”]: “))
self.sYear = self.sYear.strip()
if self.sYear != “”:
try:
self.iYear = int(self.sYear)
except:
print “This is not a valid year”
#exception in casting to int
self.sMonth=str(raw_input(“Month (mm)[default: “+str(self.iMonth)+”]: “))
self.sMonth = self.sMonth.strip()
if self.sMonth != “”:
try:
self.iMonth = int(self.sMonth)
except:
print “This is not a valid month”
#exception in casting to int
self.sDay=str(raw_input(“Day (dd)[default: “+str(self.iDay)+”]: “))
self.sDay = self.sDay.strip()
if self.sDay != “”:
try:
self.iDay = int(self.sDay)
except:
print “This is not a valid day”
#exception in casting to int
self.sHour=str(raw_input(“Hour (hh)[default: “+str(self.iHour)+”]: “))
self.sHour = self.sHour.strip()
if self.sHour != “”:
try:
if int(self.sHour) < 25:
self.iHour = int(self.sHour)
except:
print "This is not a valid hour" + str(self.sHour)
#exception in casting to int
self.sMin=str(raw_input(“Minute (mm)[default: “+str(self.iMin)+”]: “))
self.sMin = self.sMin.strip()
if self.sMin != “”:
try:
if int(self.sMin) < 61:
self.iMin = int(self.sMin)
except:
print "This is not a valid minute" + str(self.sMin)
#exception in casting to int
self.sExcludeFiles = str(raw_input(“Exclude Files (y|n)[default: n]: “))
if self.sExcludeFiles.lower() == ‘y’:
self.bExcludeFiles = True
else:
self.bExcludeFiles = False
def ZipFiles(self):
”’
0 tm_year (for example, 1993)
1 tm_mon range [1,12]
2 tm_mday range [1,31]
3 tm_hour range [0,23]
4 tm_min range [0,59]
5 tm_sec range [0,61]; see (1) in strftime() description
6 tm_wday range [0,6], Monday is 0
7 tm_yday range [1,366]
8 tm_isdst 0, 1 or -1; see below
”’
iBaseTime=time.mktime((self.iYear,self.iMonth,self.iDay,self.iHour,self.iMin,0,0,0,0))
if self.iHour != self.iHourOrig:
iBaseTime = iBaseTime + time.altzone
currentFileName = os.path.basename(str(sys.argv[0]))
f=open(self.logFileName,’w’)
zFile = zipfile.ZipFile(self.zFileName, “w”)
f.write(“- File changed since – %s\n”%time.asctime(time.localtime(iBaseTime)))
#get a list of all the root level directories
curDir = os.curdir
for root,dirs,files in os.walk(curDir):
if root.lower().find(“svn”)>-1 or root.lower().find(“cvs”)>-1 :
continue
for name in files:
if name.lower().find(“svn”) > -1 or name.lower().find(“cvs”)>-1 or name == self.zFileName or name == self.logFileName or name == currentFileName:
continue
iTime=os.path.getmtime(os.path.join(root,name))
if iTime and iTime > iBaseTime:
#add the file to the zip file
if self.bExcludeFiles == True or (self.bExcludeFiles == False and root not in self.lExcludeFiles and name not in self.lExcludeFiles):
#Products
curPath = os.path.join(root,name)
curPath = curPath.replace(“.\\”,””)
if curPath.find(‘.’)==0:
curPath = curPath[1:]
print curPath
f.write(“%s %s\n”%(time.asctime(time.localtime(iTime)),curPath))
zFile.write(curPath, curPath, zipfile.ZIP_DEFLATED)
zFile.close()
f.flush()
f.close()
if __name__ == ‘__main__’:
SimpleZipDateGrep = SimpleZipDateGrep()
[/code]
Download SimpleZipDateGrep.zip {zip 1Kb}. It’s also on the downloads section. 🙂
Update:
Some bug fixes and now written in an OO stylie for reusablility
ASPX craziness
There I was hammering away, well in the zone writing a pretty beefy login system in C# when all of a sudden all the pages stopped working. I was running the application on my own machine so I tried to debug by setting a breakpoint and attaching the aspnet worker process. Nope just output blank pages. I was about to go back to a previous version of the project I had in CVS but I had done a good bit of work and didn’t fancy trying to merge it all back in bit by bit. I then noticed the following on another aspx.cs file that I had not been working on .
[code lang=”cpp”]
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
[/code]
I had seen this in my login.aspx.cs but stripped it out as thought it was the usual Visual studio bullshit. I added it and hey presto, I have XHTML being output and I can debug to my hearts content.
The moral of todays little tale – Don’t ever delete something if you don’t know what it does.
That’s enough for today, I’m going home (in my Volvo 🙂 )