WordPress Append HashTag to PermaLink

Motivation: Running a site with a big banner header — of course this decision must be weighed itself — on a user screen with low vertical res (e.g. 1024 x 768), the homepage would only show the header link of the first post summary (we’re also using “Add Posts to Page” plugin, with it’s ‘read more’ summary function)… clicking on the post would then nav to relatively same thing, staring at a big banner.

Simple potential solution: Quick inspection of page structure proved that simply jumping to #main would do dandy to scroll content well into view… it seemed like a simple matter of selecting wp-admin > Settings > Permalinks > Custom Structure and slapping #main on the end… but no, of course that’s too easy…WP strips # hash tag out upon save… searched around quite a bit and all suggested solutions are long hacky affairs of forcing the jump after the page is rendered…

... READ MORE ...

ScreenShot2015-12-19at9.36.43PM

PowerShell Photo Slideshow

Snap4

Sizing a Battery Backup (aka UPS)

I live in the Seattle area, apparently we get a nice windy storm around every Thanksgiving… sure to form, we lost power for a nice long 24 hours starting 11/17/2015… so i finally ordered a low end generator… and then i started wondering about including a UPS for computer up-time continuity during the momentary brownouts that happen when the wind is jacking with our power grid.

Power Requirements

  • nice reference
  • Typical UPS units will be rated in VA (Volt-Amps) aka Apparent Power … and possibly in Watts aka Real Power as well
  • The difference between these two comes from concept called Power Factor… PF = Real / Apparent… quick backgrounder:
    • a “purely resistive” load like an old school incandescent light bulb will have a PF = 1 where VA and Watts are equal
    • whereas the typical implementation of AC to DC in a PC PSU represents an inductive load which causes the Amperage sine wave to lag behind the Voltage yielding a PF < 1 where some energy is “lost” – helpful physical analogy – see horse and boatit does beg the question where this energy is actually lost to… in the physical horse/boat scenario it’s easy to think it goes to friction/kinetic but i don’t have it pinned down in the AC/DC scenario… perhaps wasted in underutilized electromagnetic field
    Ideally your UPS will be rated for both their VA & Watts capacity but if only VA, then it is common to expect a UPS to handle Watts at 60% of it’s VA rating … i.e. 1000VA UPS should support 600Watts So now you need to know your power requirements… there’s a couple ways to go about this:
    1. take your PSU at face value… but how did you size your PSU in the first place… to be honest I just threw a dart when i went shopping
    2. add up your components’ ratings
    3. buy a cheap (~$20) device to measure actuals – this option is easy, inexpensive, satisfyingly definitive and it’s a nice bonus to go measure everything else in your house …
      • turns out my admittedly very non-gamer rig never went above 335VA (304 Watts, PF = 0.91) with maxed CPU and Gfx (Corsair HX750i PSU, Haswell-E 6 Core 5820k, Nvidia GTX 750Ti , 30” & 24” displays, USB speaker, USB mini network switch)
      • 300 VA just CPU maxed, no Gfx
      • 215 VA fairly idle
      • 144 VA remove 30” display
      • 75 VA remove 24” display
    Finally, working back from those numbers into a UPS means I not only need at least 335VA but I also need to watch out for 304 Watts… i CAN NOT simply go after a 335VA UPS since that would only support 201 Watts (335 * 0.6) … and we see this in typical UPS specs – notice the 650VA/390Watts

    ... READ MORE ...

Snap6

Transcode MOV to MP4

Snap2

Chrome User Script – Whack page elements based on jQuery seletors

// ==UserScript==
// @name VipLeague.se AdBlock Hack
// @match http://www.vipleague.se/*
// ==/UserScript==

function addJQuery(callback) {
  var script = document.createElement("script");
  script.setAttribute("src", "https://code.jquery.com/jquery-2.1.4.min.js");
  script.addEventListener('load', function() {
    var script = document.createElement("script");
    script.textContent = "(" + callback.toString() + ")();";
    document.body.appendChild(script);
  }, false);
  document.body.appendChild(script);
}

function main() {
  $("span:contains('Adblock is enabled')").remove();
}

