This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| PHP function for converting an ISO8601 duration (the kind used by YouTube's API) | |
| to something more readable. | |
| */ | |
| make_readable_duration($duration) | |
| { | |
| $duration = new DateInterval($duration); | |
| return $duration->format('%H:%I:%S'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function iso8601ToSeconds($input) { | |
| $duration = new DateInterval($input); | |
| $hours_to_seconds = $duration->h * 60 * 60; | |
| $minutes_to_seconds = $duration->i * 60; | |
| $seconds = $duration->s; | |
| return $hours_to_seconds + $minutes_to_seconds + $seconds; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function flatten2d($multi_dimensional_array) { | |
| $flattened = []; | |
| $flatten = function($value, $index) { | |
| global $flattened; | |
| array_push($flattened, $value); | |
| }; | |
| array_walk_recursive($multi_dimensional_array, $flatten); | |
| return $flattened; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Simple way to check whether a particular value is numeric. Saving it here so that I don't have to solve it twice. | |
| const isNumeric = (value) => { | |
| return !Number.isNaN(parseFloat(value,10)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function array_mode($$arr) { | |
| /* | |
| Count the frequency of occurrence of values in the array. | |
| This will make each duration value into a key, with its frequency as the | |
| value | |
| */ | |
| $counts = array_count_values($$arr); | |
| /* | |
| Get all of the count values and find the unique values, then sort them, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Tested on macOS 11.3.1 with ffmpeg installed with homebrew | |
| Use the h264_videotoolbox codec. -b:v is the bitrate flag. Using a higher | |
| bitrate improves quality, but increases file size. | |
| 760k (include the k!) gives a nice balance between quality and file size. | |
| ffmpeg -i input.gif -vcodec h264_videotoolbox -b:v 760k output.h264.mp4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const formatDate = ( dateStr ) => { | |
| let returned = ''; | |
| if( 'Intl' in window ) { | |
| const dateObj = new Date( dateStr ); | |
| const options = { | |
| month: 'long', | |
| timeZone: 'America/Los_Angeles', | |
| day: 'numeric', | |
| year: 'numeric' | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -e | |
| if [ ! -d src/amazon-s3-and-cloudfront ]; then | |
| echo 'This script must be run from the repository root.' | |
| exit 1 | |
| fi | |
| for PROG in composer find sed unzip |
OlderNewer