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 / us
Created March 30, 2012 13:07
ReSharper template for helping with long underscored text
$underscored$ $SELSTART$$text$ $SELEND$
@i-e-b
i-e-b / FileLockInfo.cs
Last active June 7, 2023 10:15
Discover Win32 processes locking a file, and file locks by process. This is quite old now, and better methods are available. Additional research by Walkman100 at https://github.com/Walkman100/FileLocks (see comments section)
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Text;
using System.Threading;
namespace FileLockInfo
{
public class Win32Processes
@i-e-b
i-e-b / mspec super templates.DotSettings
Created April 3, 2012 16:58
mspec super templates for ReSharper 6.1
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=17D786EF95804D4BAB8F11E7AEFE39C9/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=17D786EF95804D4BAB8F11E7AEFE39C9/Shortcut/@EntryValue">fs</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=17D786EF95804D4BAB8F11E7AEFE39C9/Description/@EntryValue">MSpec =()=&gt; operator</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=17D786EF95804D4BAB8F11E7AEFE39C9/Text/@EntryValue">=()=&gt;</s:String>
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=17D786EF95804D4BAB8F11E7AEFE39C9/Applicability/=Live/@EntryIndexedValue">True</s:B
@i-e-b
i-e-b / notes.md
Created April 12, 2012 02:51
Notes on Git and Hg

Problems with Git (and Hg) and some solution ideas

  1. Storing changes to regenerated binaries (i.e. output from another project) is inefficient and causes repo bloat.

    I want to be able to store the generated output (dlls etc) from one project to another, as each should stand on it's own for CI & deployment purposes. I don't care about their history, as they can be cheaply regenerated.

@i-e-b
i-e-b / pathspec.ps1
Created May 3, 2012 16:36
Powershell pathspecs
function SpecToRegex($spec) {
$tmp = $spec.Replace("**", "[{A}]").Replace("*","[{B}]").Replace("\","[{C}]").Replace(".","[{D}]").Replace("?",".")
$tmp = $tmp.Replace("[{A}]",".*?").Replace("[{B}]","[^/\\]*").Replace("[{C}]","\\").Replace("[{D}]","\.")
"^$tmp$"
}
function FindFiles($in, $matching) {
$pattern = SpecToRegex($matching)
ls $in -Recurse | ?{$_.FullName -match "$pattern"}
}
@i-e-b
i-e-b / fizzbuzz.fs
Created May 4, 2012 16:45
A unit-tested fizz-buzz in F#
module program
let fizzbuzz n =
let (|DivisibleBy|_|) x i = if i%x=0 then Some i else None
match n with
| DivisibleBy 3 _ & DivisibleBy 5 _ -> "FizzBuzz"
| DivisibleBy 3 _ -> "Fizz"
| DivisibleBy 5 _ -> "Buzz"
| x -> string x
@i-e-b
i-e-b / DrawingFramework.coffee
Created May 21, 2012 22:27
Html5 animation in canvas with coffeescript
class Entity
constructor: (@context, @cw, @ch) ->
# any setup here...
update: ->
# do per-frame updates
draw: ->
# draw using '@context'
@context.fillStyle = 'rgba(0,128,255,0.8)'
@i-e-b
i-e-b / installVBox.sh
Created May 24, 2012 10:40
Script to install virtual box
#!/bin/bash
sudo chmod 666 /etc/apt/sources.list
csrc=$(grep -c "$deb http://download.virtualbox.org" /etc/apt/sources.list)
if [ $csrc -eq 0 ]
then
echo "deb http://download.virtualbox.org/virtualbox/debian oneiric contrib" >> /etc/apt/sources.list
fi
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
@i-e-b
i-e-b / install-gems.ps1
Created May 24, 2012 15:47
Neat gem checker and installer
function MissingGem($name) {return ((gem list --local) -match "$name").Length -lt 1}
# list gem names:
("vagrant", "bundler") | %{
if (MissingGem($_)) {& "gem install $_"} else {echo "$_ already installed"}
}
@i-e-b
i-e-b / publish.ps1
Created June 6, 2012 11:43
MSBuild commands for "Publish Website" behaviour
$build = "$env:windir\Microsoft.NET\Framework\v3.5\MSBuild.exe"
$SolutionPath = "C:\Projects\AdminWebSite"
$SolutionFile = "AdminWebSite.sln"
$WebProjectFile = "Admin.Web\Admin.Web.csproj"
$OutputPath = "C:\PublishedSites\Hosts\adminweb"
& $build "$SolutionPath\$SolutionFile" /t:rebuild
& $build "$SolutionPath\$WebProjectFile" "/t:ResolveReferences;_CopyWebApplication;publish" /p:OutDir="$OutputPath\bin\" /p:WebProjectOutputDir="$OutputPath"