// load jQuery and execute the main function
addJQuery(main);

... READ MORE ...

Bash script – loop over inline list of files

#!/bin/bash

#echo $BASH_VERSION

# read args:
# -r = disable backslash escaping
# -d '' = read the whole here-doc as one big input vs stopping stopping at the first new line as the default delimiter
# -a = put the results into an array
#the minus in "<<-" provides for indenting the here-doc lines, but with TABS ONLY
#bash4 is way easier but wanted to be portable: readarray -t arr <<-"EOT"
IFS=$'n' read -r -d '' -a arr <<-'EOF'
    /file/path/1
    /file/path/2
    /file/path/3
EOF

#echo ${#arr[*]}

# http://stackoverflow.com/questions/9084257/bash-array-with-spaces-in-elements
# disable default space delimiter
IFS=""
for filePath in ${arr[*]}
do
  stat "${filePath}"
done

unset IFS

... READ MORE ...

IMG_2724

2015Q1 Haswell-E X99 Build

Mobo: Gigabyte GA-X99-UD4 – LGA 2011-v3

CPU: Intel i7-5820k – 6 core Haswell-E

Cooler: Corsair H80i GT

PSU: Corsair HX750i

RAM: Crucial 32GB (4 x 8GB) Ballistix Sport (DDR4 PC4-19200 2400 MHz, 16-16-16 CAS)

CaseCooler Master Storm Scout 2 Advanced – love that rubber top handle!

SSD: SAMSUNG 850 EVO 500GB

Video: Asus Strix Nvidia GeForce GTX 750Ti 2GB … this card is a perfect fit in my book:

  • No drivers necessary to vanilla boot into Yosemite – no QE/CI out of box but very workable for initial install and then full QE/CI via Nvidia “webdriver”.
  • fanless unless pushed hard
  • 3 x digital display, INCLUDING DP – I can confirm this card supports at least dual monitors under Yosemite via any combination of DP / HDMI / DVI (dual- link) with any of them driving 2560 x 1600 res… I’ve seen mention of possible 4k support on this card and can’t wait to confirm that myself
  • no more horsepower than I care to pay for => $160 at the time … and was well stocked in major outlets circa March 2015

PC Hound build pricing
($1,675.26 pre-tax from Amazon on 2015-03-11)

... READ MORE ...

Installing Windows in UEFI Mode

For motherboard: Gigabyte GA-X99-UD4

Booting Windows in UEFI mode offers a couple mild advantages:

  1. it’s more compatible with Clover if you’re booting OSX this way already
  2. it’s supposed to be the fastest way to boot
Notes / Lessons Learned:
  • Rufus flash usb boot tool – wound up going with mbr and uefi-csm – not the normal recommendation
  • bios settings
    • fast boot didn’t seem to matter
    • legacy usb worked in disabled mode
    • worked with “other OS” selected
    • machine would not display bios after reboot whenever i disabled CSM (even though that’s what most UEFI guides recommendation)

    ... READ MORE ...

Minimal pure CSS Treeview with FontAwesome expanders

Update 2015-07-18: shux! not valid to apply ::before/after psuedo elements to <input> since it’s not technically content (stack-o reference)

jQuery replacement:

Works in Chrome and Safari but not Firefox or IE

Look ma, no JavaScript!

Leveraging (hidden) checkbox element to maintain expand/collapse state and

:before {content: "xyz" }

 css 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!

... READ MORE ...

External Content in Blogger Post

Highlights:

  • 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

Usage:
drop this helper function in a global JS/HTML widget via the Blogger Layout editor…

function pluginContent(url, containerSelector, boolPrettyPrint) {
  var ctrl = $(containerSelector);
  $.get("http://crossorigin.me/"+url)
    .done(function (result) {
        ctrl.html(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) {
          ctrl.removeClass("prettyprinted");
          PR.prettyPrint();
        }
    })
    .fail(function() {
      ctrl.html('failed to retrieve external content.'+
        'try going there directly: <a href="'+url+'">'+url+'</a>')
    });
}

... READ MORE ...