Skip to content

Instantly share code, notes, and snippets.

@thinktainer
thinktainer / git squash workflow
Created August 30, 2013 14:25
a workflow that allows me to squash my commits before merging to master / this depends on master not having moved since
combination of:
http://stackoverflow.com/questions/363908/how-do-i-use-git-rebase-i-to-rebase-all-changes-in-a-branch
http://stackoverflow.com/questions/5189560/how-can-i-squash-my-last-x-commits-together-using-git
git merge-base feature master
git reset --hard output of above sha
git merge --squash HEAD@{1}
git commit
public class DisposableClass :
IDisposable
{
bool _disposed;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
@thinktainer
thinktainer / continueTaskAsync.fs
Created September 23, 2013 19:04
continue task without 'T in f# and handle exception there
member x.HandleExceptionOrContinue(t : Task) =
match t.IsFaulted with
| true ->
tracer.WriteLine(
(sprintf "Unhandled Exception when trying to send message: %O"
(t.Exception)), LogError); raise t.Exception
| arg -> ()
call it with
t.ContinueWith(
member x.ContinueUnitTaskSafe (writer : (string -> unit) option) (t : Task) =
match t.IsFaulted with
| true ->
match writer with
| Some x -> x "reraising"
| None -> ()
raise t.Exception
| arg -> ()
Param( $serviceName = "",
$storageAccountName = "",
$packageLocation = "",
$cloudConfigLocation = "",
$environment = "Staging",
$deploymentLabel = "ContinuousDeploy to $servicename",
$timeStampFormat = "g",
$alwaysDeleteExistingDeployments = 1,
$enableDeploymentUpgrade = 1,
$selectedsubscription = "default",

CarolR

We conceived the idea for this hack when reading the list of hardware that was going to be available for this hack day. Among them was a raspberry pie that could be turned into an iBeacon very easily. An appealing thought was that we could join the event of people coming into a range of each other and the festive setting into a meaningful context. Playing festive tunes in a polyphonic orchestra of users devices seemed like a perfect fit for this proposition. We set out by looking at implementations of communications protocols and quickly discovered that Bluetooth_LE was not going to fit the bill, as we were going to have to:

@thinktainer
thinktainer / tohexstring.cs
Created January 24, 2014 20:47
format hex string from byte array c#
// Loop through each byte of the hashed data
// and format each one as a hexadecimal string.
for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));
}
@thinktainer
thinktainer / azurekeys.sh
Created March 4, 2014 19:37
generate azure keys
# You may want to use another dir than /tmp
cd /tmp
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout azure-private.key -out azure-certificate.pem
chmod 600 azure-private.key azure-certificate.pem
openssl x509 -outform der -in azure-certificate.pem -out azure-certificate.cer
# Generate a keystore (azurekeystore.pkcs12)
# Transform private key to PEM format
openssl pkcs8 -topk8 -nocrypt -in azure-private.key -inform PEM -out azure-pk.pem -outform PEM
# Transform certificate to PEM format
module Seq =
let private spill (n:int) (s:seq<'a>) =
let en = s.GetEnumerator()
let pos = ref 0
let lst = [ while !pos < n && en.MoveNext() do
pos := !pos+1
yield en.Current]
if lst |> List.isEmpty then None else
Some((lst, seq { while en.MoveNext() do yield en.Current}))
@thinktainer
thinktainer / ilmerge.cmd
Created April 7, 2014 02:14
ilmerge for .NET 4.5
ilmerge /t:exe /targetplatform:"v4,$env:windir\Microsoft.NET\Framework64\v4.0.30319" /lib:. /out:Upload.exe .\lsul.exe