Skip to content

Instantly share code, notes, and snippets.

Avatar
📺
Movin vidja bits

Matthew McClure mmcc

📺
Movin vidja bits
View GitHub Profile
@mmcc
mmcc / saga.ts
Last active Jun 28, 2019
Redux Confirmation Modal Examples
View saga.ts
function *deleteAsset (action: Action<'AssetDeleteRequested'>) {
const { payload: { id }, meta: { callbackAction } } = action;
yield put({ type: 'ConfirmAction', payload: { actionType: action.type } });
const { canceled } = yield race({
confirmed: take('ActionConfirmed'),
canceled: take('ActionCanceled'),
});
if (canceled) {
@mmcc
mmcc / elixir-example.ex
Last active Jan 31, 2019
Node & Elixir Updates
View elixir-example.ex
# These examples assume you have your token id and secret in your Mix config:
# config :mux, token_id: 'your-token-id', token_secret: 'your-token-secret'
# Same as above, first we'll create a token with defaults: 7 day expiration for video
video_token = Mux.Token.sign('your-playback-id')
# https://stream.mux.com/your-playback-id.m3u8?token=#{token}
gif_token = Mux.Token.sign('your-playback-id',
type: :gif,
expiration: 60 * 60 * 3 # 3 hours
@mmcc
mmcc / access.ts
Created Mar 29, 2018
Simple example to show an issue with array index access.
View access.ts
interface IGenericThing {
bop: [string, string, string];
[key: string]: string | number | [string, string, string];
}
const foo: IGenericThing = {
bar: '#0000ff',
baz: 123,
bat: ['a', 'b', 'c'],
bop: ['d', 'e', 'f'],
@mmcc
mmcc / authed_conn_case.ex
Last active Dec 7, 2017
Elixir test macros
View authed_conn_case.ex
defmodule AppWeb.AuthConnCase do
alias AppWeb.Router
use ExUnit.CaseTemplate
import Phoenix.ConnTest, only: [dispatch: 5, json_response: 2]
@doc """
Allows you to call the same set of tests with the same describe block
Setups is an array of named setups, i.e. [first_setup: [:setup_conn, :thing], second_setup: [:different_setup, :neato_setup]]
## Examples
@mmcc
mmcc / install-docker-mint.sh
Last active Aug 15, 2020 — forked from sirkkalap/Install-Docker-on-Linux-Mint.sh
Install Docker on Linux Mint 17
View install-docker-mint.sh
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sh -c 'echo deb https://apt.dockerproject.org/repo ubuntu-trusty main > /etc/apt/sources.list.d/docker.list'
# Install docker
sudo apt-get update
sudo apt-get purge lxc-docker
sudo apt-get install linux-image-extra-$(uname -r)
sudo apt-get install docker-engine
sudo service docker start
@mmcc
mmcc / index.html
Created Mar 27, 2015
HTML5 boilerplate
View index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Awesome Boilerplate</title>
<link rel="stylesheet" href="css/main.css">
</head>
@mmcc
mmcc / stringificated.js
Last active Aug 29, 2015
Stringifying strings
View stringificated.js
var blah = { foo: "bar", neat: "true", something: "{\"cool\": \"not\"}"}
// { foo: 'bar',
// neat: 'true',
// something: '{"cool": "not"}' }
// So far, so good.
var stringified = JSON.stringify(blah)
// '{"foo":"bar","neat":"true","something":"{\\"cool\\": \\"not\\"}"}'
// Not what we wanted, but this is reasonable and expected.
@mmcc
mmcc / suite.js
Created Dec 11, 2014
chain smoker example config
View suite.js
var Suite = {};
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
Suite.tests = [
{
name: 'Test Delivery',
address: 'http://www.example.com/accounts/'+ getRandomInt(100, 999) +'/subscriptions',
@mmcc
mmcc / slack-import.js
Created Dec 10, 2014
Had trouble with too many temporary accounts on slack import, so hacked this together.
View slack-import.js
var $selects = $('.user_map_selector select');
var throwAwayEmail = function(index) {
return 'oldsupportacct+'+ getRandomInt(2500, 99999) +'@zencoder.com';
}
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
var count = 0;
@mmcc
mmcc / audio.html
Created Oct 3, 2014
Video.js Audio example
View audio.html
<audio id="audio_example" class="video-js vjs-default-skin" controls preload="auto"
width="600" height="600" poster="/img/awesome-album-art.png" data-setup='{}'>
<source src="/audio/awesome-music.mp3" type='audio/mp3'/>
</audio>