jScripts - jQuery and Google prettyPrint

Sunday, June 28, 2015

Minimal pure CSS Treeview with FontAwesome expanders

Look ma, no JavaScript! :)

Leveraging (hidden) checkbox element to maintain expand/collapse state and
:before {content: "xyz" }
 to avoid extra elements.
Not an original idea but wanted to see of i could trim down all the extra html markup & css required.
Turned out swell! The <input> is the only additional overhead above standard markup, sahweet!

Sunday, June 14, 2015

External Content in Blogger Post

  • pull content from 3rd party source, using crossorigin.me (CORS proxy) to avoid "no 'access-control-allow-origin' header is present on the requested resource"
  • from what i can glean, Blogger does not offer any kind of server side include facility so we have to resort to client browser tricks and that means this content is NOT going to be crawled/googlable
  • this approach relies on jQuery (Core) so you'll need to have that referenced as well - example here, but also make sure you point at the latest version

drop this helper function in a global JS/HTML widget via the Blogger Layout editor...
function pluginContent(url, containerSelector, boolPrettyPrint) {
function pluginContent(url, containerSelector, boolPrettyPrint) {
  var ctrl = $(containerSelector);
    .done(function (result) {

        //force prettyPrint rendering after loading dynamic content
        // google on: "google code prettify" to get dialed in on this code syntax highlighting library
        // => https://code.google.com/p/google-code-prettify/wiki/GettingStarted
        if (boolPrettyPrint) {
    .fail(function() {
      ctrl.html('failed to retrieve external content.<\br>'+
        'try going there directly: <a href="'+url+'">'+url+'</a>')

Then use it like this in an individual blogpost:
<pre class="prettyprint linenums lang-powershell" id="prePoshDualExplorers"></pre>

  //pull code content from codeplex
  pluginContent("https://beejpowershell.svn.codeplex.com/svn/PoshDualExplorers/PoshDualExplorers.ps1", "#prePoshDualExplorers", true);

PowerShell Dual Windows Explorers

  • Nutshell: Hosting two Windows File Explorers inside a WinForm... with the potential of sprinkling some utility hotkeys on top - e.g. "copy from left to right".
  • latest powershell source code
  • Always wanted to try this and just finally got around to it... and it actually works to a decent degree.
  • This is obviously well covered ground with various other file managers... i just wanted to see if you could do it this poor man's way with PowerShell driving... so one could take it and make it one's own, w/o having to get into big C# compile fest... it's all relative of course
  • The obnoxious part is hunting down the COM interfaces necessary to pull stuff out of FileExplorer... it dips into silliness like how IE is somehow part of the equation.
  • See comments for all the good posts i drew from to cobble it together... lots of handy Shell programming nuggets to be had
  • oh yeah, thanks to a handy github project, Font-Awesome is now in the WinForms domain - too cool
  • notes to self
    • interop.SHDocVw.dll is generated from doing a Visual Studio reference to C:\windows\system32\shdocvmw.dll
    • interop.Shell32.dll seemed like it was going to come in handy but didn't wind up being necessary
    • these are the only real FileExplorer API calls necessary for the CopyFile piece
      • $objFolder = $objShell.NameSpace($explorerRight_SHDocVw.LocationUrl)
      • $objFolder.CopyHere($explorerLeft_SHDocVw.Document.SelectedItems())
    • there are a few wacky interfaces behind the shell objects but the neat thing is that runtime dynamic type binding makes using real types largely irrelevant... i feel that does lose some self documentation in the balance so i've tried to include the pertinent interfaces in the comments for future reference and expansion

Sunday, April 5, 2015

Yosemite Hackintosh VMware Fusion 7 Bootcamp

Current Versions:

  • Yosemite v10.10.2
  • VMware Fusion Pro v7.1
  • Tuxera NTFS v2014


  •  Paragon v12 for Yosemite wasn't recognizing the NTFS volumes, so switched to Tuxera and it seemed to work better
  • Seemed like unmounting the recovery partition on my main Windows drive kept Fusion from trying to pull that in as the Bootcamp drive
  • Fusion took a very long time to process my main Windows boot drive... probably over a half hour with no progress status the whole time... apparently we  just have to be very patient

Saturday, April 4, 2015

Installing Yosemite on native hardware via VMware

General guide for installing physical boot OS X from a Windows VMware hosted guest instance. Including some specifics for Yosemite, the Clover boot loader and my hardware.

The "MBR Magic Hide Trick" is the sneakiest part ... I'm very grateful those guys came up with any workaround because otherwise not able to write to the physical drive is a show stopper :) Tying a VM to a physical disk like a peppy SSD just seems like such a natural thing to do it's kinda amazing VMware hasn't gotten slammed into addressing this issue over the years of upgrades.


  • I tend to shuffle things around enough that I don't always have a working hackinstosh available. My MacBook pro is circa 2007 and stops at OS X 10.7.5, which doesn't run all the latest tools. Therefore the ready-to-run VMware Yosemite images out there are a convenient bootstrapping approach.
  • I had trouble getting my USB stick to boot with Clover – which appears to be a known issue on my mobo (Gigabyte X99-UD4) – so on the way to prepping a USB for UniBeast, I figured why not see how tough it is to install directly from the VMWare guest to my intended physical drive and skip the USB process.
    • This approach turned out nicely... I wonder why one doesn't see it mentioned more often in all the guides out there... perhaps the all the bits one must line up to support the VM equate to the same hassle as creating a USB boot... but having a full working Yosemite environment at all times is a nice advantage over the limited options of an OS X installation thumb drive.

Hardware as of this guide:

    • Mobo: Gigabyte GA-X99-UD4 - LGA 2011-v3
        • bios: F12
          • onboard ethernet: Intel I218-V (kext required)
          • onboard audio: Realtek ALC1150 (vanilla support)
          • CPU: Intel i7-5820k - 6 core Haswell-E (vanilla via Clover flags)
            • Video: Asus Strix Nvidia GeForce GTX 750Ti 2GB ... this card is a perfect fit in my book:
              • No drivers necessary to install & boot into Yosemite - indeed low res no QE/CI but very workable for initial install and then full QE/CI drivers are easily installed.
              • I can confirm this card supports at least dual monitors on DVI & DP under Yosemite with the DP side driving at least 2560 x 1600 res... I've seen mention of possible 4k support but don't have screen to confirm that.
                • fanless unless pushed hard
                  • 3 x digital display, INCLUDING DP
                    • no more horsepower than I care to pay for => $160 at the time
                    • lastly it was well stocked in major outlets circa April 2015

                  Obtain Software Bits:

                    Software versions only listed for reference as of this build, not crucial unless noted.
                    1. VMware Workstation (v11.1)
                    2. Yosemite VMWare image (v10.10 14A389) - this package includes crucial patches enabling OS X guests
                      1. My app store Yosemite install turned out to be v10.10.*2* (14C109) even though the vmware image was running v10.10.
                      2. OS X version can be confirmed by hitting the "Startup Disk" button at the end of the installer.
                    3. Yosemite via App Store download - get this download fired up as soon as you can get into the VM since it's big and takes a while
                    4. Clover (v2.3k r3241, change descriptions)
                      1. while UniBeast covers more hardware situations, if your hardware is lined up for it, Clover is pretty slick
                      2. particularly the EFI footprint which stays intact when you manage to scramble the main boot partition due to black screen reboots
                      3. Couple nice bits for this hardware
                        1. HaswellE kernel patch checkbox
                        2. no fuss iMessage NVRAM checkbox
                      4. Clover Configurator (v4.23.0) - very very handy, seals the deal on Clover
                    5. KextWizard (v3.7.11) - one handy feature above other more well known kext loaders, it will target another drive which is perfect for this side-load scenario
                      • Kexts
                        1. FakeSMC - bare minimum for everybody (classic DSMOS avoidance)
                        2. AppleIntelE1000e (v3.1.0) - for X99-UD4's onboard Intel I218-V ethernet
                        3. VoodooTSCSync patched for 6 core (this hardware) - author site says this addresses "spin lock" issue
                      • Nvidia's web driver
                        1. *** Updating Nvidia web driver *** - black screen issue
                          1. add nv_disable=1 boot flag
                          2. boot up, hopefully works
                          3. install new drivers
                          4. remove nv_disable=1 
                          5. reboot, hopefully happy now
                        2. 750ti guide

                      BIOS settings:

                      1. SATA controller in AHCI mode
                      2. xHCI = manual, xHCI handoff = disabled - (Reference) i think this is a USB3 compatibility thing

                      VMware Guest Configs:

                      1. add 'smc.version = 0' to the VMX file in order to resolve error: vmcore/vmm/main/physMem_monitor.c:1123
                      2. In addition to the main vmware virtual drive that your guest OSX boots from, add your physical disk to the guest
                        1. i found SATA interface to *never* work vs IDE or SCSI... SCSI gave some minor warning so i went with IDE / full disk / persistent
                      3. MBR Magic trick to allow boot utilities (e.g. Clover installer) under vmware guest to write to physical disk:
                        1. In my experience, on Windows 8.1, simply taking the drive "offline" via DiskManagement was not enough
                        2. ** This must be done BEFORE firing up vmware guest
                        3. hide the physical disk from Windows by temporarily clearing the "MBR magic" signature in the very last 2 bytes of sector 0 (see DirectDisk tool screenshot below)
                        4. then refresh Disk Management (or DiskPart.exe > rescan) and the drive will show that it's now completely unknown
                        5. now put the 55AA signature back so the Mac guest can see the drive - but be careful not to refresh Disk Management or DiskPart
                        6. now fire up vmware guest and you're good to slam that drive all day long
                      4. couple more tidbits i learned the hard way... 
                        1. it seems pretty crucial to format the drive in GPT vs MBR even thought we're talking about an MBR cookie
                        2. starting from a completely bare drive 
                          1. just format it as GPT & Journaled with a single partition
                          2. Clover install will add the EFI partition
                          3. and either Yosemite install or the Recovery script with add "Recovery HD" partition
                        3. on the VM image i had major kernal_task CPU crunches that would storm in and bring everything to a halt... guessing thru googling that some IO kext is getting hung up... i disabled sleep and that went away, no big surprise.

                      Install Steps:

                      1. Fire up the VMware OS X guest on pre-installed virtual Yosemite image (Bits 1 & 2 above)
                        1. BEFORE launching OS X guest, perform "3. MBR trick" above
                        2. if you install the darwin.iso tools () the resolution does get a nice little bump from 1024x768 to 1920x1080... and it seems to be slightly more responsive
                      2. Install Yosemite to the physical drive via Apple App Store download
                        1. I count 3 restarts (few mins stuck on 1 sec remaining, then maybe a 20 mins run) - the 3rd and final looped me back to the beginning of the install, so then just bail out and reboot back into virtual Yosemite
                        2. If you wind up hosing that last profile setup stage like i did :| this article is handy :)
                        3. Recommend selecting the virtual disk for startup as convenient to making repairs on the broken physical from the working virtual
                      3. Install Clover via Configurator (too easy!!)
                        1. Boot tab:
                          1. -v - verbose, you're going to want to watch for any clues if it blows up
                          2. npci=0x2000 - everybody says this one is crucial
                          3. nvda_drv=1 - (my hardware)  enables Nvidia web driver
                          4. kext-dev-mode=1 - this means load unsigned kexts
                          5. slide=0 - pulled this from a guide (not sure necessary)
                        2. Kernel and Kext Patches
                          1. KernelHaswellE (my hardware) 
                        3. Install Drivers
                          1. HFSPlus UEFI (under "Extra Drivers")
                          2. remove VBoxHfs (under "Drivers UEFI 64 Bit")
                        4. Copy kexts to EFI\EFI\CLOVER\Kexts\10.10
                          • FakeSMC
                          • VoodooTSCSync (only for 6/8 core support, my hardware)
                      4. AppleIntelE1000e (my hardware) - install to traditional /S/L/E via KextWizard... didn't seem to work when loaded from EFI\CLOVER\Kexts
                      5. *** You should now be able to reboot into this new physical OS X
                      6. Play it safe, do a Time Machine backup of this pristine install before you do anything else to screw it up, *** especially before the Nvidia drivers ***, i've had them black screen me... but if that happens, follow the notes under "Updating Nvidia" above
                      7. Last juicy step is to go ahead and install latest full Nvidia web drivers (Tip: confirm your specific OS X build via Finder > About This Mac > and hold ⌘ when you click the version number :)

                      Misc tweaks:

                      • DiskPart cheat sheet
                      • XtraFinder - F2=rename, Enter=launch file, Delete=delete file, dual pane tabbed Finders and tons of other must haves
                      • Fix Home/End keys
                      • Show All Drives in DiskUtility: defaults write com.apple.DiskUtility DUDebugMenuEnabled 1
                      • Enable Time Machine saving to Windows share (smb)
                        1. Save a "sparsebundle" image to your share via DiskUtil > new image... 500GB or whatever... it's "sparse" so it won't use all the space right away... go with "Single Partition - GUID" and Journaled
                        2. "Mount" your share via Finder ⌘-k, confirm by Finder > prefs > SideBar > Devices > {your machine}...  look for share as a drive icon there
                        3. Double click the sparsebundle to get that mounted as well
                        4. Terminal: sudo tmutil setdestination /Volumes/{sparsebundle drive}
                        5. Fire up Time Machine prefpane and select that drive, yay!
                        6. Use Users prefpane > Login Items to make the two mounts automatic after reboots so that Time Machine has continuous access to do its background backup magic
                        7. CONFIRM THAT YOU CAN RECOVERY RESTORE from this unsanctioned source
                        8. you could setup a bootable Clover recovery partition
                        9. but i ran aground going that route with what appeared to be permissions issues after modifying the BaseSystem.dmg to include my NIC kext... so i'm of the opinion that the virtual OS X serves this "recovery" purpose nicely... it's a resilient solution because if we somehow trash it, we just unzip the 100% working source vmdk again and spin back up fresh.
                      • Mounting EFI partition under windows
                        1. cmd.exe
                        2. diskpart
                        3. list disk (looking for your boot drive)
                        4. select disk 1
                        5. list part
                        6. select part 1 (EFI will be first on a normally formatted GUID drive)
                        7. assign letter=e
                        8. (when done) remove letter=e
                        9. Then need to launch explorer.exe as admin to access this E: drive
                          1. cmd.exe as admin
                          2. taskkill /im explorer.exe /f
                          3. explorer

                        MBR Trick:

                        Saturday, December 13, 2014

                        Chrome Blacklist Blocker (PowerShell)

                        If you need this, you'll know why ;)

                        Save ChromeBlacklistBlocker.ps1 somewhere local.

                        You can run it via right mouse > "Run with PowerShell".
                        It will dump out some event text whenever it notices a registry change.
                        (this is currently commented out and latest code hides the powershell console window after launch)

                        Or more permanently, put a shortcut like this into your auto "Startup" folder:
                        powershell.exe {path}\ChromeBlacklistBlocker.ps1

                        It will monitor the HKLM\Software\Policies registry branch and delete the value named "1" under Google\Chrome\ExtensionInstallBlacklist.
                        This value is specific to my scenario but is of course editable to your specific needs.

                        You can test it is working by creating the "1" value yourself and it should disappear.

                        Another good way to test is to fire gpupdate.exe force a group policy update - again, if you need this, that should make sense :)

                        More Google search keywords: block registry key

                        Tuesday, November 18, 2014

                        Open Source Photo Slideshow in Powershell

                        All Source


                        • Good randomization - One soon learns that a key feature of a photo screensaver is good randomization. Fortunately PowerShell has a readily available random commandlet that seems to do quite well.
                        • Skips .hidden folders
                        • Several hotkeys defined - open current image folder, copy current image to My Photos, rotate current image (and save), back up to previously shown photo and pause.
                        • Easy to modify for your own preferences - it's just PowerShell

                        I borrowed baseline code from the project referenced in the comments to generate the few Windows Forms GUI objects necessary to provide a topmost canvas for the current photo.