Skip to content

Instantly share code, notes, and snippets.

View ronnieoverby's full-sized avatar
🏠
Working from home

Ronnie Overby ronnieoverby

🏠
Working from home
  • Olo
  • Lexington, NC
View GitHub Profile
@ronnieoverby
ronnieoverby / DemoGettingUsersInSpecificRole.cs
Created January 30, 2015 21:57
Demonstrates efficiently querying the default MVC 5 entity framework model for users in a given role.
using System;
using System.Collections.Generic;
using System.Linq;
using WebApplication9.Models;
namespace WebApplication9
{
public class DemoGettingUsersInSpecificRole
{
private readonly ApplicationDbContext _db;
@ronnieoverby
ronnieoverby / Base64Extensions.cs
Created February 21, 2015 16:47
I got bored and implemented a base64 encoder/decoder. This is much slower than the .NET implementation.
public static class Base64Extensions
{
private static readonly Lazy<char[]> EncMap =
new Lazy<char[]>(BuildEncodingMap);
private static readonly Lazy<int[]> DecMap =
new Lazy<int[]>(BuildDecodingMap);
private const char Pad = '=';
@ronnieoverby
ronnieoverby / index.html
Created March 5, 2015 02:56
peek @ password angular directive
<p>
The password input below is using the "peek-password" directive.
Focusing on the input will reveal the peek icon on the right side.
Hovering the mouse over the peek icon will cause the password value to be visible.
Try it!
</p>
<form ng-app="app" class="form-horizontal">
var dt = DateTime.Parse("3/1/2015 12:07 AM", CultureInfo.CurrentCulture, DateTimeStyles.AssumeUniversal);
var dto = new DateTimeOffset(dt);
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace CoreTechs.Common
{
public class BufferedEnumerable<T> : IEnumerable<T>
{
using System;
using System.Collections.Generic;
public class CharacterComparer : IEqualityComparer<char>, IEqualityComparer<string>
{
public static readonly CharacterComparer Ordinal = new CharacterComparer(StringComparer.Ordinal);
public static readonly CharacterComparer OrdinalIgnoreCase = new CharacterComparer(StringComparer.OrdinalIgnoreCase);
public static readonly CharacterComparer CurrentCulture = new CharacterComparer(StringComparer.CurrentCulture);
public static readonly CharacterComparer CurrentCultureIgnoreCase = new CharacterComparer(StringComparer.CurrentCultureIgnoreCase);
public static readonly CharacterComparer InvariantCulture = new CharacterComparer(StringComparer.InvariantCulture);
void Main()
{
using(var l = new ReaderWriterLockSlim())
{
var tasks = Enumerable.Range(0,2).Select (i =>
Task.Run(() =>
{
l.EnterUpgradeableReadLock();
try
{
var n = 1234;
var array = map(n.toString().split(''), parseInt);
public static class LightInjectExtensions
{
public static void RegisterFunc<T>(this IServiceRegistry reg, Func<IServiceFactory, T> factoryFunc)
{
if (reg == null) throw new ArgumentNullException("reg");
reg.Register(sf => factoryFunc(sf));
}
}
onmessage = function(msg) {
// TODO: long running code that uses msg.data to figure out answer to everything
postMessage(42);
};