Skip to content

Instantly share code, notes, and snippets.

View johnny77221's full-sized avatar

John Hsu johnny77221

View GitHub Profile
@johnny77221
johnny77221 / stop-video.js
Last active July 20, 2020 02:21 — forked from cferdinandi/stop-video.js
A simple method to stop YouTube, Vimeo, and HTML5 videos from playing.
/**
* Stop an iframe or HTML5 <video> from playing
* @param {Element} element The element that contains the video
*/
var stopVideo = function ( element ) {
element.querySelectorAll('iframe').forEach(function(iframe) {
if ( iframe.contentWindow ) { /* send stop to content */
stopVideo(iframe.contentWindow.document);
}
else { /* Cross Domain, resetting src is all we can do, and the iframe might fail loading same url */
@johnny77221
johnny77221 / Storage.swift
Last active June 15, 2018 00:31 — forked from saoudrizwan/Storage.swift
Helper class to easily store and retrieve Codable structs from/to disk. https://medium.com/@sdrzn/swift-4-codable-lets-make-things-even-easier-c793b6cf29e1
import Foundation
public class Storage {
fileprivate init() { }
enum Directory {
// Only documents and other data that is user-generated, or that cannot otherwise be recreated by your application, should be stored in the <Application_Home>/Documents directory and will be automatically backed up by iCloud.
case documents