/* BeejBløg */

Sep 7, 2018 - 1 minute read - Comments

Embed Github Content In Post

Intro

Went looking for this quite a bit and was surprised not to find anything obvious. Wondering why github hasn’t provided this directly. Obviously gist embedding is covered in spades… and WordPress has some plugins… why no love for the static web? Maybe it’s just too to easy to bother publishing ;)

Caveats

  • just for markdown so far
  • client side rendering (using ShowdownJs) - no SEO for you
  • using HTML5 “fetch” - modern browser dependency
  • instructions are Hugo leaning but this is vanilla js stuff usable anywhere

Example Usage

12345
* blah blah blah best post evah!

<script id="embed1"> renderMarkdown("embed1", "https://raw.githubusercontent.com/Beej126/PoShSlideshow/master/README.md") </script>

* nailed it!

Demo

Jun 9, 2018 - 2 minute read - Comments -

Self Escalating Batch

this is a great spin on Sudo for Windows.

it goes to some length to keep the input/output inside the current console - versus most other sudo approaches that simply launch the command in another elevated console window.

it pulls this off by clever trick of launching a hidden elevated process and capturing/forwarding it’s I/O to the original console via socket.

i’ve seen some tools have incompatibility with the stdin capture but this technique generally works beautifully.

self escalate as concisely as possible:

 1 2 3 4 5 6 7 8 9101112131415161718192021
:: net session is a concise way to determine elevation
:: https://stackoverflow.com/a/16285248/813599

:: || means logical "or"..
:: i.e. if net session doesn't trip ERRORLEVEL to 1 it means we're already elevated
:: and we just keep going, otherwise we fire this same file path under sudo

:: this sudo already only elevates where necessary so it would be nice
:: to eliminate the net session check but i can't think of a quicker way to
:: avoid the infinite loop... any ideas?

:: %~f1 means expand the full path of argument 1 (i.e. this script)
:: simple %1 would work in most cases but this is a good habit to get into
:: when you associate scripts to Explorer.exe context menus

:: note this doesn't pass any additional arguments
:: you could use %* for that but then you'd have to tradeoff the full path

net session >nul 2>&1 || sudo "%~f1"

::...rest of your logic...

Jun 3, 2018 - 1 minute read - Comments -

Minimal Pure CSS Expand/Collapse Widget

The gist here is leveraging a hidden checkbox to maintain expand/collapse state and css :before {content: "xyz" } to add the expand/collapse widget which keeps the additional markup minimal.

Markdown compatible :)

123456
<p></p><input type="checkbox" class="expander">
#### Expandified Heading
* bullet 
* bullet
* <input type="checkbox" class="expander"><i>another expander</i>
  * nested content that will be expanded