Skip to content

Instantly share code, notes, and snippets.

Avatar

Jason Byrne jasonbyrne

View GitHub Profile
@jasonbyrne
jasonbyrne / timing.js
Last active Aug 29, 2015
Better Timing Management
View timing.js
/**
* 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 Aug 29, 2015
Simple promise maker for browser JavaScript or Node.JS
View xYourHeart.js
/**
* Created by jasonbyrne on 9/2/14.
*/
var xYourHeart = (function(){
// Self-reference
var xYourHeart = {
STATUS: {
PENDING: 0,
FAILURE: -1,
View httpStatusCodes.js
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 Oct 30, 2015
Untested queue
View q.js
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 Apr 21, 2017
Bash function so you can just say install packageName regardless of apt or yum distro
View universal-install.sh
#!/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
View tweets.redactor.js
/**
* 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 Jun 15, 2018
Watch an HLS stream on the best rendition and publish an event whenever a new segment arrives. Then optionally upload it to S3.
View hls.ts
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 / country-code-to-name-lookup
Created Sep 21, 2018
Three character country code to country name object for JavaScript
View country-code-to-name-lookup
{
"ABW": "Aruba",
"AFG": "Afghanistan",
"AGO": "Angola",
"AIA": "Anguilla",
"ALA": "Åland Islands",
"ALB": "Albania",
"AND": "Andorra",
"ANT": "Netherlands Antilles",
"ARE": "United Arab Emirates",
@jasonbyrne
jasonbyrne / iframe-manifest-generator.ts
Last active Oct 19, 2018
Generate an iframe only manifest from a video file with ffprobe and Node
View iframe-manifest-generator.ts
// 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 Nov 27, 2018
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
View flagpole-itunes-api.js
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();