Skip to content

Instantly share code, notes, and snippets.

View richtr's full-sized avatar

Rich Tibbett richtr

View GitHub Profile
@richtr
richtr / style_scoped_shim.js
Created November 8, 2012 15:12
<style scoped> polyfill
/*!
* <style scoped> shim
* http://github.com/richtr
*
* Copyright 2012 Rich Tibbett
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
* Date: 8th November 2012
*/
@richtr
richtr / orientationChange.js
Last active February 26, 2021 09:11
JavaScript shim of iOS's window.orientation + orientationchange events for other (typically mobile) browsers
/*
* OrientationChange Event Shim
* http://github.com/richtr
*
* Copyright (c) 2012, Rich Tibbett
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
@richtr
richtr / config.yml
Last active November 28, 2017 21:36
Parse YAML from bash with sed and awk.
development:
adapter: mysql2
encoding: utf8
database: my_database
username: root
password:
apt:
- somepackage
- anotherpackage
@richtr
richtr / blockstack-verification.txt
Created February 10, 2017 16:46
Verifying that "richtr.id" is my Blockstack ID. https://onename.com/richtr
Verifying that "richtr.id" is my Blockstack ID. https://onename.com/richtr
@richtr
richtr / handbrake_nas.applescript
Last active January 1, 2017 23:00
Synology NAS (or any other AFP-based shared folder) to Handbrake auto-conversion of avi/mkv files to mp4
-- AppleScript that mounts an AFP service (e.g. a Synology NAS Diskstation) then
-- searches for any .avi or .mkv files in the requested volume and converts all
-- the files it finds to .mp4 via HandbrakeCLI (which must be installed on your
-- machine at /Applications/HandbrakeCLI)
-- IMPORTANT: You may need to make sure your NAS does not sleep until ~4 hours of
-- inactivity has passed so it doesn't interrupt the mp4 conversion process of
-- this script.
-- Based loosely on the script published at http://cybernetnews.com/batch-convert-videos-handbrake-applescript/
@richtr
richtr / Element.js
Created February 3, 2012 14:25
DOM Element Constructor wrapper
/**
* DOM Element constructor helper class.
*
* Usage:
* -------
* var newDiv = Element.create('div');
* var newDiv = Element.create('div', {text: "Hi"});
* var newDiv = Element.create('div', {text: "Hi "}, [
* Element.create('span', {style: 'color: #CC0000', html:"<b>you</b>"}, [
* // Infinitely chainable
@richtr
richtr / logo_mediasession
Created June 30, 2015 10:10
Media Session Logo
<?xml version="1.0"?>
<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
<g>
<title>Layer 1</title>
<circle fill-opacity="0" id="svg_1" stroke-width="10" stroke="#3c790a" fill="#000000" r="45" cy="50" cx="50"/>
<rect stroke="#3c790a" id="svg_8" height="40.5" width="1.75" y="29.5" x="60.25" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="5" fill="#3c790a"/>
<path stroke="#3c790a" id="svg_6" d="m31.25,32.631443l0.5,33.819592l22,-16.816372l-22.5,-17.00322z" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="5" fill="#3c790a"/>
<rect stroke="#3c790a" id="svg_9" height="40.5" width="1.75" y="29.5" x="70.375" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="5" fill="#3c790a"/>
</g>
</svg>
@richtr
richtr / gist:2235fdae25c74186297d
Last active August 29, 2015 14:13
General considerations for Media Focus scoping, lifecycle and events

Media Focus Scope

  • At what level should Media Focus be requested and granted/revoked?

    • Per Tab(s)
      • Per Origin(s)
        • Per Document(s)
          • Per Media Grouping(s)
            • Per Media Object(s)
  • High-level vs. Low-level scope - what are the pros and cons of setting the media focus scope at these different levels? Do we want audio focus to be set and applied implicitly to tab/document/origin content or explicitly to in-page media groupings or elements?

@richtr
richtr / SensorCheck.js
Created September 23, 2014 14:21
A reliable DeviceOrientation and DeviceMotion Events API feature detection library
/**
* DeviceOrientation and DeviceMotion Events Detection API
*
* Example API Usage (Promise-based API):
*
* supportsDeviceOrientationEvents().then(function() {
* console.log("Platform DeviceOrientation Events support OK");
* }, function(error) {
* console.error("Platform DeviceOrientation Events support KO");
* });
@richtr
richtr / NormalVariablesFunctions.js
Last active August 29, 2015 13:59
Variable-bound Functions: JIT (Just In Time) function binding as an alternative to inline conditional statements within fast render loops
/**
*
* Normal method w/ inline conditional statements placed within each render loop
*
*/
var myVariable = true;
function normalLoop() {
if ( myVariable === true ) {