Skip to content

Instantly share code, notes, and snippets.

View GFoley83's full-sized avatar
☘️
CTO @ Educa

Gavin Foley GFoley83

☘️
CTO @ Educa
View GitHub Profile
@jeffrafter
jeffrafter / export.sh
Created June 8, 2010 05:32
Exporting XML from Final Cut Pro using Apple Script
#!/bin/sh
# 'Enable access for assistive devices' must be selected in Universal Access preferences.
osascript -e "
try
tell application \"Final Cut Pro\" to activate
delay 0.5
tell application \"System Events\"
@jarrettmeyer
jarrettmeyer / ObjectToDictionaryHelper.cs
Created January 27, 2011 15:53
C# convert an object to a dictionary of its properties
public static class ObjectToDictionaryHelper
{
public static IDictionary<string, object> ToDictionary(this object source)
{
return source.ToDictionary<object>();
}
public static IDictionary<string, T> ToDictionary<T>(this object source)
{
if (source == null)
@Fodsuk
Fodsuk / gist:3025099
Created June 30, 2012 18:56
service layer exampe
public class InventoryController : ApiController
{
private readonly IInventoryManagementService _inventoryManagementService;
private readonly IUnitOfWork _unitOfWork;
public InventoryController(IUnitOfWork unitOfWork)
{
_unitOfWork = unitOfWork; //access services
_inventoryManagementService = _unitOfWork.Get<IInventoryManagementService>();
}
@cuppster
cuppster / 1.cs
Created September 3, 2012 18:39
Promises for C# using Generics
/*
modified from original source: https://bitbucket.org/mattkotsenas/c-promises/overview
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Promises
@chrisallick
chrisallick / gist:3648116
Created September 5, 2012 23:57
Force preload of video in HTML5
function addSourceToVideo(element, src, type) {
var source = document.createElement('source');
source.src = src;
source.type = type;
element.appendChild(source);
}
var video;
@codingoutloud
codingoutloud / RandomTokenGenerator.cs
Created December 4, 2012 04:14
Generate a random string that is URL safe.
using System;
using System.Security.Cryptography;
using System.Web;
namespace DevPartners
{
// author: Bill Wilder, @codingoutloud
// original: https://gist.github.com/4200537
public static class RandomTokenGenerator
{
@munr
munr / gist:4282463
Created December 14, 2012 03:20
Helper class to simplify executing command line applications from C# and retrieving their output.
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading;
using NLog;
namespace CLE
{
/// <summary>
@jbtule
jbtule / AESGCM.cs
Last active October 30, 2023 21:14
I have two code examples that I wrote for best practices encrypting a string in c#. They are both using authenticated encryption. http://stackoverflow.com/a/10366194/637783
/*
* This work (Modern Encryption of a String C#, by James Tuley),
* identified by James Tuley, is free of known copyright restrictions.
* https://gist.github.com/4336842
* http://creativecommons.org/publicdomain/mark/1.0/
*/
using System;
using System.IO;
using System.Text;
@atifaziz
atifaziz / md5.cs
Created December 24, 2012 10:37
C# program to compute MD5 hash of files specified as command-line arguments
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
static class Program
{
static void Run(IEnumerable<string> args)
@mwunsch
mwunsch / emoji_image_replace.js
Last active August 13, 2023 21:44
Detect emoji unicode on a page, replace it with images (supplied by GitHub, for now). Goes great in your ~/.js
/**
*
* Here's a thing that will look through all the text nodes of a document, and
* upon encountering an emoji codepoint, will replace it with an image.
* For now, those images are pulled from GitHub, which isn't very nice, so I
* need to find a more suitable host.
*
* Much of this code was gleaned from staring at the minified GitHub JS.
*
* Copyright (c) 2013 Mark Wunsch. Licensed under the MIT License.