Skip to content

Instantly share code, notes, and snippets.

View draganjovanovic1's full-sized avatar

Dragan Jovanović draganjovanovic1

View GitHub Profile
@draganjovanovic1
draganjovanovic1 / IdGenerator.fs
Last active March 11, 2019 17:55
Simple unique id generator
open System
open System.Threading
open System.Text
type IdGenerator<'a> private (chars: char seq, getTime: unit -> int64, transform: string -> 'a) =
let chars =
chars
|> Seq.distinct
|> Seq.toArray
@draganjovanovic1
draganjovanovic1 / StrongNameKeyManager.cs
Last active August 29, 2015 14:01
StrongNameKeyManager
using System;
using System.IO;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
namespace CryptoPlayground.StrongNameKeyManagement
{
public class StrongNameKeyManager
{
public StrongNameKeyManager(string containerName, bool machineScope = true)
@draganjovanovic1
draganjovanovic1 / Impersonation.cs
Last active March 11, 2019 17:40
Windows user Impersonation in code (C#)
using System;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Security.Principal;
using Microsoft.Win32.SafeHandles;
namespace GitHub.Gists
{
@draganjovanovic1
draganjovanovic1 / GenericExtension.cs
Last active March 11, 2019 17:39
Generic object extension for reading - setting property values to - from key value pairs....
/// <summary>
/// Generic extension.
/// </summary>
public static class GenericExtension
{
/// <summary>
/// Read properties to key-value pair.
/// </summary>
/// <typeparam name="T">Class type.</typeparam>
/// <param name="obj">Object instance.</param>