Skip to content

Instantly share code, notes, and snippets.

Chris Airey cairey

Block or report user

Report or block cairey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
cairey / gist:975ea7ab2ccdab48af95
Created Feb 7, 2016
Grab an UTC timecode from an offset in seconds on a Unified Streaming Server. Takes it to account encoder reconnects / restarts.
View gist:975ea7ab2ccdab48af95
def timecode_from_offset (nokogiri_doc, pos_in_secs, in_point_utc)
utc_result = in_point_utc
video_el ='video').first
c_els = video_el.css('c')
final_c_els = []
total_seconds = pos_in_secs
c_els.each do |c_el|
end_of_c_utc = DateTime.parse(c_el['end'])
if end_of_c_utc > in_point_utc
cairey / OffsetFromTimecode.cs
Created Feb 7, 2016
Grab an offset in seconds from a UTC timecode on a Unified Streaming Server. Takes it to account encoder reconnects / restarts. This is the C# version.
View OffsetFromTimecode.cs
public double GetOffsetFromTimecode(Guid eventId, DateTime startPos, DateTime inPoint)
startPos = startPos.ToUniversalTime();
inPoint = inPoint.ToUniversalTime();
var ismUrl = _configuration.GenerateIsmStreamUrl(eventId);
var streamUrl = ismUrl + "/archive";
var doc = XDocument.Load(streamUrl);
var videoEl = doc.Descendants().First(x => x.Name.LocalName == "video");
cairey / offset_from_timecode.rb
Created Feb 7, 2016
Grab an offset in seconds from a UTC timecode on a Unified Streaming Server. Takes it to account encoder reconnects / restarts. This is the Ruby version.
View offset_from_timecode.rb
def offset_from_timecode (nokogiri_doc, start_pos_utc, in_point_utc)
video_el ='video').first
c_els = video_el.css('c')
final_c_els = []
total_seconds = 0
start_pos_time = Time.parse(start_pos_utc.to_s)
c_els.each do |c_el|
end_of_c_utc = DateTime.parse(c_el['end'])
final_c_els << c_el if end_of_c_utc > in_point_utc
cairey / unfollow.js
Created Feb 7, 2016
Unfollow people that do not follow you on Twitter
View unfollow.js
/* Scroll to the bottom of
Open the Console and run the following
$('.ProfileCard-content').each(function(){var status = $(this).find('.FollowStatus').text();var unfollowButton = $(this).find('.user-actions-follow-button');if(status != 'follows you'){;}});
View gist:fb5dd88838b57ca27107
public class HashedUrl
private readonly string _secretKey;
private readonly string _urlToHash;
private readonly DateTime _startDate;
private readonly DateTime _endDate;
/// <summary>
/// Hash a url
/// </summary>
cairey / gist:5501024
Last active Apr 15, 2019
Programmatically start IIS Express from code.
View gist:5501024
public static class IISExpress
private static readonly List<string> sites = new List<string>();
private static readonly List<string> paths = new List<string>();
public static void StartIISExpress(string site, int port = 7329)
else return;
cairey /
Created May 1, 2013
Inspect the Visual Studio solution and project settings using T4 template code gen.
<#@ template language="C#" debug="true" hostSpecific="true" #>
<#@ output extension=".cs" #>
<#@ Assembly Name="System.Core.dll" #>
<#@ assembly name="EnvDTE" #>
<#@ Assembly Name="System.Windows.Forms.dll" #>
<#@ Assembly name="System.Configuration"#>
<#@ import namespace="System" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Diagnostics" #>
<#@ import namespace="System.Linq" #>
cairey / gist:4563456
Created Jan 18, 2013
iTextSharp PdfStamper stream to MVC File Result
View gist:4563456
public virtual ActionResult PdfDownloadTravel()
var reader = new PdfReader(Server.MapPath("~/pdf/travel_insurance_card.pdf"));
var outputPdfStream = new MemoryStream();
var stamper = new PdfStamper(reader, outputPdfStream) { FormFlattening = true, FreeTextFlattening=true };
var form = stamper.AcroFields;
form.SetField("Name", "");
form.SetField("number", "500-0000324");
cairey / gist:3917111
Created Oct 19, 2012
MSTestContrib BDD Extensions
View gist:3917111
namespace MSTestContrib.Specifications
public static class BDDExtensions
public static ThenGrammar Then(this WhenGrammar whenGrammar, string description, Action<SpecificationContext> implementation)
Func<SpecificationContext, bool> implementationWithReturnTrue = (x) =>
return true;
View UnitOfWorkBehaviorAttribute.cs
public class UnitOfWorkBehaviorAttribute : Attribute, IContractBehavior, IContractBehaviorAttribute
public void Validate(ContractDescription contractDescription, ServiceEndpoint endpoint)
{ }
public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
foreach(var operation in dispatchRuntime.EndpointDispatcher.DispatchRuntime.Operations)
operation.CallContextInitializers.Add(new PCMUnitOfWorkCallContextInitializer());
You can’t perform that action at this time.