Friday, January 15, 2010

Windows 7 Customizations and Software Replacements

Hello and Happy Holidays! (OK, well I started this before the holidays...)

Anyway.  I've been playing with Windows 7 for a bit now and I've got a few little tools that people may find useful depending on what you do with your computer.

The first is one I love for it's ease of use.

The Windows 7 Logon Background Changer


This tool allows you to as it's name says, change the background on your Windows 7 logon screen.  It exploits a set of features included in the OS for OEM installs (Dell, HP, etc.) to make their systems stand out.  It can also be used for branding by companies, and now with this tool anyone with a picture and 20 seconds.  For the curious you can grab the source code to see how it all works.

Ultramon

This program is still in beta for Vista and 7.  It's also a pay for application.  However it works, really really well.  What it does do is allow you to manage multiple monitors easily.  These management properties include generating wallpapers that can include different images on each screen of the system and allowing you to configure screen savers that span multiple screens.  It also allows you to specify hotkeys for managing multiple monitors, like a quick key to toggle off/on all screens except the primary screen (exceedingly important for playing video games).   Another interesting feature is that it can mirror one monitor onto another monitor as long as they are the same resolution, yes this can be done usually anyway but not always and this will happily do it for you.  I've been using it since XP, and it's progressed pretty well since then. The release candidate for the latest version was just put out which is a plus.  A competing option to this program is the package Display Fusion, the feature sets are not entirely the same but the basic stuff is all the same, plus it has a free version.

John's Background Switcher

For anyone just looking for a straight forward background management package instead of the whole kit and kaboodle that is Ultramon, we have John's Background Switcher.  It allows you to setup a set of images to be rotated in as your background and also enables and number of composting features like a postcard pile display.  You can select either local picture folders or image streams and sites like flickr or deviantart, as well as a whole slew of tweaking options for the truly obsessed.  It also features the ability to configure each monitor seperately (assuming you have separate monitors).  O yea, and it's FREE.  It should be noted however you can't create background profiles like you can in Ultramon, it's entirely dynamic in the way it's presented.

Paint .NET

I've used this number of times now and have loved it every time I've used it.  I'm no photoshop guru but I've been pleasantly surprised how easy this has been to use so far.  Basically it's a free photoshop esq photo editing software package and it's pretty powerful.  On top of that it supports plugins for real power users that want to get just that little bit more out of the software.

Notepad ++

For those of you who use notepad as more than just a scratch space when IMing people, this is a rock solid piece of software.  If you've ever used 'Crimson Editor' you'll love this piece of software.  It has support for syntax highlighting on a truly amazing number of programming languages.  As well you can expand it's default list with user published highlighting rules, as well as plug-ins to expand it's feature set to include things like HEX editors, change trackers and spell checkers.  It's open source (and thus free), and has the option to automatically replace the notepad shortcuts with ones to itself during installation.

SSD Tweak Utility

For all the SSD early adopters out there you've probably read that Windows 7 support for the technology is better than both XP and Vista's, and this is (apparently) true.  However there's still more you can do if you so choose.  And now you don't even have to think about it, the user elpamyelhsa on the OCZ forums has produced a tweaking utility designed to squeeze the maximum life time out of those precious little drives.  A full rundown of the work, what each tweak means and how it affects you can be located here.  O yes, it's also free.

Ultimate Windows Tweaker

Finally, for the nitty gritty settings junkies out there, this package condenses 100+ of the most popular and useful tweaks into an itty bitty download.  The best part is you don't even have to install it, just run it and tweak whatever you want.

Sorry folks, no red pill blue pill on this one, it just doesn't fit the format.

Saturday, December 19, 2009

Updated Dancing Instructions for QT and MSVC 2008

So, anyone that's tried to follow my instructions for compiling QT for use with MSVC 2008 (which incidentally should work for 2005 as well) will notice that for 4.6 (and I believe 4.5) they don't work. Instead everything will go smoothly until you get some sort of webkit linking error error 0x2 on command 'cd' and etc.

This is a fixable error, and actually the fix is pretty simple. You have to remove four files before you begin the compile that cause some sort of issue with the build process. Don't worry they are all temporary files, and appear to be artifacts of the MinGW build's MOC process. I can not take credit for discovering this, it just took alot of Googling to figure out what's up. The best run down I've found is at the ffuts.org blog, which also provides a way to optimize your QT compile for people that want to explore multi processor compilation.

