Skip to content

Instantly share code, notes, and snippets.

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
cairey / unfollow.js
Created February 7, 2016 10:47
Unfollow people that do not follow you on Twitter
/* Scroll to the bottom of https://twitter.com/following
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'){unfollowButton.click();}});
@cairey
cairey / offset_from_timecode.rb
Created February 7, 2016 10:59
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.
def offset_from_timecode (nokogiri_doc, start_pos_utc, in_point_utc)
video_el = nokogiri_doc.search('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
cairey / OffsetFromTimecode.cs
Created February 7, 2016 10:59
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.
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
cairey / gist:975ea7ab2ccdab48af95
Created February 7, 2016 11:00
Grab an UTC timecode from an offset in seconds on a Unified Streaming Server. Takes it to account encoder reconnects / restarts.
def timecode_from_offset (nokogiri_doc, pos_in_secs, in_point_utc)
utc_result = in_point_utc
video_el = nokogiri_doc.search('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