/* BeejBlog */

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...

SOLVED: Skip the admin UI and simply modify the database => select * from wp_options where option_name like '%link%'

PowerShell Photo Slideshow

GitHub Source

Project Description

Photo slideshow implemented in PowerShell -> Windows Forms

Simply target a local/LAN folder of images.

Features:

  • task tray icon to start slideshow on demand…
  • otherwise kicks off after user defined idle timeout (honors running video)
  • good randomization - one soon realizes pleasantly random photos are the key want of a photo slideshow … fortunately PowerShell has a readily available random commandlet that seems to do quite well
  • image fade-in and slide for ambience
  • several hotkeys functional:
    • open current image folder
    • copy current image to My Photos
    • rotate current image (and save) - specifcally coded to honor EXIF rotation metadata where present but sometimes this gets lost
    • reverse to previously shown photo (left cursor)
    • pause/play (space)
    • hotkey legend pops up on any other keypress
  • skips .hidden folders
  • open to modification - it’s just PowerShell :) no compiling tools required

Install - basically just launch the ps1… here’s some tips:

  1. only the ps1 and ico files are needed, download them to a folder
  2. (see screenshot below) create a shortcut to the ps1 and tweak the target to include powershell before the ps1 filename…
  3. select Run: Minimized to make script launch more polished
  4. add -WindowStyle Hidden after powershell.exe on target command line for further polish
  5. then hit the Advanced button and select Run as administrator - this is only required for the powercfg /requests used to identify running video and avoid starting slideshow after user input idle timeout (wouldn’t mind hearing a slicker approach???)
  6. script parameters:
    • add -photoPath {path\to\your\images} to the end of the shortcut path - shared folder fair game
    • add -idleTimeout 2 to the end of the shortcut path - units are in minutes
  7. Copy this shortcut to shell:startup in Windows FileExplorer to automatically launch this script when you login to your desktop

Wishlist

  • show videos as well - thinking VLC convenient… would need to pause image display loop and figure out how to recognize when VLC was done playing… would be nice not to keep launching new VLC instance vs reusing

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 boat - it 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 - … to put another way, since my Active PFC (see below) PSU puts my overall PF nearer to 1 vs 0.6, my Wattage load is the critical dimension to satisfy vs VA… to work back to a UPS VA that would support 304 Watts => VA * 0.6 = 304 Watts… VA = 304/0.6 = 506… so at minimum I am looking for 560VA/304Watts

Secondary Considerations

  • I’m an Amazon junkie, I typically check off Amazon prime and then scan similar products for a high number of positive reviews… in the consumer UPS space (+/- $100 range) it’s really a matter of CyberPower vs APC… The APC BE550G is the obvious best rated at 4.5 stars 3218 reviews…
  • Generator Compatibility!
  • AVR - Automatic Voltage Regulation - like all marketing, it sounds good… smooth out your voltages in brownouts, but I couldn’t find enough concrete evidence to say whether it was significant
  • Replaceable battery - the APS and CyberPowers both appear to be readily servicable
  • Info Display - I’m kind of a sucker for the LCD
  • Software - it’s tough to find specifics on the APC & CyberPower software beyond turning off the beep and setting up automatic shutdown… i was somewhat interested in something that would actually log power consumption over time to give me some “Kill A Watt” style info… since the software does show Watts it seems feasible to think i could reverse gen the USB info and record it (like i’ll actually get around to that ;)
    • Apparently CyberPower is Mac & Linux compatible whereas APC is Windows only
  • Leaning towards CyberPower CP600LCD = $65 @ 2015-11-23

Active Power Factor Correction (APFC)

  • the PF < 1 waste drives marketing of modern PC PSUs to trend towards Active Power Factor Correction (Active PFC) which means the PSU corrects the raw electronic load back to a PF = 1… and can thereby boast higher efficiency, which sells
  • through a fun combination of physical constraints, the kind of electric equipment humans could readily produce and politics at the outset of power distribution, modern society settled on high voltage AC and the momentum of large investments required have kept it that way…
  • further, current is most readily generated by rotating mechanisms which lead to a smooth “harmonic” curve of voltage highs and lows over time, i.e. the oft referred sine wave… hence our electric grid was founded on smooth sine wave current
  • and it’s therefore understandable that cost effective electric equipment would actually depend on a smooth sine… and apparently some Active PFC PSU’s implementations are indeed sensitive to having a pure sine wave input…
  • yet it is also cost effective for UPS’s to convert their DC battery source into AC via electronic approximations that yield a “stepped” wave vs the smooth sine we see from our power grid … this stepped sine is what dominates the consumer end UPS space (Fig.1)
  • the main downside of this potential conflict is that the fail-over from wall to UPS battery during a power outage may still cause a PC power cycle…
  • Nevertheless based on my quick reading, we should generally rely on contemporary hardware to be compatible and the only way to really know for sure is to find a published test or test it yourself… the simple test is to unplug the UPS and see if you get a reboot or not :)

Fig.1

Transcode MOV to MP4

Motivation:

Digital cameras and phones typically save video to MOV (Motion JPEG) files. I share my photos & videos via a self hosted open source photo gallery (zenPhoto). MOV files must be converted to a compatible format like MP4 to stream through the readily available web video players like Flowplayer.

Script features:

  • Handles multiple files at once… even from different folders when part of an explorer search result
  • Applies rotation where necessary.
  • Touches new file datestamp to be same as original.

Leverages 3rd party tools:

  • FileMenu Tools - handy for creating a FileExplorer right mouse context menu for executing transcode on selected files
  • HandBrake - read something that suggested HandBrake is faster than ffmpeg and that appears true on my quick comparison
  • MediaInfo - pulls the EXIF metadata to determine if any rotation is necessary

Install:

  1. save transcode.ps1 below into a known location
  2. install FileMenu Tools and disable all the commands you don’t want. Configure a “transcode” command as shown in screenshot below (of course edit your ps1 file path accordingly)
  3. install HandBrake and put HandBrakeCli in your path
  4. minimally, put MediaInfo.exe and MediaInfo.dll in your path

transcode.ps1


Example UI

enter image description here

FileMenu Tools Config

enter image description here

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);
enter image description here
enter image description here

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

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)

Biggest gripe - the Corsair USB stuff is total junk... It sounds cool to be able to monitor temps but it is so bad I would seriously recommend against it... I traced OS X re-wake back to the H80i cooler and the drivers are all super flaky under windows... reports of all kinds of known issues installing on Win8 and above out there on the interwebs... even with the well known hacks in place, only some rare reboots would yield working gauges for me... looks like USB device initialization timing bugs... sounds neat at face value but the unreliable drivers ruin the whole experience... there are open source alternatives brewing... guess there's a new build up for Win10, we'll see how that goes.

2015-09-03 Update: Spooky! Machine was just totally dead this morning, no power up at all ... jiggled the usual stuff, manually shunted the mobo power-on pins, re-seated ram, nothing... was expecting dead PSU but it checked out fine on voltmeter... and test button on PSU revved up the fans just fine... so next i started figuring dead mobo and was basically giving up ... then the big guy nudged a thought into my sad mind, "try the paperclip trick"... so i shunted pins 15 & 16 on the back of the 24pin header (while PSU connected to mobo) and sure enough it all powered right up <whew>... after that the case power button was working normally again as well... no other changes...

very interesting behavior ... really grasping to place blame anywhere particular  ???


i shudder to think of the time and effort i could have easily wasted swapping out working components chasing this ghost

we did have a power outage here a couple days ago but the machine had been running fine since then; even going in and out of sleep mode so it's hard to think there would be something "lingering"... yet there i was