The files that need to be removed from each copy you wish to build into an MSVC version are:

.\qt\src\3rdparty\webkit\WebCore\tmp\moc\debug_shared\mocinclude.tmp
.\qt\src\3rdparty\webkit\WebCore\tmp\moc\release_shared\mocinclude.tmp
.\qt\src\script\tmp\moc\debug_shared\mocinclude.tmp
.\qt\src\script\tmp\moc\release_shared\mocinclude.tmp

The Blue Pill:
The good news is, this works and it's fairly straight forward.

The Red Pill:
This was not easy to find by any stretch. It would be nice to just be able to grab a 'tools and source' setup so you can cut out a few steps, like fighting with these files that will kill your compilation several hours in.  That said, the fix is easy.

Thursday, November 19, 2009

SVN Verify Crond Monitor Script, Born From Misery.

Over the last few weeks I've had the displeasure of dealing with an imploded SVN FSFS repository. In the process of learning what was wrong and how to go about fixing it (or working around the problem) I discovered that I could have mitigated some of this problem by monitoring my svn repositories for problems with 'svnadmin verify'.

This wouldn't of course help me fix the problem, but it would have identified it long before I did, making the overall data loss that occurred far smaller.  As it stands we lost about 25 revisions from one of our major SVN repositories, as we had to remove everything at and after the damaged repository and recommit it on top of the undamaged remnants.  This means we lost alot of history but not necessarily alot of code.  Still it was an extremely time consuming fix that would have been better simply avoided.

As such I've written a little python script that's simply designed to catch any errors generated by the verify command that is meant to be inserted into a crontab for execution. As such there are a number of things you'll have to edit before it'll be truly useful to you. It's been written this way to avoid many of the major pitfalls associated with running scripts from cron, which has a severely restricted execution environment.

Specifically you must update a few variables to reflect what you would like them to do or point at.

The first and most obvious is updating the /usr/bin/python, to point at your actual version of python. I strongly recommend typing 'which python' and just pasting the results in the place of the above string, if you just put 'python' in there instead your beholden to the path available to crond.

After that it's a simple matter of updating the variables under the 'Setup' comment. I will list each one and explain what you need to put in that position.

svnadmin_path: this is the string returned from 'which svnadmin', this should be an absolute path, and the line under it will make it into such for good measure.

repository_path: this value serves one of two functions, either it's the location of the repository (singular) that you wish to keep an eye on.  Or it's the location of the root of several repositories you wish to keep an eye on.  In either case the path should be absolute.

recursive_path: this is a bool flag with possible values of True or False, if it is set to True the program will treat the repository path as the root of a group of repositories instead of as the target repository itself.

verbose: this is another bool flag with the same possible values.  If set to True it will output short status notes at specific segments throughout the program.

I recommend running the program every day, more often is possible but seems like overkill unless your committing at a rapid pace.  As such, my crontab entry:

0 0 * * * /root/verify_svn.py


The Blue Pill:
First and foremost, this is by no means a 'perfect' piece of software.  First, it has no error checking what so ever, so it doesn't fail gracefully, on the other hand the worst its going to do is attempt to do comparisons on things that make no sense and generate some nonsense output.  Second, it relies on the fact that if you generate stdout output in a crond execution that output is captured and emailed to the owner of the crontab (in my case root, who also owns SVN and the repositories). 

The Red Pill:
That all said, it works and pretty well if a bit slow.  The svnadmin verify command is by no means a quick command even on a small repository.  On a large one it takes as long as ten minutes to execute.  However it does it's job which is to run a verify on all of our repositories every night and notify us if there are any issues (of a nature that verify can detect).  Two possible areas of improvement that I've considered up till now but haven't done anything with is allowing command line arguments and making it work with Nagios somehow.  Command line arguments are pretty easy to get up and running, but undo the whole compact one place to find all the info feature I like about the current implementation.  On the other hand it will be a must if I want Nagios support.  Nagios on the other hand is no nearly so easy, I'm not sure how I would even go about it, but it would prove supremely useful in our overall monitoring strategy where I work.

