Skip to content

Instantly share code, notes, and snippets.

View jasonbyrne's full-sized avatar

Jason Byrne jasonbyrne

View GitHub Profile
@jasonbyrne
jasonbyrne / timing.js
Last active August 29, 2015 14:05
Better Timing Management
/**
* Created by jasonbyrne on 8/30/14.
*/
window.JCB = window.JCB || {};
JCB.Timing = (function(){
// Self
var me = {};
// Private Properties
@jasonbyrne
jasonbyrne / xYourHeart.js
Last active August 29, 2015 14:06
Simple promise maker for browser JavaScript or Node.JS
/**
* Created by jasonbyrne on 9/2/14.
*/
var xYourHeart = (function(){
// Self-reference
var xYourHeart = {
STATUS: {
PENDING: 0,
FAILURE: -1,
var HTTP_STATUS = {
'OK': 200,
'CREATED': 201,
'ACCEPTED': 202,
'NON_AUTHORITATIVE': 203,
'NO_CONTENT': 204,
'RESET': 205,
'PARTIAL_CONTENT': 206,
'MULTI_STATUS': 207,
'ALREADY_REPORTED': 208,
@jasonbyrne
jasonbyrne / q.js
Created October 30, 2015 04:06
Untested queue
var q = (function() {
var me = this,
_callbacks = [],
_index = -1,
_nonePending = true;
me.then = function(callback) {
// Add this to the queue
_callbacks.push(callback);
@jasonbyrne
jasonbyrne / universal-install.sh
Created April 21, 2017 03:22
Bash function so you can just say install packageName regardless of apt or yum distro
#!/bin/bash
install(){
isApt=`command -v apt-get`
isYum=`command -v yum`
package=$1
if [ -n "$isApt" ]; then
apt-get -y install $package
elif [ -n "$isYum" ]; then
yum -y install $package
/**
* Imperavi Redactor Plugin for Embedding Tweets
* for version >= 9.1
*
* https://gist.github.com/jasonbyrne/6e96a907c781e90e0dbf
*
* @author Jason Byrne <jason.byrne@flocasts.com>
* @version 0.5.1
*
* @forked https://gist.github.com/chekalskiy/7438084
@jasonbyrne
jasonbyrne / hls.ts
Last active June 15, 2018 21:37
Watch an HLS stream on the best rendition and publish an event whenever a new segment arrives. Then optionally upload it to S3.
let request = require('request');
let validUrl = require('valid-url');
class PubSub {
protected subscribers: { [key: string]: Function } = {};
public subscribe(callback: Function): string {
let key: string = Date.now() + '_' + Math.ceil(Math.random() * 10000);
this.subscribers[key] = callback;
@jasonbyrne
jasonbyrne / iframe-manifest-generator.ts
Last active October 19, 2018 06:01
Generate an iframe only manifest from a video file with ffprobe and Node
// Work in progress to convert this to TypeScript/Node:
// https://gist.github.com/biomancer/8d139177f520b9dd3495
import { exec } from "child_process";
/**
*
*/
export class IframeByteRange {
public packetTime: number;
@jasonbyrne
jasonbyrne / flagpole-itunes-api.js
Last active November 27, 2018 20:45
Sample to accompany blog post of testing a REST API with Flagpole automation: https://engineering.flosports.tv/rest-api-testing-with-flagpole-part-2-60abcc03eaf1
const { Flagpole } = require('flagpole');
const suite = Flagpole.Suite('iTunes API Test')
.base('https://itunes.apple.com');
suite.Scenario('Music Videos Search')
.open('/search?term=2pac&entity=musicVideo')
.json()
.assertions(function (response) {
let firstResult = response.select('results').first();
@jasonbyrne
jasonbyrne / client-side-framework.ts
Last active December 18, 2018 01:15
Roll your own framework experiment
import { isFunction } from 'util';
abstract class Listener {
protected listeners: { [eventName: string]: [Function] } = {};
public on(eventName: string, callback: Function) {
this.listeners[eventName] = this.listeners[eventName] || [];
this.listeners[eventName].push(callback);
}