Skip to content

Instantly share code, notes, and snippets.

@tomasjurasek
tomasjurasek / token.cs
Created February 12, 2016 09:53
Token Owin
public static AppUserManager Create(AppUserManager manager, IdentityFactoryOptions<AppUserManager> options, IOwinContext context)
{
// Configure validation logic for usernames
manager.UserValidator = new UserValidator<AppUser, int>(manager)
{
AllowOnlyAlphanumericUserNames = false,
RequireUniqueEmail = true
};
// Configure validation logic for passwords
@tomasjurasek
tomasjurasek / resource.cs
Created February 2, 2016 14:03
Embedded resource
var assembly = Assembly.GetExecutingAssembly();
var resourceName = "AssemblyName.MyFile.txt";
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
{
using (StreamReader reader = new StreamReader(stream))
{
string result = reader.ReadToEnd();
}
}
@tomasjurasek
tomasjurasek / node.cs
Last active December 16, 2015 22:00
Node
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tree
{
class Program
{
@tomasjurasek
tomasjurasek / Hashing.cs
Last active April 21, 2016 19:07
Create hash with salt
public class Hashing
{
private readonly int SALT_SIZE = 16;
private readonly int HASH_SIZE = 32;
private byte[] salt;
private byte[] newSalt;
public string HashWithSalt(string passwordPlainText, string Username)
{
byte[] key;
@tomasjurasek
tomasjurasek / ProcessKill
Last active August 29, 2015 14:03
process killer
Process currentProcess = Process.GetCurrentProcess();
Process[] processes = Process.GetProcessesByName(currentProcess.ProcessName);
if (processes.Count() > 1)
{
for (int i = processes.Count() -1; i > 0; i--)
{
processes[i].Kill();
}
}