Entire code:

 #!/usr/bin/python
 #SVN Repository Verify.
 #The script is released under the MIT License, because I really don't care what 
 #you do with it, so long as you don't claim you wrote it.  This code is released
 #with no warrantee, and free to use under the license at the bottom of the file.
 #It should be further noted that I probobly will not spend a huge amount of time updating
 #this script unless I get a compulsion to add some sort of Nagios support to it, 
 #or find a tragic bug in need of fixing.

 #This script was written under the shadow of a fairly severe and irrecoverable 
 #error that one of the SVN repo's I'm responible for experienced
 #this error, one of the many 'line length' errors, is detected by the svnadmin 
 #verify command.  But goes undetected between commits until you hit
 #the issue again.  So I've just put together a short script to run every night (or whenever)
 #using the svnadmin verify command and reporting the any errors.

import os #import os tools.
from platform import python_version #get the python version tool

#this part is messy due to the fact that 'getoutput' is moved from 'commands' to 'subprocess' in python 3.0
#as such I test for the version of python, and adjust the import of 'getoutput' accordingly.
pyversion = python_version()
pyversion = pyversion.split('.')
if eval(pyversion[0]) < 3: #check major version
 from commands import getoutput #retrieve getoutput from commands if py version less than 3.
else:
 from subprocess import getoutput #retrieve getoutput from subprocess if py version 3 or greater.


def main():
 # Setup
 # -The paths asked for below should NOT be relative.
  
 #Provide the path for svnadmin ( this could be replaced with a 'which' command 
 # but i'd rather leave nothing to chance with 'cron', which never behaves well assuming paths.)
 svnadmin_path = '/usr/local/bin/svnadmin'
 svnadmin_path = os.path.abspath(svnadmin_path) #path cleanup
 
 #This is either your single repository path, or the root of multiple repositories.
 repository_path = '/location/of/repository/' 
 repository_path = os.path.abspath(repository_path) #path cleanup
 
 #would you like to use the repo path as a recursive repository root with subdir repositories or as a single repository
 recursive_path = False
 
 #Do you want lots of useful output, or just a bit at the end?
 verbose = True
 
 paths = [] #establish the empty array of path strings.
 
 #if the path is recursive, generate a list of the paths to be verified.
 if recursive_path:
  
  if verbose:
   print 'Recursive Mode Directories:' #if verbose, output recursive mode notification
  
  ls_of_repo = getoutput('ls ' + repository_path) #dump contents into a local string
  ls_of_repo = ls_of_repo.splitlines() #split the string into an array of strings.
  
  for item in ls_of_repo:
   temp = os.path.join(repository_path,item) #generate an actual path for every item in the repository root
   if os.path.isdir(temp): #if the item is a directory add it to the list of paths.
    paths.append(temp)
    if verbose:
     print temp #if verbose, output path

 #else use the repository path on it's own.
 else:
  paths.append(repository_path)
 
  if verbose:
   print 'Single Directory Mode: ' + repository_path #if verbose, output repository path

 #create a basic array to hold errors.
 errors = []
 
 for path in paths:
  if verbose:
   print 'Currently running svnadmin verify on: ' + path # if verbose, output current verify target
  
  log = getoutput(svnadmin_path + ' verify ' + path) #run svnadmin verify on the path
  log = log.splitlines()
  #errors.append(process_log(path, log, verbose))
  errors += (process_log(path, log, verbose))
 
 
 #I'm using this as a cron job, so all I actually have to do is print to stdout and 
 #the owner of the cron job will get an output email.
 
 if errors != []:
  print 'Current SVN Verification Errors'
  for error in errors:
   print error
 
 return 0
 
def process_log(path,log,verbose):
 #this functions entire job is to return a list of error strings from a provided log.
 #the path value is simply a header it could be anything
 errors = []
 for line in log: #process log line by line
  temp = line.split(" ") #split each line to test for the normal 'verified' responce
  if temp[0] != '*' and temp[1] != 'Verified':
   errors.append( path + ": " + line) # append the path and error message to the error log if it fails.
 
 return errors
 
if __name__ == '__main__':
 main()
 
# Copyright (c) <2009> <Garrett McGrath>

 # Permission is hereby granted, free of charge, to any person
 # obtaining a copy of this software and associated documentation
 # files (the "Software"), to deal in the Software without
 # restriction, including without limitation the rights to use,
 # copy, modify, merge, publish, distribute, sublicense, and/or sell
 # copies of the Software, and to permit persons to whom the
 # Software is furnished to do so, subject to the following
 # conditions:

 # The above copyright notice and this permission notice shall be
 # included in all copies or substantial portions of the Software.

 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 # OTHER DEALINGS IN THE SOFTWARE.