Winter Cleanup Code release
Thursday, January 27th, 2011This is a release of all old code which I found on my harddrive, related to many different projects and of different age and quality. Feel free to browse, download and use all of the code on this site. I would appreciate a backlink, but this is no must.
The code has been compressed with 7zip.
License
Unless otherwise stated all code referenced in this post is released under the Apache 2.0 open source license.
Please double – check the code before using, I can give no warranty of any kind for its fitness for your purpose or good behaviour. Some code may be yet in unfinished and untested state.
Some tools and code included in my downloads originate from other authors. They have been included for your convenience, please read and respect their licences. If some license owner is unhappy with me putting their tools into my downloads, please contact me to resolve the matter.
Code
1. Google Analytics Batchpatcher
This is an application written in Ruby, and designed with a GUI Builder (foxGUIb) based on FxRuby. It has been processed with Erik Veenstras & Cowlibob's Rubyscript2exe to create an executable package ready to run on systems without Ruby (which should be the most).
It's purpose is to patch a lot of HTML files simultaneously, inserting code (it must not necessarily be Google Analytics code) just before the <\body> closing tag.
Usage
Select the work directory (preferably a copy of your live files!) using the directory browser on the right by double clicking. The folder selected will be shown on top. The Application will automatically recurse in subdirectories.
Set the file filters (the last one allows you to set an arbitrary extension). The default selected ones are .html and .htm
Enter the code you want to be patched in under "Google Analytics code". This can be any kind of code.
Hit "Patch!", and be patient – especially for large file sets. After the application has finished processing your request, you can see what has been processed in "Output".
The application will search for some "magic strings" to ensure that the file has not already been patched / incorporates Google Analytics code. This will only work for the old Google Analytics code, it will patch in copies of other code every time you run it. Unfortunately, this "magic strings" will not work for the newest version of Google Analytics code.
Known Bugs and Problems
- Apparently it hits UAC when you start it in Windows 7 (perhaps because it has a directory listing component?)
- The application will seem to hang on a very large fileset, it will update the progress output only after processing all files.
- There is no "dry run" option – once you hit "Patch!" the application starts processing
- "Umlauts (ä ö ü)" will display incorrectly in the log output, but they will be processed (this is probably a limitation in Ruby's handling or rather lack of handling of UTF-8)
- With the newest version of Google Analytics code, this tool can't recognize if a file already includes the code – and would patch it twice. Use a tool like HD Search and Stats to find these files.
Download
- google-analytics-batchpatcher (EXE, for Windows)
- google analytics batch patcher source (7z, includes foxGUIb and rubyscript2exe under their respective licenses!)
2. Miscellaneous Ruby scripts
Somebody may find a useful approach to some problem here. Remove the .txt extension before using the file, it is just for download purposes.
- removecuesheet.rb
Interacts with Foobar to remove cuesheets from APE (Monkey audio) files - addcuesheet.rb
Adds cuesheets to APE (Monkey audio) files using Foobar. You need to edit the script to provide the correct location of Foobar for instance. - htmlnuke.rb
Deletes all html files in the folder it is run in - killindexhsub.rb
Deletes all index*.html / index*.htm files in the folder it is run in and all subfolders of it recursively - timer.rb
Plays a sound file every 30 seconds using the Windows32 API (that's the interesting part I got off some Ruby website!) - ruby.ebutcher
This script reads a webpage (which you would need to set up and modify the script accordingly), and monitors the running processes in your (Windows) system. On start it kills all "offending" processes immediately, later it waits for a random time before killing or freezing the processes. The tool needed to do this is included (its the one by SysInternals, thanks!)
It is intended to serve as a crude "babysitting" tool, which does not give itself away too easily.
