Skip to content

Instantly share code, notes, and snippets.

View jennings's full-sized avatar
🦄
What a mess I've made

Stephen Jennings jennings

🦄
What a mess I've made
View GitHub Profile
@jennings
jennings / netsh.md
Last active December 6, 2017 23:44

Set a URL ACL for the current user to listen on a specific port

netsh http add urlacl url=http://+:44444/  user=DOMAIN\username

netsh http add urlacl url=https://localhost:44300/           user=DOMAIN\username
netsh http add urlacl url=https://hostname:44300/            user=DOMAIN\username
netsh http add urlacl url=https://hostname.domain.ext:44300/ user=DOMAIN\username

View current URL ACLs

<#
Run this automatically via this URL:
http://boxstarter.org/package/nr/url?https://gist.githubusercontent.com/jennings/11245384/raw/Boxstarter.ps1
#>
Set-WindowsExplorerOptions -EnableShowFileExtensions
Install-WindowsUpdate
Update-ExecutionPolicy RemoteSigned
# General Utilities
@jennings
jennings / IISExpressCertificate.md
Created June 4, 2014 21:20
How to use a real certificate with IIS Express

Generate a certificate and store it in the local computer's certificate store.

Then, use netsh to assign the certificate to a port and application.

netsh http delete sslcert ipport=<hostname>:<port>
netsh http add sslcert ipport=<hostname>:<port> certhash=<certificate-thumbprint> appid=<appid>

For example:

netsh http delete sslcert ipport=0.0.0.0:44301

@jennings
jennings / TableSizes.sql
Last active February 6, 2017 09:41
Get size of all tables in a SQL Server database
-- Adapted from: http://stackoverflow.com/a/7892349/19818
SELECT *
FROM (
SELECT
name AS TableName,
'(FILESTREAM)' AS SchemaName,
0 AS RowCounts,
size / 8 AS TotalSpaceKB,
size / 8 as UsedspaceKB,
[ServiceContract]
public interface IService2
{
[OperationContract]
void setSalesItems(setSalesItems obj);
[OperationContract]
void setSalesItemsV3(setSalesItemsV3 obj);
}
[DataContract(Namespace = "")]
@jennings
jennings / Program.cs
Last active December 5, 2015 23:12
A sample program for Stack Overflow question 34111695 (http://stackoverflow.com/q/34111695/19818)
// See: http://stackoverflow.com/q/34111695/19818
namespace StackOverflow34111695
{
using System;
using System.IO;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
@jennings
jennings / keybase.md
Created April 17, 2016 05:39
Keybase proof

Keybase proof

I hereby claim:

  • I am jennings on github.
  • I am jennings (https://keybase.io/jennings) on keybase.
  • I have a public key ASAr3xJbZmMFK6kV8HoTTo1vRKFb4PjLj55jcdht_igINAo

To claim this, I am signing this object:

@jennings
jennings / Windows10-Setup.ps1
Last active May 6, 2016 19:47 — forked from NickCraver/Windows10-Setup.ps1
(In Progress) PowerShell Script I use to customize my machines in the same way for privacy, search, UI, etc.
##################
# Privacy Settings
##################
# Privacy: Let apps use my advertising ID: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 0
# To Restore:
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 1
# Privacy: SmartScreen Filter for Store Apps: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost -Name EnableWebContentEvaluation -Type DWord -Value 0
@jennings
jennings / WcfExtensibilityPoints.md
Last active September 26, 2020 06:09
I can never remember how to extend WCF in the ways that I want.

A good summary of all the extensibility points: https://blogs.msdn.microsoft.com/carlosfigueira/2011/03/14/wcf-extensibility/

Doing stuff before/after calls

Use IOperationInvoker if you need to do "runtime-y" things, such as replacing the current SynchronizationContext (perhaps with one that restores OperationContext after an await...).

But! You can only apply an IOperationInvoker from an IOperationBehavior, not from a IServiceBehavior. If you try to assign an operation invoker from a service behavior, WCF will eventually just overwrite it. If you want to apply an IOperationInvoker to every operation in a contract, you can write an IServiceBehavior which applies the IOperationBehavior to every operation.

You can have an attribute which can apply to a whole service, or to a single operation: