Tuesday, December 26, 2017

A Merry Christmas to us all; God bless us, every one!

Twas the Night before Christmas, when @realpresssecbot posted an image,
I was still browsing while Twitter glowed on my visage.
Merry Christmas it read, following dog whistles,
An itching it caused, as if sitting in thistles.

One of the very first responses that I saw to the original statement included a video mashup of former President and First Lady Obama saying "Merry Christmas." (Message me if it was you and I'll update this post to embed your tweet) Just in case the Republicans in my life and in my state sincerely believed the Statement by the President, I thought I should share this mashup video. I downloaded the file and shared it on Facebook from both my profile and my Page. The good thing about sharing from a Page is that you can boost the post.


I used my power to Boost the video into the Christmas Day news feeds of 35+ year old men in Maryland that like Donald Trump. This net will have caught some people that have told Facebook they are interested because they want to keep aware of what happens from the President, but it will mostly be older male Republicans. (AL exit polling showed that men still support DJT's messaging more than women and older more than younger)


Sadly, in a turn of events that will surprise no one, I did not have anyone thank me for removing their misconceptions. My personal profile post elicited one comment from a father of a high school acquaintance. He has been making a habit of posting sexist and racist comments on my posts so I was not surprised when a simple "Merry Christmas to all!" post was met with a "has been". Disappointed, but not surprised. I appreciate that he left off any racial slurs this time.


After nearly a day of running my post acquired 1,165 views with 452 of those making it at least 10 seconds in. (At 10 seconds the video has had "Merry Christmas" spoken 4 times.) The average view time was just 8 seconds, so the average viewer heard three "Merry Christmas"s. Two people shown the post chose to Hide All future posts from me which makes sense since Facebook generally works as an echo chamber and my targeted audience for this was Republicans. My Page is from when I ran for Congress as a Democrat.


The comments on the boosted post were what really got me though. Remember that this video was posted because the President of the United States has been regularly claiming that "Merry Christmas" was not welcome to be said before he was in office. If saying "Merry Christmas" is such a big deal to Republicans then a video of Barak Obama saying "Merry Christmas" on Christmas Day should be at worst ignored, right? That would be wrong. Over the course of today the post received two positive comments... "Merry Christmas", of course. The rest were pure vitriol and form quite a timeline through Christmas Day:

8:13 am

Greg Keeney: Fuck You

10:03 am

Chris Lunderman: You piece of shit

11:36 am

William Hidey: meme

William Hidey: meme

12:51 pm

Scott Carpenter: 1st and his pos

1:00 pm

Leon Issacs: Oh shut the hell up

3:13 pm

Charles Skinski: Fuck you no nothin politician

6:52 pm

Sean Lee Hughes: Fuck the prick and his family

7:10 pm

Chuck Snider: Fuck off

My reproduction here censored cases of incorrectly grouping either me or Obama into marginalized groups that we don't belong to. While the intended hate is clear it is neither a problem nor an insult to belong to the referenced groups. I have redacted the usage to keep from hurting readers by implying they are less if the labels apply to them.

I spent just under $10 to help establish common ground with my Republican neighbors over yesterday's holiday and considering that over 1,800 saw my post. Hopefully we can all agree that the phrase "Merry Christmas" was fully supported by the previous occupant of the White House. Some common ground has to be found for any meeting to be had, and a simple point like the President actively lies about easily disproved facts should be it.

To my Republican neighbors and family: do you want to continue to stand with Greg Keeney, Chris Lunderman, William Hidey, Scott Carpenter, Leon Issacs, Charles Skinski, Sean Lee Hughes, and Chuck Snider?

Saturday, December 16, 2017

Blocklisting dynamic paywalls on Google Chrome

Stop me if you have heard this one. When reading Twitter you find an interesting looking article linked. Before you outrage share it you decide to click through and read it.
It starts to load and suddenly you get this screen.

A dynamic paywall. Blast! Either you set up an account or you just outrage share based on the headline. I have a better solution! Type a magic url into the address bar:
chrome://settings/content/javascript


This brings up a simple looking settings page. You could toggle off the Allowed switch, but the modern Internet uses JavaScript for a lot of behavior. Your web browsing experience will suffer. Click the ADD button.

This brings up a popup text box "Add a site". Type in the fully qualified domain name: everything between the :// and the first /. www.nytimes.com is different than nytimes.com.


Once you hit ADD then you just go back to the page with the dynamic paywall. Hit REFRESH.

The page will load back up without the dynamic tracking and thus without the dynamic paywall.

This technique not only gets rid of the paywall this month, but forever.

Sunday, December 3, 2017

Introducing python module symcopy

Have you ever had a directory that you wished to copy the contents to another but you did not want to duplicate the file data? You use a symlink.

Now, what happens if you have migrated an entire directory to another drive and faked it with symlinks but then a Windows Update comes through and gets confused by your setup and refreshes your whole system?!

Oh look! Windows.old
I woke this morning to find that Windows Update had "fixed" my system. My symlinks were saved off in Windows.old and both Program Files directories were restored to fresh. Thanks, Windows.

To avoid reinstalling EVERYTHING, I decided to fix my problem from Windows rejecting my symlinks with... symlinks!
This would have been awful to type out and typing that many commands in an admin prompt can be a bit dangerous so I turned to my totally safe friend python. I needed to compare two directories, identify the items in the target that were not in the source, and create symlinks to them.
Don't worry about it being an image, I'm linking the Github.
The actual magic happens in that mklink function. I first implemented that as its own function because it was the first code I wrote this morning. Having it like that allowed me to easily test it before moving on. Once my problem was solved I decided to pip it up and share in case anyone (myself in the future...) has similar use cases, so the final version selects the correct command: ln or mklink.
I had never submitted code to pypi before so I prepared the package with the help of @mart0903.

And now: `pip install symcopy`
Demonstrated in docker: docker run --rm -it --entrypoint=/bin/bash python
PYPI: https://pypi.python.org/pypi/symcopy/
Source Code: https://github.com/SecsAndCyber/symcopy/

Saturday, December 2, 2017

Migrating %ProgramFiles% off of %SystemDrive%

Do not do this! I just had to do a fresh install of Windows 10 to finally get everything working again. Full disk format and install.

Yesterday I noticed a concerning state on my computer:
For a moment I wondered how I could have possibly filled that drive all the way up this fast. I just received this system in mid-October!

Oh yeah. I have games on here. Very, very large games. But I have that huge D. That should be able to relieve the pressure. So I set about copying both of my Program Files directories over.
 This took a while, as those two directories weigh in at 116 GB on disk for me right now. Once they were all copied I was left with another large problem: Windows uses stuff out of Program Files! There are open handles all over and so you cannot just move the directories. I needed to have access to my hard drives without Windows running. In the past (Windows XP days) this would have meant booting from an install media or booting up a Linux distro.

Thankfully, this is 2017 and I'm running Windows 10. There is now native support for rebooting into a diagnostic state that is not using your normal partitions. I followed the instructions documented by DigitalCitizen. Just pop open the Start menu and type Settings.

Click thru Update & Security and select Recovery.


 Once I was in the Advanced Startup screen I booted into Command Prompt.

For some reason my D: was mapped to C: and my normal C: was mapped to D:. It was a little weird. What I wanted to set up was NTFS junction points (symbolic links) at what my normal operating system thought was C:\Program Files and C:\Program Files (x86).

First, I made backup copies.
cd /d D:
move "\Program Files" "\_Program Files"
move "\Program Files (x86)" "\_Program Files (x86)"

And then I made the symbolic links... including with a bug!

mklink /D "\Program Files" "D:\InstalledSoftware\Program Files"
mklink /D "\Program Files (x86)" "D:\InstalledSoftware\Program Files"

Since the destination path is stored in the NTFS partition, I could point it at a location that didn't make any sense in the state I was at right there. Once I rebooted everything should work out fine.

I exited out to the Advanced Startup and allowed the system to continue into Windows 10. The first thing I noticed was that the system successfully booted. Once I logged in though I saw a bunch of my icons were broken. Just the shortcuts to 32 bit programs though. I compared the contents of D:\InstalledSoftware\Program Files (x86)\ and C:\Program Files (x86)\ and found that they didn't match. Strange. It looked more like C:\Program Files (x86)\ contained my 64 bit applications. Which it did.

A quick jaunt back to the Boot to Command Prompt let me fix it:
cd /d D:
rmdir "\Program Files (x86)"
mklink /D "\Program Files (x86)" "D:\InstalledSoftware\Program Files (x86)"

Excellent. On reboot all my icons looked find. Time to do a quick spot check of the file system before I delete the backups on C:
The file view in the C drive backup
The file view in C:\Program Files
Oh no! I broke all of the file system security settings by setting everything to be owned by Administrators. Is it even possible to restore a file to TrustedInstaller?! Turns out it is and it has been blogged about. And so I set about fixing a few directories.
Security Tab of File Properties on my directory
You cannot search for the TrustedInstaller account, but it is there.
Apply the changes down the whole tree.
Finally I had a directory restored! Yay! Now on to the next... 116 GB worth?! No. There had to be a way to script this. And so Powershell to the rescue.

Function Copy-ACL {
    Param (
        [string]$SrcPath,
        [string]$DestPath
    )
 
    $BaseACL = Get-ACL -LiteralPath $SrcPath
    Set-ACL -LiteralPath $DestPath -AclObject $BaseACL
 
    ForEach ($ChildItem in Get-ChildItem -LiteralPath $SrcPath -Recurse)
    {
        $DestItem = $ChildItem.FullName.replace($SrcPath, $DestPath)
        $SrcACL = Get-ACL -LiteralPath $ChildItem.FullName       
        if (Test-Path $DestItem)
        {
            Set-ACL -LiteralPath $DestItem -AclObject $SrcACL
        }     
    }
}
Now I could fix both trees.
Copy-ACL 'C:\_Program Files\' 'D:\InstalledSoftware\Program Files\'
Copy-ACL 'C:\_Program Files (x86)\' 'D:\InstalledSoftware\Program Files (x86)\'

Now... off to the races!
What is this? Oh, just rmdir /s /q %programfiles% ¯\_(ツ)_/¯
Thank you for coming on this journey with me. Next week I will blog about the total destruction I just made by massively modifying my workstation from 1am to 6am. I hope you enjoyed reading about it.
Free ALL the space!