Skip to content

Instantly share code, notes, and snippets.

@RodH257
RodH257 / gist:142314f2c60afca4b2de
Created September 7, 2014 12:30
Referencing full image path in Xamarin iOS apps
public static class GetFullImagePath
{
public static string ForFileName (string fileName)
{
//Any old images with a full file path stored should have the front part removed
if (fileName.Contains ("/"))
{
fileName = fileName.Substring (fileName.LastIndexOf ("/") + 1);
}
var docsDir = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
@RodH257
RodH257 / gist:4045370
Created November 9, 2012 12:01
SetupAllObjectSets
public static Mock<IUnitOfWork> SetupAllObjectSets(this Mock<IUnitOfWork> mock)
{
var properties = typeof(IUnitOfWork).GetProperties();
foreach (var property in properties)
{
//IObjectSet<Of Something>
var genericType = property.PropertyType.GetGenericTypeDefinition();
if (genericType == typeof(System.Data.Objects.IObjectSet<>))
{
//Gets the <T> out of IObjectSet<T>
@RodH257
RodH257 / gist:4472165
Last active December 10, 2015 18:08
EF Detatch
static int[] Detach<TEntity>(
this IUnitOfWork unitOfWork, Func<TEntity, bool> where, Func<TEntity, int> getKey = null)
where TEntity : EntityObject
{
if (!(unitOfWork is ObjectContext))
{
return new int[0];
}
var objectContext = ((ObjectContext)unitOfWork);
@RodH257
RodH257 / vogels-dates-problem.js
Created April 10, 2016 10:07
Demonstration of Vogels issue saving dates inside objects inside arrays
const vogels = require('vogels');
const Joi = require('joi');
const AWS = require('aws-sdk');
// setup Vogels
vogels.log.level('debug');
vogels.AWS.config.update({
region: 'us-west-1',
});
### Keybase proof
I hereby claim:
* I am rodh257 on github.
* I am rodh257 (https://keybase.io/rodh257) on keybase.
* I have a public key ASC991rqSF5IdhmoplmPbuAw_WSI61Zp_7iR-vXlYNwbggo
To claim this, I am signing this object: