Skip to content

Instantly share code, notes, and snippets.

@theuntitled
theuntitled / ListExtensions.cs
Created April 15, 2016 08:50
Mnemonic Password Generator
using System;
using System.Collections.Generic;
namespace Gists
{
public static class ListExtensions
{
public static T GetRandom<T>(this List<T> list, Random random = null)
{
random = random ?? new Random();
@theuntitled
theuntitled / PrettyFileSize.cs
Last active April 20, 2016 11:29
Pretty / Human readable file size formatter
namespace Project {
public static class Utilities {
public static string[] ByteUnits = {"kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
public static string GetPrettyFileSize(int fileSize) {
return GetPrettyFileSize((double)fileSize);
}
@theuntitled
theuntitled / CustomPasswordHasher.cs
Last active March 27, 2019 02:26
IdentitityFramework 2 Custom SHA256 IPasswordHasher with Salt
using System;
using System.Security.Cryptography;
using System.Text;
using Microsoft.AspNet.Identity;
namespace Project
{
public class CustomPasswordHasher<TUser> : ICustomPasswordHasher<TUser> where TUser : class , IUser<string>
{
@theuntitled
theuntitled / CookieJar.cs
Created April 27, 2016 08:32
ASP.NET CookieJar Class
using System;
using System.Linq;
using System.Web;
namespace Project
{
public class CookieJar
{
public HttpRequest Request => return HttpContext.Current.Request;
@theuntitled
theuntitled / query.sql
Created July 7, 2016 11:15
Get all logical database file names
SELECT DB_NAME(database_id) AS DatabaseName, name AS LogicalFileName, physical_name AS PhysicalFileName
FROM sys.master_files AS mf
using Xamarin.Forms.Xaml;
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
@theuntitled
theuntitled / DataContext.cs
Created August 31, 2016 15:43
Entity Framework Core - Identity AspNet Tables
...
protected override void OnModelCreating(ModelBuilder builder)
{
builder.Entity<User>().ForSqlServerToTable("Users");
builder.Entity<IdentityRole>().ForSqlServerToTable("Roles");
builder.Entity<IdentityUserRole<string>>().ForSqlServerToTable("UserRoles");
builder.Entity<IdentityUserClaim<string>>().ForSqlServerToTable("UserClaims");
builder.Entity<IdentityRoleClaim<string>>().ForSqlServerToTable("RoleClaims");
builder.Entity<IdentityUserLogin<string>>().ForSqlServerToTable("UserLogins");
builder.Entity<IdentityUserToken<string>>().ForSqlServerToTable("UserTokens");
@theuntitled
theuntitled / TaxonomySearchResult.ts
Created September 20, 2016 11:50
SharePoint 2013 JSOM Taxonomy Managed Metadata Field Result
class TaxonomySearchResult {
id: string;
label: string;
termSetId: string;
parentTermId: string;
constructor(resultValue: string) {
const informationParts = resultValue.split(";");
for (let i = 0; i < informationParts.length; i++) {
@theuntitled
theuntitled / CustomSqlErrorLog.cs
Created April 19, 2017 13:54
ASP.NET MVC error page containing the ELMAH error id
using System.Collections;
using System.Web;
using Elmah;
namespace Project
{
/// <summary>
/// A custom implementation of the elamh provided <see cref="SqlErrorLog" />.
/// </summary>
public class CustomSqlErrorLog : SqlErrorLog
@theuntitled
theuntitled / rainbows.css
Created June 9, 2017 12:51
Rainbow text effect for your text
.easteregg {
animation: rainbow 1s infinite linear;
-moz-animation: rainbow 1s infinite linear;
-webkit-animation: rainbow 1s infinite linear;
-o-animation: rainbow 1s infinite linear;
-webkit-transition: color;
-moz-transition: color;
-o-transition: color;
transition: color
}