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:

  1. I fuckingfipping love bitter
  2. I am shit at choosing horses
  3. I fuckingfipping love bitter

John Smiths

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

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);
}

///

/// Required method for Designer support – do not modify
/// 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 🙂 )

Vivacious Volvo

Well, it’s done. After many weekends deliberating over whether to buy a second car, I’ve finally taken the plunge and purchased a long time dream of a car (note I didn’t buy this car with economy in mind ;)) – Volvo v70 2,5 litre 20v Turbo. Even saying it gets me excited. It’s a 1997 model with a cool 160,000 miles. I paid £1900 (2,752.18 EUR) with a new cam belt fitted which after much research is a good price. The mileage does not bother me as I have read of v70s doing more than 700,000 miles. I pick it up next saturday and I cannot wait.

Volvo v70 exterior 1
Volvo v70 interior
Volvo v70 exterior 2

I predict that this car will feature heavily in my future posts.

Awesome Synergy

Awesome synergy
Damn those open source developers. Synergy is excellent. I recently bought a USB switch so I could switch my trackball and keyboard between machines. It works well but then I tried Synergy. I have heard some talk of it but thought it was still alphatastic but I ran the installer on my home machine, my work laptop and my brothers laptop, configured it . Now all I have to do is flick the cursor from screen to screen and start typing. This is the best application I have seen for months.

Update:
As suspected, it is a bit buggy in that sometimes my mouse stops being able to click on anything. But restarting Synergy on the server machine fixes it.

Second update:
Myself and Matt at work (whose new site is almost out of beta) were having a play with synergy and he found quicksynergy (http://quicksynergy.sourceforge.net/) which means it’s super easy to install synergy on OSX. It also seems to work with Linux. SynergyKM (http://software.landryhetu.com/synergy/) is another synergy gui for OSX