Skip to content

Instantly share code, notes, and snippets.

ctigeek / SoapApiTest.cs
Created Jan 4, 2021
Calling the soap api
View SoapApiTest.cs
using System;
using NUnit.Framework;
namespace RackspaceSoapTest
public class Class1
public void Test1()
ctigeek / TcpListener.cs
Created Jun 22, 2020
A simple TCP listener. Assumes you're sending UTF8 text to it.
View TcpListener.cs
using System;
using System.IO;
using System.Net;
using System.Text;
namespace TcpListener
class Program
static void Main(string[] args)
View GenericCache.cs
public interface IGenericCache<T>
TimeSpan CacheTtl { get; set; }
Func<T> LoadCache { get; set; }
T ReturnCache();
T ForceRefresh();
public class GenericCache<T> : IGenericCache<T>
ctigeek / Tjson.cs
Created Jan 24, 2019
Tjson Deserializer....
View Tjson.cs
// written by Steven Swenson
// Released under the MIT open source license...
// No warranty at all. use at your own risk.
public static class Tjson
private static readonly Splitter.Preserver QuotePreserver = new Splitter.Preserver { Start = '"', End = '"', Escape = '\\' };
private static readonly Splitter.Preserver CurlyBoiPreserver = new Splitter.Preserver { Start = '{', End = '}', Escape = '\\', Recursive = true, SubPreserver = QuotePreserver };
private static readonly Splitter.Preserver BracketPreserver = new Splitter.Preserver { Start = '[', End = ']', Escape = '\\', Recursive = true, SubPreserver = QuotePreserver };
ctigeek / Split.cs
Last active Jan 24, 2019
Split a string on a character, but don't split based on start-end characters.
View Split.cs
/// <summary>
/// Split a string while preserving sections of it.
/// Similar to string.Split, but you can define start-end characters (e.g. quotes, brackets, braces) inside of which it will NOT split.
/// Preservers can also be "recursive" which means it can determine if it's in nested brackets or parens, etc.
/// If the start & end characters are different, there's a good chance you want to set recursive to true.
/// See the associated unit test for an example that can parse json....
/// Also supports escape characters so the separator and start-end characters can be ignored.
/// </summary>
public class Splitter
ctigeek / EncryptionExample.cs
Created Jun 19, 2018
File Encryption example.
View EncryptionExample.cs
using System;
using System.Diagnostics;
using System.IO;
using System.Security.Cryptography;
namespace EncryptionExample
class Program
static void Main(string[] args)
ctigeek / Retry.cs
Created Apr 11, 2018
Retry pattern
View Retry.cs
public static class Retry
public static void Do(Action action, TimeSpan retryInterval, int maxAttemptCount)
ctigeek / Import-XlsData.ps1
Last active Mar 13, 2018
Query XLS spreadsheet from powershell
View Import-XlsData.ps1
function Import-XlsData($filePath) {
## You have to have these drivers...
##The first row will be the column names
##This only looks at the first sheet. If you want a different sheet you'll have to adjust the table name retrieved from $schema.
$strProvider = "Provider=Microsoft.ACE.OLEDB.12.0"
$strDataSource = "Data Source=$filePath"
$strExtend = "Extended Properties='Excel 12.0;IMEX=1'"
ctigeek / Config.cs
Last active Feb 4, 2018
Save name-object pairs securely.
View Config.cs
public static class Config
public const int MaxValueLength = 7990; //If you change the size of the [secret] column then this needs to be changed.
public static string ConnectionString { get; set; }
public static string AesKey { get; set; }
public static int SecretPaddingSize { get; set; } = 1000; //e.g. any secret less than 1000 bytes will be padded so that it is at least 1000 bytes. This is to prevent information leaking regarding the size of the secret. Set to 0 to disable padding.
ctigeek / Get-AllMailboxes.ps1
Last active Dec 11, 2017
Get all Hex and Rackspace mailboxes for your account, and any indirect accounts.
View Get-AllMailboxes.ps1
## This code released under the MIT open source license.
## See here for details:
## This code is provided with NO SUPPORT and NO WARRANTY and NO GUARANTEE. Use at your own risk.
[string] $ApiKey = ""
[string] $ApiSecret = ""
## only populate $indirectAccountNumber if you want a list from one specific account, otherwise leave blank.
[string] $indirectAccountNumber = ""
[string] $path = "AllMailboxes.csv"