sortxml (week #22)

Tuesday, May 28, 2013 Labels: ,
This is a very simple utility that prettifies and sorts xml file nodes and attributes.

It is simple to use.


USAGE: sortxml.exe [options] infile [outfile]

  infile      The name of the file to sort, etc.
  outfile     The name of the file to save the output to.
              If this is omitted, then the output is written to stdout.

OPTIONS:

  --pretty    Ignores the input formatting and makes the output look nice.
  --sort      Sort both the nodes and attributes.
  --sortnode  Sort the nodes.
  --sortattr  Sort the attributes.

(prefix an option with ! to turn it off.)

The default is to output pretty and sorted nodes and attributes. So, given the following:

    $ type sample.xml
    <root><node attr="name" value="one"></node></root>
Would output the following:

    $ sortxml.exe sample.xml
    <root>
        <node attr="name" value="one">
        </node>
    </root>
I created this utility so I can use it as a File Format in Beyond Compare. Here is the gist of the File Format in BC3.

    Helpers\sortxml.exe --pretty --sortnode --!sortattr %s %t

Check out the source code at GitHub!

jQuery.deepShow()

Wednesday, May 22, 2013

I wrote this little snippet earlier today that ensures an object is shown even if one of its parent objects is currently being hidden. It does this, of course, by going through its parents and checking for the 'display:none' property..

/// <summary>
/// Shows the object and clears any style="display:none;" /// styles on all of its parents.
/// </summary>
jQuery.fn.deepShow = function() {
    $(this).parents().each(function() {
        if ($(this).css("display") === "none") {
            $(this).css("display", "");
        }
    });
    $(this).show();
}

menustack (week #21)

Tuesday, May 21, 2013 Labels: ,
menustackA nifty dynamically loaded menu, one menu item per file, useful for docking onto your taskbar for easy access to lots of applications/shortcuts.

It also includes a search field at the top, so when the menu opens you can immediately start typing to filter out menu items.

It is simple to use.

Just create a shortcut (link) to the menustack.exe file. Then edit the shortcut properties, specifically the target. This is the default syntax:

    menustack.exe --f filepattern filepath

The options are:

    --f filepattern

Specifies the files to show in the menu. This is generally a wildcard, such as *.exe, *.lnk, *.sln, etc.

    filepath

Specifies the directory to look for the files to include. This can be anywhere on your system. Be sure to include paths with spaces within double-quotes.

Here is an example:

    "...\MenuStack.exe" --f *.lnk "%UserProfile%\Dropbox\Shortcuts"

This will create a menu item for each file (*.lnk) in the Shortcuts directory.

File system details:

The files in filepath are automatically sorted alphabetically. However, you can customize that also. You can basically separate the sort key from the displayed menu text (file name) using the `]` symbol. For instance, in the screen shot above, the menu items are not alphabetical. This is because the files (the .lnk files) are named as follows:

    10] Chrome – Default.lnk
    10] Chrome (Profile 2).lnk
    10] Chrome (Profile 3).lnk
    20] Beyond Compare.lnk
    30] Sublime Text.lnk
    30] Visual Studio 2013.lnk
    50] Personal Projects.lnk
    60] Putty.lnk
    61] Winamp.lnk

It works pretty well. The search/filter is extremely inefficient and a bit wonky. But, it does the job!

Check out the source code at GitHub!

SublimeCycleWhiteSpace (week #19)

Tuesday, May 7, 2013 Labels: ,

Cycle's through Sublime Text's three options for displaying white space: none, selection, and all.

Many thanks to skuroda for his extremely helpful comment on Stack Overflow.

Check out the MIT-licensed source code on GitHub.

Features

  • Configure which options to cycle through in the settings.

Installation

Clone into your sublime packages directory.

Sorry, I haven't even looked at using Package Control yet.

Configuration

CycleThroughWhitespace.sublime-settings

Turn each option on or off here. If you want to alternate all three view options from your shortcut key, then set each to true. If you only want to alternate between selection and all, set only those two properties to true.

{
"cycle_whitespace_none": true,
"cycle_whitespace_selection": true,
"cycle_whitespace_all": true
}

Default (Windows).sublime-keymap

My default key bindings mirror that of Visual Studio. Feel free to change it to whatever you want.

[
{ "keys": ["ctrl+r", "ctrl+w"], "command": "cycle_through_whitespace" }
]
Older Posts Home Newer Posts