Skip to content

Instantly share code, notes, and snippets.

View lennybacon's full-sized avatar
🏠
Working from home

Daniel Fisher lennybacon

🏠
Working from home
View GitHub Profile
@lennybacon
lennybacon / StringExtensions.Wcce.cs
Last active August 29, 2015 13:57
Sanitizing Strings according to Windows Client Certificate Enrollment Protocol [MS-WCCE]
public static partial class StringExtensions
{
/// <summary>
/// Sanitizes the string according to Windows Client Certificate Enrollment
/// Protocol: http://msdn.microsoft.com/en-us/library/cc249879.aspx
/// </summary>
/// <param name="input">The input.</param>
/// <returns>System.String.</returns>
/// <remarks>
/// All disallowed characters in the original name MUST be replaced with
@lennybacon
lennybacon / callChain.js
Last active August 29, 2015 13:57
Chaining asynchronous JavaScript calls with Angular JS
angularModule.
factory(
'callChain',
[
function() {
return function () {
var cs;
cs = [];
this.add = function (call) {
cs.push(call);
@lennybacon
lennybacon / usingCallChain.js
Last active August 29, 2015 13:57
Using the chaining asynchronous JavaScript calls with Angular JS
function f1(callback) {
console.log('f1');
if (callback != null) {
console.log('hasCallback');
callback();
}
}
function f2(callback) {
console.log('f2');
if (callback != null) {
@lennybacon
lennybacon / MultiplyData.sql
Last active August 29, 2015 14:02
Poor Mans SQL Data Generation
SET IDENTITY_INSERT [LogEntry2] ON;
GO
WHILE (SELECT COUNT(*) FROM [LogEntry2]) < 2500000
BEGIN
INSERT INTO [LogEntry2]
(
[LogEntry2].[Id]
, [LogEntry2].[Culture]
, [LogEntry2].[Created]
, [LogEntry2].[CreatedBy]
@lennybacon
lennybacon / iiscfg.ps1
Created August 7, 2014 08:47
IIS Configuration PowerShell Script
Set-Alias iiscfg Edit-ApplicationHostsConfig
function Edit-ApplicationHostsConfig {
$file = Get-ApplicationHostsConfig
edit $file
}
function Get-ApplicationHostsConfig(){
$appHostConfig = "C:\Windows\sysnative\inetsrv\config\applicationHost.config"
$exists = Test-Path $appHostConfig
@lennybacon
lennybacon / LicensedComponent.cs
Created November 19, 2014 13:03
.NET Component Licensing
namespace MyNamespace
{
[LicenseProvider(typeof(MyLicenseProvider))]
public class MyLicensedComponent : Component
{
}
public class MyLicenseProvider : LicenseProvider
{
@lennybacon
lennybacon / license.licx
Created November 19, 2014 13:18
.NET Componen License File
TXTextControl.ServerTextControl, TXTextControl.Server, Version=21.0.600.500, Culture=neutral, PublicKeyToken=6b83fe9a75cfb638
@lennybacon
lennybacon / Compile-License.cmd
Created November 19, 2014 13:26
License Compiler in action
"LC.exe" /target:Licensensing.dll /complist:.\licenses.licx /outdir:. /i:".\TXTextControl.Server.dll"
@lennybacon
lennybacon / Embed-License.cmd
Created November 19, 2014 13:29
Embed a license during compilation
"Csc.exe" /reference:"System.dll" /reference:"System.Core.dll" /reference:"TXTextControl.dll" /reference:"TXTextControl.Server.dll" /out:Licensensing.dll /resource:Licensensing.dll.licenses /target:library .\Class1.cs .\Properties\AssemblyInfo.cs
@lennybacon
lennybacon / RuntimeLicenseContext-snip.cs
Created November 19, 2014 13:55
Resolve license from embedded resource
//..
if (resourceAssembly == null)
{
resourceAssembly = Assembly.GetEntryAssembly();
}
if (resourceAssembly == null)
{
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
{
//...