Skip to content

Instantly share code, notes, and snippets.

View jaguire's full-sized avatar
👻

Jaguir jaguire

👻
  • Oracle
  • Independence, MO
View GitHub Profile
@jaguire
jaguire / AesEncryptor.cs
Created May 9, 2016 18:50
AES Encryption
/// <summary>
/// AES (Advanced Encryption Standard) encryptor and dencryptor.
/// </summary>
public interface IAesEncryptor
{
/// <summary>
/// Pass in a UTF8 encoded string and get back a base64 encoded string of the encrypted data.
/// </summary>
/// <param name="utf8String">The UTF8 encoded string to encode.</param>
/// <param name="password">The password.</param>
@jaguire
jaguire / DeleteDuplicates.sql
Created March 14, 2013 22:30
Delete duplicates for ms sql
-- FIELD is the unique field to find duplicates on
delete TABLENAME
from TABLENAME
left outer join (
select min([Key]) as [Key], FIELD
from TABLENAME
group by FIELD
) as temp on
TABLENAME.[Key] = temp.[Key]
where temp.[Key] is null
@jaguire
jaguire / CacheExtensions.cs
Last active February 9, 2016 19:46
Cache the output of a method call.
public static class CacheExtensions
{
private static readonly object ThisLock = new object();
public static T Get<T>(this Cache cache, string key, Func<T> builder, DateTime expiration)
{
var data = cache.Get(key);
if (data == null)
{
lock (ThisLock)
@jaguire
jaguire / namespace.js
Created November 30, 2011 15:10
Simple javascript namespacing. Intended as code organization before being bundled for deployment.
function namespace(path) {
var root = window;
var names = path.split('.');
for (i = 0; i < names.length; i++) {
root[names[i]] = root[names[i]] || {};
root = root[names[i]];
}
};