Skip to content

Instantly share code, notes, and snippets.

View benfrain's full-sized avatar

Ben Frain benfrain

View GitHub Profile
@benfrain
benfrain / animateNumericValues.ts
Last active February 7, 2019 15:21
JS utility to animate numeric values from one value to another
/**
* [animateNumericValues interpolates from one number to another with a max of 60 integers per second]
* @param {Element} element [The DOM element that will get interpolated]
* @param {number} fromValue [the first value]
* @param {number} toValue [the final value]
* @param {number} speed [how long the animation should take in milliseconds]
* @param {delay} delay [any delay before it starts counting up]
* @param {string} appendString [optional string that gets appended to the value. E.g. "%"]
*/
function animateNumericValues({

Styling native elements

Native HTML controls are a challenge to style. You can style any element in the web platform that uses Shadow DOM with a pseudo element ::pseudo-element or the /deep/ path selector.

video::webkit-media-controls-timeline {
  background-color: lime;
}

video /deep/ input[type=range] {
@benfrain
benfrain / allowSVG.php
Created March 8, 2014 00:05
Allow SVG upload and preview to Media area of Wordpress (add this to functions.php)
function custom_mtypes( $m ){
$m['svg'] = 'image/svg+xml';
$m['svgz'] = 'image/svg+xml';
return $m;
}
add_filter( 'upload_mimes', 'custom_mtypes' );
@benfrain
benfrain / webkit-video.css
Last active April 2, 2024 12:45
Video controls for WebKit
video::-webkit-media-controls-fullscreen-button {}
video::-webkit-media-controls-play-button {}
video::-webkit-media-controls-timeline {}
video::-webkit-media-controls-current-time-display{}
video::-webkit-media-controls-time-remaining-display {}
video::-webkit-media-controls-mute-button {}
video::-webkit-media-controls-toggle-closed-captions-button {}
video::-webkit-media-controls-volume-slider {}
@benfrain
benfrain / post-receive.sh
Last active June 8, 2024 20:52
post-receive hook for multiple branches
#!/bin/bash
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then
git --work-tree=./path/under/root/dir/live-site/ checkout -f $branch
echo 'Changes pushed live.'
fi