Skip to content

Instantly share code, notes, and snippets.

View kradcliffe's full-sized avatar

Kevin Radcliffe kradcliffe

  • Medical Venture Partners, LLC
  • Denver, CO
View GitHub Profile
@kradcliffe
kradcliffe / gist:2017635
Created March 11, 2012 18:40
Very annoying ObjectQuery API quirk
// Convenience property on MyDbContext for easy access to the ObjectContext
public ObjectContext ObjectContext
{ get { return ((IObjectContextAdapter)this).ObjectContext; } }
/* The actual problem - goes against the expected fluent API here */
var ctx = new MyDbContext().ObjectContext;
ObjectQuery<TModel> query = ctx.CreateObjectSet<TModel>();
query.Include("Site"); // Silently DOESN'T INCLUDE "Site"
query.OrderBy("it." + orderBy); // Silently DOESN'T ORDER BY our orderBy
@kradcliffe
kradcliffe / AutoMapperExtensions.cs
Created February 28, 2012 12:28
Automapper extension to IGNORE unmapped properties for a given type
public static class AutoMapperExtensions
{
public static IMappingExpression<TSource, TDestination>
IgnoreAllNonExisting<TSource, TDestination>(this IMappingExpression<TSource, TDestination> expression)
{
var sourceType = typeof(TSource);
var destinationType = typeof(TDestination);
var existingMaps = Mapper.GetAllTypeMaps().First(x => x.SourceType.Equals(sourceType) && x.DestinationType.Equals(destinationType));
foreach (var property in existingMaps.GetUnmappedPropertyNames())
{
def add_acl app_path, desiredFilesystemRights, groupOrAccountName
di = DirectoryInfo.new app_path
ds = di.GetAccessControl
simple_rule = FileSystemAccessRule.new(
groupOrAccountName,
desiredFilesystemRights,
AccessControlType.Allow
)
module Gem
def self.default_exec_format
exec_format = ConfigMap[:ruby_install_name].sub('ruby', '%s') rescue '%s'
#unless exec_format =~ /%s/ then
# raise Gem::Exception,
# "[BUG] invalid exec_format #{exec_format.inspect}, no %s"
#end
exec_format