Skip to content

Instantly share code, notes, and snippets.

View i-e-b's full-sized avatar
🤔
Thinking

Iain Ballard i-e-b

🤔
Thinking
View GitHub Profile
@i-e-b
i-e-b / JavaScriptInclude_WF.cs
Created December 13, 2011 10:01
Javascript defer by script file or script block (for MVC using ASPX view engine)
using System;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.WebPages;
namespace Web.Extensions {
public static class JavascriptIncludeExtensions {
private const string JscriptIncludeViewdata = "__jsrq";
private const string JscriptDeferViewdata = "__jsdf";
@i-e-b
i-e-b / JavaScriptInclude_Rz.cs
Created December 13, 2011 10:33
Javascript defer by script file or script block (for MVC using Razor view engine)
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using System.Web.WebPages;
namespace Web.Extensions {
public static class JavascriptIncludeExtensions {
private const string JscriptIncludeViewdata = "__jsrq";
private const string JscriptDeferRazorViewdata = "__jsdfrz";
@i-e-b
i-e-b / A_Profile_BJSS.ps1
Last active October 28, 2023 13:27
My sample Powershell profile script
Set-PSReadlineOption -BellStyle None
# Clone `https://github.com/dahlbyk/posh-git.git` to C:\Gits
Import-Module 'C:\Gits\posh-git\src\posh-git.psd1'
set-executionpolicy Unrestricted process
$baseDir = Split-Path -parent $MyInvocation.MyCommand.Definition
#. "$baseDir\hand.ps1"
# General actions
function edit ($file) { & "${env:ProgramFiles(x86)}\Notepad++\notepad++.exe" $file }
@i-e-b
i-e-b / Global.asax.cs
Created February 14, 2012 16:21
Slap-on-top rest services
using System;
using System.Reflection;
using System.Web;
namespace Host
{
public class Global : HttpApplication
{
protected void Application_BeginRequest (object sender, EventArgs e) {
if (HttpContext.Current.Request.RawUrl.StartsWith(RestHandler.RestPrefix)) {
@i-e-b
i-e-b / ExtractInterface.cs
Created March 7, 2012 20:52
Dependency Ejection
using System;
namespace Common {
public sealed class Extract<I> {
internal sealed class StaticWrapper<Ti, Tt> {
private static readonly WrapperBase Prototype;
static StaticWrapper () {
Prototype = WrapperGenerator.GenerateWrapperPrototype(typeof(Ti), typeof(Tt));
}
public static Ti Cast (Tt src) {
@i-e-b
i-e-b / pull-everything.sh
Created March 9, 2012 13:41
Perform a git pull on all subdirectories of a given folder
#!/bin/bash
pushd ~/.gvfs/work\ on\ iain-2003svrvm
folders=( */ )
for location in "${folders[@]%*/}"; do
pushd $location
git pull origin master
popd
done
@i-e-b
i-e-b / guidaggregation.sql
Created March 15, 2012 11:11
TSQL count and value for grouped GUIDs
SELECT
CAST(MIN(CAST(myGuid AS BINARY(16))) AS UNIQUEIDENTIFIER) AS [TheGuid],
COUNT(myGuid) AS [ItsCount]
FROM MyTable
GROUP BY myGuid
@i-e-b
i-e-b / SimpleDataExtensions.cs
Created March 27, 2012 12:30
C# extension to select enumerable as a specific type from a dynamic.
public static IEnumerable<T> SelectAs<T> (this IEnumerable<dynamic> source, Func<dynamic, T> selector){
return source.Select(selector);
}
@i-e-b
i-e-b / MSpecWrapper.cs
Created March 27, 2012 12:40
Context wrapper for MSpec
#pragma warning disable 169 // ReSharper disable StaticFieldInGenericType, InconsistentNaming
using System;
using System.Transactions;
namespace Machine.Specifications {
public abstract class ContextAndResult<TSubject, TResult> {
protected static Exception the_exception;
protected static TSubject subject;
protected static TResult result;
@i-e-b
i-e-b / fs
Created March 27, 2012 13:18
MSpec templates for ReSharper using my MSpec wrapper
=()=>