Skip to content

Instantly share code, notes, and snippets.

@jbtule
jbtule / AESGCM.cs
Last active October 21, 2024 22:04
I have two code examples that I wrote for best practices encrypting a string in c#. They are both using authenticated encryption. http://stackoverflow.com/a/10366194/637783
/*
* This work (Modern Encryption of a String C#, by James Tuley),
* identified by James Tuley, is free of known copyright restrictions.
* https://gist.github.com/4336842
* http://creativecommons.org/publicdomain/mark/1.0/
*/
using System;
using System.IO;
using System.Text;
@jbtule
jbtule / keyczar-make-data.sh
Last active December 11, 2015 00:58
Create test data for keyczar via bourne shell script.
#!/bin/sh -x
./testdata-script.sh "cs" "mono KeyczarTool.exe"
# python requires http://code.google.com/r/jtuley-python-collisions/
./testdata-script.sh "py" "python keyczar/keyczart.py"
# java requires http://code.google.com/r/jtuley-java-usekey-interop/
./testdata-script.sh "j" "java -jar KeyczarTool.jar"
@jbtule
jbtule / create-nuget.bat
Last active December 16, 2015 18:59
Create,Publish Nuget Package w/ Symbols&Source
@echo off
IF %1.==. GOTO WrongArgs
..\.nuget\nuget.exe pack ..\%1\%1.csproj -Build -Properties Configuration=Release -Symbols
GOTO:EOF
:WrongArgs
ECHO "create-nuget <projectname>"
@jbtule
jbtule / LosslessJson.csx
Created May 25, 2013 01:37
This example was inspired by "Serialization is Lossy" http://kellabyte.com/2013/05/02/serialization-is-lossy/
using ImpromptuInterface;
using Newtonsoft.Json.Linq;
/*
* This example was inspired by
* "Serialization is Lossy"
* http://kellabyte.com/2013/05/02/serialization-is-lossy/
*/
open System.Linq
[<EntryPoint>]
let main argv =
let counter = List.fold (fun (a,c,g,t) x -> match x with
| 'A' -> (a+1, c, g, t )
| 'C' -> (a, c+1, g, t )
| 'G' -> (a, c, g+1, t )
| 'T' -> (a, c, g, t+1)
@jbtule
jbtule / PCLBuildServerNotes.md
Last active December 20, 2015 10:49
Notes on installing portable library Profile support for build servers!
  • Visual Studio 2012 Pro Update 2 buy
  • Portable Library Tools 2 (install with /buildmachine from command line) download
  • Mono 3.2.4 stable download
  • Windows Phone 8 sdk (Requires Windows 8) download
@jbtule
jbtule / NullCoalesce.fs
Last active May 13, 2022 16:38
Null Coalesce Operator for F# (|??), works with option, Nullable, and c# reference types
//inspired by http://stackoverflow.com/a/2812306/637783
type NullCoalesce =
static member Coalesce(a: 'a option, b: 'a Lazy) = match a with Some a -> a | _ -> b.Value
static member Coalesce(a: 'a Nullable, b: 'a Lazy) = if a.HasValue then a.Value else b.Value
static member Coalesce(a: 'a when 'a:null, b: 'a Lazy) = match a with null -> b.Value | _ -> a
let inline nullCoalesceHelper< ^t, ^a, ^b, ^c when (^t or ^a) : (static member Coalesce : ^a * ^b -> ^c)> a b =
((^t or ^a) : (static member Coalesce : ^a * ^b -> ^c) (a, b))
@jbtule
jbtule / build.fsx
Last active March 24, 2020 16:06
Crossplatform FSharp Makefile Bootstrapper
#!/bin/sh
#if run_with_bin_sh
# Doing this because arguments can't be used with /usr/bin/env on linux, just mac
exec fsharpi --define:mono_posix --exec $0 $*
#endif
(*
* Crossplatform FSharp Makefile Bootstrapper
* Apache licensed - Copyright 2014 Jay Tuley <[email protected]>
* v 2.0 https://gist.github.com/jbtule/9243729
@jbtule
jbtule / build.fsx
Last active July 4, 2017 21:43
Single file Crossplatform FSharp MakeFile bootstrap
#!/bin/sh
#if run_with_bin_sh
# Doing this because arguments can't be used with /usr/bin/env on linux, just mac
exec fsharpi --define:mono_posix --exec $0 $*
#endif
#if FSharp_MakeFile
(*
* Single File Crossplatform FSharp Makefile Bootstrapper
@jbtule
jbtule / keybase.md
Created September 22, 2014 15:23
keybase.md

Keybase proof

I hereby claim:

  • I am jbtule on github.
  • I am jbtule (https://keybase.io/jbtule) on keybase.
  • I have a public key whose fingerprint is 3D0C 3B0C 41D8 A997 9363 F5A9 264F 726E 62F0 9646

To claim this, I am signing this object: