Skip to content

Instantly share code, notes, and snippets.

View sharpjs's full-sized avatar
💾
Flipping bits, taking bytes

Jeff Sharp sharpjs

💾
Flipping bits, taking bytes
View GitHub Profile
@sharpjs
sharpjs / SaveEntityFrameworkProxyAssembly.cs
Created January 30, 2013 22:30
Make Entity Framework save the dynamic proxy assembly it uses
private void SaveEntityFrameworkProxyAssembly(params Type[] types)
{
var factoryType = typeof(ObjectContext).Assembly.GetType(
"System.Data.Objects.Internal.EntityProxyFactory",
throwOnError: true);
var privateStaticFlags
= BindingFlags.Static
| BindingFlags.NonPublic;
@sharpjs
sharpjs / FakeDbContext.cs
Last active November 15, 2016 15:16
How to fake a DbSet<T> for Entity Framework (EF5 as of this writing)
namespace SharpJS.Data.Entity.Testing
{
public abstract class FakeDbContext
{
protected FakeDbContext() { }
public abstract void SaveChanges ();
public abstract void Dispose ();
}
}
@sharpjs
sharpjs / IUrlToken.cs
Created September 17, 2013 15:08
Convert objects to/from encrypted URL tokens.
using System.IO;
namespace SharpJS.Web
{
public interface IUrlToken
{
void WriteTo (BinaryWriter writer);
void ReadFrom (BinaryReader reader);
}
}
@sharpjs
sharpjs / ControllerTestExtensions.cs
Created September 18, 2013 14:27
Mocking controller context in ASP.NET MVC
using System;
using System.Collections;
using System.Security.Principal;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Moq;
namespace SharpJS.Web.Testing
{
@sharpjs
sharpjs / AssemblyInfo.cs
Created May 14, 2014 22:24
Example Per-Project AssemblyInfo.cs
using System.Reflection;
using System.Security;
// General Information
[assembly: AssemblyTitle ("My Utility")]
[assembly: AssemblyDescription ("A neat program that does a few useful things.")]
// Security
//
// All code is transparent.
@sharpjs
sharpjs / dynamic_eq.rs
Created December 27, 2015 18:17
Rust Dynamic Trait Equality Deriving
// Dynamic Trait Equality Deriving
//
// Copyright (C) 2015 Jeffrey Sharp
//
// This file is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// This file is distributed in the hope that it will be useful, but
@sharpjs
sharpjs / shared.rs
Created December 27, 2015 18:18
Rust Smart Pointer to Shared Immutable Data
// Smart Pointer to Shared Immutable Data
//
// Copyright (C) 2015 Jeffrey Sharp
//
// This file is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// This file is distributed in the hope that it will be useful, but
@sharpjs
sharpjs / functor.rs
Created March 26, 2016 10:44
Functor (fmap) for Rust
// Functors (fmap) for Rust
//
// Copyright (C) 2016 Jeffrey Sharp
//
// This file is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// This file is distributed in the hope that it will be useful, but
@sharpjs
sharpjs / CrashPlan.md
Last active November 19, 2016 19:27
Running CrashPlan in Docker on a Synology NAS
@sharpjs
sharpjs / bash-files.md
Last active February 20, 2022 23:44
Bash Startup File Chart

What files will Bash run automatically?

When invoked as bash:

Remote Non-Login Login
Interactive
  • .bashrc
  • .bashrc
  • /etc/profile
  • First one of:
    • .bash_profile
    • .bash_login
    • .profile
  • .bash_logout
Non-Interactive
  • .bashrc
  • $BASH_ENV
  • /etc/profile
  • First one of:
    • .bash_profile
    • .bash_login
    • .profile
  • $BASH_ENV
  • .bash_logout (if exit invoked)

When invoked as sh: