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.

Wednesday, August 27, 2014

Style all <select>'s with a given CSS class into a fancy radio button look

Json.Net Serialize Dictionary<Tkey, Tobject> to List<Tobject>

Motivation: Wanted convenience of a Dictionary on the server side MVC controller (for some key look-up based logic), yet send the same list of objects down to Knockout Ajax client, which most readily consumes lists as Javascript object arrays.

Could've just exposed the List<Object> as another property but wanted to see if I could roll it all into one property just to learn a little more about the Json.Net API.

Nice that Json.Net's tokenization framework has already abstracted away from specific types within the overridden method scope on custom JsonConverter class, so this approach generically handles *any* Dictionary<object, object> without any additional effort.

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;

namespace YouNameIt {

  using CartItemDict = Dictionary<long, CartItemDto>;

  //reverse of this:
  //adapted from here:
  public class DictToListConverter : JsonConverter
    public override bool CanConvert(Type objectType)
      return objectType == typeof (Dictionary<object, object>);

    public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
      throw new NotImplementedException();

    public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
      var t = JToken.FromObject(value);

      if (t.Type != JTokenType.Object)
        var o = (JObject) t;
        var values = o.Properties().Select(p => p.Value).ToList();
        (new JArray(values)).WriteTo(writer);

  public class CartDto
    public CartItemDict Items { get; set; }

    public decimal TotalPrice { get; private set; }

  public class CartItemDto : VariantDto
    public long CartItemId { get; private set; }
    public int Quantity { get; private set; }

    public decimal UnitPrice { get; private set; }
    public decimal LinePrice { get; private set; }

    private List _addons;
    public List Addons { get { return _addons ?? (_addons = new List()); } }

Friday, July 4, 2014

[SOLVED] Comodo v7 blocking HTTP/S and FTP/S on Windows 8.1 IIS 8.5

Besides opening incoming HTTP ports in the firewall via "Global Rules", the annoying thing for me to find was also adding an "Application Rule" for "Windows Operating System" on those same ports.

Comodo v7.0.317799.4142

And this guy explains what's necessary for FTP very nicely...

  • in comodo > global settings > application rule - add 20,21 & 5000-6000 as allowed incoming TCP ports on "Windows Operating System"... you will also hopefully get prompted to allow svchost which is responsible for running the ftpsvc
  • on internet router - forward ports 20,21 and 5000-6000
  • in IIS FTP settings
  • filezilla settings
    • require explicit ftp over tls

Wednesday, June 11, 2014

List all your Azure RDP's

Get-AzureVM | #this first one gets the entire list of VMs in subscription
    Get-AzureVM | # this one gets the detailed object for each specific VM
        $port = ($_ | Get-AzureEndpoint | ? {$ -like "Remote*"})[0].Port;
        $null = $_.DNSName -match 'http://(.*?)/'
        write-host "$($_.Name) - $($matches[1]):$($port)"

Saturday, February 8, 2014

SQL Server Aliasing

  • Done via "SQL Server Configuration Manager" > "SQL Native Client vXY.Z Configuration" > Aliases
  • tip: SSMS.exe is a 32bit app (because Visual Studio, upon which it is based, still has a well established justification for 32bit) and therefore it depends on the (32bit) Client Configuration node above to find your server alias
  • For mainstream sql server network client API based connections there is no need to put this alias anywhere else (i.e. not in DNS/hosts file nor AD computers)
  • tip: in AD trusted login context, it seems mandatory to use the name of the actual SQL Server host machine vs just the corresponding ip address; otherwise i would always get bonked with "Login failed. The login is from an untrusted domain and cannot be used with Windows authentication."