Skip to content

Instantly share code, notes, and snippets.

View rdundon's full-sized avatar

Robert Dundon rdundon

View GitHub Profile
// "videoTag" is <video> element pulled from the DOM
var videoPercentageRate = this.duration / 100;
var videoCompletionRateIntervals = [25,50,75,100];
videoTag.play = function() {
var percentageCompleted = (videoTag.currentTime / videoTag.duration) * 100
console.log(percentageCompleted);
if (percentageCompleted >= videoCompletionRateIntervals[0]) {
console.log(videoCompletionRateIntervals[0], '% of video completed');
// "videoTag" is <video> element pulled from the DOM
var videoPercentageRate = this.duration / 100;
var videoCompletionRateIntervals = [25,50,75,100];
videoTag.play = function() {
var percentageCompleted = (videoTag.currentTime / videoTag.duration) * 100
console.log(percentageCompleted);
if (percentageCompleted >= videoCompletionRateIntervals[0]) {
console.log(videoCompletionRateIntervals[0], '% of video completed');
/**
* Little script/function to get time intervals
*/
// Based on:
// https://stackoverflow.com/a/19225446/808870
const diffInHours = (startDate, endDate) => ( endDate.valueOf() - startDate.valueOf() ) / 1000 / 60 / 60;
const getTimeIntervalsPerHour = interval => {
@rdundon
rdundon / ShowJSON.js
Created September 4, 2019 15:25
Show JSON component
// Just shows props as JSON, To be used for testing and as a stub/placeholder
const ShowJSON = (props) => {
return ( <pre>
{JSON.stringify(props)}
</pre> );
}
@rdundon
rdundon / date_update.php
Created December 27, 2017 19:52
Update time without NTP with PHP
<?php
/**
* Little script to update date based on SO answer here: https://askubuntu.com/a/655528/158714
* but with more security in mind (as that answer just feeds the output right into bash)
*
* Useful for little VMs when NTP is blocked and you put VMs into saved state regularly/
*
* Run via cron as root or other privileged user.
*
* Robert Dundon
@rdundon
rdundon / git-setup.sh
Last active June 9, 2024 19:58 — forked from patik/git-setup.sh
Git and Node with Zscaler proxy
#!/bin/sh
# Git proxy settings
echo "Configuring Git for compatibility with ZScaler..."
git config --global http.proxy http://gateway.zscaler.net:80/
git config --system http.proxy http://gateway.zscaler.net:80/