I really like the Diff Viewer that comes with TortoiseSVN, but from what I can gather it doesn’t seem to support anything but text files, which is fair enough, but I need to compare archives as well. Zip and Jar files in particular.
WinMerge supports that, and can be integrated with TortoiseSVN very easily right through its installer. But I prefer the diff viewer that comes with TortoiseSVN and the archive diff isn’t recursive by default, so I decided to set it up manually.
- Install WinMerge
(without the automagic TortoiseSVN integration)
- Install the WinMerge 7-zip plugin for archive support
(I couldn’t get the shared install to work, so had to use the application specific one)
- Open TortoiseSVN Settings, Diff Viewer, Advanced
- Add rows with extension set to .zip, .jar and whatever archives you want WinMerge to handle and set external program to the following:
C:\Program Files (x86)\WinMerge\WinMergeU.exe /r /x /e /u /dl %bname /dr %yname %base %mine
If I now for example ask TortoiseSVN for a Diff with previous version of a jar file, I get WinMerge with a recursive comparison of the archive contents. I also recommend that you deselect Show Identical Items under View.
Needed to recursively list all the files of a certain type and save them as an XML file. Turns out this was pretty easy using PowerShell.
# Make a regular .Net XmlTextWriter
$output = "processes.xml";
$xml = New-Object System.Xml.XmlTextWriter($output, $Null);
$xml.Formatting = "Indented"
$xml.IndentChar = " ";
$xml.Indentation = "1";
# Start writing
# Do the listing and keep outputting XML
Get-ChildItem .. -Recurse -include *.esbp |
$name = $_.BaseName;
$path = Resolve-Path $_ -relative;
# Close the writer, which also closes the root element and document for us
Keep running into scenarios where I need to scan through a file system and it’s actually pretty simple if you just know what classes to use. So… note to self and others:
// This should return false if there is something you want excluded
function filter($file, $key, $iterator)
$exclude = array('.git');
return ! in_array($file->getFilename(), $exclude);
// Recursive directory iterator for current directory, ignoring dots
$it = new RecursiveDirectoryIterator('.', FilesystemIterator::SKIP_DOTS);
// Wrapped by a filtering iterator with our filter function
$it = new RecursiveCallbackFilterIterator($it, 'filter');
// Wrapped by an iterator which automatically traverses children for us
$it = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
// And then just loop :)
foreach($it as $file)
echo str_repeat("\t", $it->getDepth())
This skips the annoying dots, properly excludes directories you don’t want and pretty much works the way it should.
Just discovered you can pull in external XML and other kinds of text directly through standard XSLT 2.0 methods. So here’s a note to self on how.
<!-- Single string URI -->
<!-- One or more URI from items, in this case a variable -->
<variable name="uri" select="'http://www.w3schools.com/xml/note.xml'"/>
<!-- Unparsed text, in this case escaped HTML -->
Sometimes XML becomes a bit weird with namespace declarations all over the place. This XSLT cleans that up. Stumbled upon in a StackOverflow answer I don’t find anymore and put here so I know where to find it in the future.
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@* | text() | processing-instruction() | comment()">
<xsl:for-each-group group-by="local-name()" select="descendant-or-self::*/namespace::*">
<xsl:apply-templates select="@* , node()"/>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
<cus:msisdn xmlns:cus="http://api.example.com/some-webservice" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">00000000</cus:msisdn>
<cus:ticket xmlns:cus="http://api.example.com/some-webservice" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">171</cus:ticket>
If anyone know how to adjust it to also merge the duplicated prefixes ns1 and cus, do let me know
I keep seeing people typing these lines in the console:
$ tail /path/to/some.log
$ tail -f /path/to/some.log
This is often a dumb thing to do. Why? Because you can’t really do anything with tail. What if you discovered you needed to look at something right above the lines you got printed out? Or what if you were -f’ing and something flew past you that you needed to investigate further? You’d have to leave tail and run it again with more lines or use a different tool instead. Not very practical.
What more people should do is to use less tail and more less
Things you can do with less
||Up one line|
||Down one line|
||Up one page|
||Down one page|
||Beginning of file|
||End of file|
|ctrl + c
||Next search result|
||Previous search result|
Much more flexible and handy than tail! Know your tools Now back to work…
Quick simple conditional select when creating a variable in XSLT 2.0. Also shows the
castable as check.
<variable name="id" select="if(id castable as xs:integer) then id else 0" />