/* BeejBlog */

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

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: http://stackoverflow.com/questions/24759181/deserializing-a-json-dictionaryint-customtype-to-listcustomtype
  //adapted from here: http://james.newtonking.com/json/help/index.html?topic=html/CustomJsonConverter.htm
  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)
      {
        t.WriteTo(writer);
      }
      else
      {
        var o = (JObject) t;
        var values = o.Properties().Select(p => p.Value).ToList();
        (new JArray(values)).WriteTo(writer);
      }
    }
  }

  public class CartDto
  {
    [JsonConverter(typeof(DictToListConverter))]
    public CartItemDict Items { get; set; }

    [DataType(DataType.Currency)]
    public decimal TotalPrice { get; private set; }
  }

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

    [DataType(DataType.Currency)]
    public decimal UnitPrice { get; private set; }
    [DataType(DataType.Currency)]
    public decimal LinePrice { get; private set; }

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

[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

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 | ? {$_.name -like "Remote*"})[0].Port;
        $null = $_.DNSName -match 'http://(.*?)/'
        write-host "$($_.Name) - $($matches[1]):$($port)"
    }

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

[SOLVED] Win8.1 Upgrade - No "Keep Windows settings, personal files, and apps" option

Before
I was met with only two options from the Windows 8.1 upgrade, "Keep Personal Files Only" or "Nothing". Not much of an "upgrade", I went poking around.

For me it turned out that I had been fiddling with localized development a while back and had an old en-GB language pack still installed. There are various references that the Win8.1 upgrade criteria prohibits "cross language" installs.

Apparently a language pack can't be removed from a running Windows instance, it must be "offline". One way is from the CMD.exe of a Windows DVD/USB install boot disc. Tip: Shift-F10.

After :)
To find which language packs are installed ("Language" is case sensitive):
dism /image:c:\ /get-packages | find "Language"

Which output something long like this:
Package Identity : Microsoft-Windows-Client-LanguagePack-Package~31bf3856ad364e35~amd64~en-GB~6.2.9200.16384

To remove the package:
dism /image:c:\ /remove-package /packagename:{long_name_from_above_output}

That ran for a few minutes to completion and when I booted back into my main instance and retried the upgrade, I was met with the new desired option to preserve my applications as well - yay :)