Skip to content

Instantly share code, notes, and snippets.

@cferdinandi
cferdinandi / myplugin-media.js
Last active December 27, 2025 03:22
Adding a Media Uploader to a custom metabox
/**
* Load media uploader on pages with our custom metabox
*/
jQuery(document).ready(function($){
'use strict';
// Instantiates the variable that holds the media library frame.
var metaImageFrame;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Mocha Tests</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://unpkg.com/mocha/mocha.css" />
</head>
<body>
<div id="mocha"></div>
@cferdinandi
cferdinandi / completed.html
Last active December 11, 2025 15:27
Learn the basics of vanilla JavaScript is about 10 minutes. Watch the video at https://www.youtube.com/watch?v=IQn_up6ZUkk, and grab more vanilla JS resources at https://gomakethings.com.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Learn Vanilla JS</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Styles -->
<style type="text/css">
@cferdinandi
cferdinandi / terminal-cheat-sheet.txt
Last active December 10, 2025 21:05
Terminal Cheat Sheet
# Terminal Cheat Sheet
pwd # print working directory
ls # list files in directory
cd # change directory
~ # home directory
.. # up one directory
- # previous working directory
help # get help
-h # get help
@cferdinandi
cferdinandi / web-servers.md
Created April 29, 2020 12:36 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Basic Setup</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
body {
margin: 1em auto;

Automate GitHub Release

This script automates the publishing of a new release on GitHub and runs npm deploy whenever the version number in package.json is changed.

It requires two secret tokens in the repo settings:

  1. GH_TOKEN - a fine-grained token with read/write permissions for content and pull releases.
  2. NPM_TOKEN - a CI token from your NPM account.

Learn more about how it works here.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Code Sandbox</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
@cferdinandi
cferdinandi / index.html
Created April 1, 2025 18:01
Watch the tutorial on YouTube: https://youtu.be/v-3O0MCl41k
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Toast Library</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
@cferdinandi
cferdinandi / stop-video.js
Last active August 2, 2025 14:10
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 ) {
var iframe = element.querySelector( 'iframe');
var video = element.querySelector( 'video' );
if ( iframe ) {
var iframeSrc = iframe.src;
iframe.src = iframeSrc;