Skip to content

Instantly share code, notes, and snippets.

@marking
marking / keybase.md
Created February 9, 2017 16:21
Keybase.md

Keybase proof

I hereby claim:

  • I am marking on github.
  • I am mark_ingalls (https://keybase.io/mark_ingalls) on keybase.
  • I have a public key ASAuVdU6QtF03i1koCSvsF59q3CQZHVZUsiE0dcy5GBZrAo

To claim this, I am signing this object:

@marking
marking / Invoke-KMSEncrypt-Example.ps1
Created July 12, 2016 23:23 — forked from Sam-Martin/Invoke-KMSEncrypt-Example.ps1
PowerShell Example for using Invoke-KMSEncrypt and Invoke-KMSDecrypt
# Stolen from http://ctrlf5.net/?p=263 and http://www.dailycoding.com/posts/convert_image_to_base64_string_and_base64_string_to_image.aspx
function ConvertFrom-StringToMemoryStream{
param(
[parameter(Mandatory)]
[string]$InputString
)
$stream = New-Object System.IO.MemoryStream;
$writer = New-Object System.IO.StreamWriter($stream);
$writer.Write($InputString);
@marking
marking / invokeWithCookie.ps1
Created March 14, 2016 20:44 — forked from lawrencegripper/invokeWithCookie.ps1
Invoke-webrequest With Cookie
$downloadToPath = "c:\somewhere\on\disk\file.zip"
$remoteFileLocation = "http://somewhere/on/the/internet"
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$cookie = New-Object System.Net.Cookie
$cookie.Name = "cookieName"
$cookie.Value = "valueOfCookie"
public static IList<T> Get<T, I>()
where T : class
where I : IRepository<T>
{
using (var assembleContainer = BuildAssembleContainer())
{
return assembleContainer.Resolve<I>().List();
}
}
public static void SaveUser(User userToSave)
{
using (var assembleContainer = BuildAssembleContainer())
{
var userRepository = assembleContainer.Resolve<IUserRepository>();
var user = userRepository.GetById(userToSave.Id);
if (user == null)
{
throw new ArgumentException(string.Format("A User with id={0} does not exist in the database", userToSave.Id));