Skip to content

Instantly share code, notes, and snippets.

View cogdog's full-sized avatar

Alan Levine cogdog

View GitHub Profile
b4oshany / discourse-api.php
Created October 8, 2020 10:28
Discourse API - Generate new topics, posts and PM
header('Content-Type: application/json');
//Make sure that it is a POST request.
if (strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') != 0) {
echo json_encode(array("error" => 'Request method must be POST!'));
//Make sure that the content type of the POST request has been set to application/json
$contentType = isset($_SERVER["CONTENT_TYPE"]) ? trim($_SERVER["CONTENT_TYPE"]) : '';
bajpangosh / index.html
Created November 27, 2018 08:09
YouTube API - Multiple Videos on One Page
<div class="video-item">
<iframe id="video0" src="//" frameborder="0" allowfullscreen></iframe>
<button class="play">Play</button>
<button class="stop">Stop</button>
<div class="video-item">
<iframe id="video1" src="//" frameborder="0" allowfullscreen></iframe>
<button class="play">Play</button>
<button class="stop">Stop</button>
Plugin Name: UTF8mb4-convert
Version: 1.0
function update_db_to_utf8mb4() {
if ( ! isset( $_GET['update-utf8bm4'] ) ) {
troutcolor /
Last active December 15, 2019 06:31
#script to download pile of flickr images and make a movie like the pummelvision service # example #needs ffmpeg sox & jhead #needs sips so a mac I think
#2018 additions
#needs jhead which I installed with homebrew
#jhead auto rotates images according to the exif Orientation which ffmpeg does not respect
#if the photos do not need rotated then you could remove the jhead line below
#sox to loop audio. I installed with homebrew
#my video was longer than the audio, I just create a loop of 3 with sox and use that. Could up the number iif you have more photos than me
<title>Hello River</title>
The Hello World of Rivers
magnetikonline /
Last active September 27, 2022 18:12
Responsive embedding of Google Maps (or anything <iframe> embedded really).

Responsive Google Maps embedding

Simple technique for embedding Google Maps <iframe>'s responsively using a padding-bottom percentage trick, which when applied to a block element will be calculated as a percentage of the element width - essentially providing an aspect ratio.

This technique should work on anything that is <iframe> embedded from your social network/service of choice.

simplethemes / youtube-url.php
Created November 21, 2013 23:00
Extracts YouTube video ID from various URL structures
$url = array (
dfwood / wp-iso8601-datetime.php
Last active March 6, 2017 20:24
Datetime conversion functions for WordPress using the ISO8601 standard.
* Why does this exist? also because it makes sense to have a standard way in WordPress to work with
* dates and times so that plugin developers can create plugins that will work in any timezone worldwide.
* WordPress sets the default timezone during execution to UTC, reguardless of what the server is set to.
* This means that date( 'FORMAT' ) will always give you the current time in UTC, not the timezone you have set
* in the WP admin settings. Use date( 'FORMAT', current_time( 'timestamp' ) ) instead to get WP local time. Likewise,
* use current_time( 'timestamp' ) instead of time() for the local time.
kzrl / wordpress-admin.php
Created November 29, 2012 21:52
AJAX autocomplete on wordpress admin pages
<?php /* From */ ?>
// Register hooks
add_action('admin_print_scripts', 'add_script');
add_action('admin_head', 'add_script_config');
* Add script to admin page
luetkemj / wp-query-ref.php
Last active February 6, 2024 14:25
WP: Query $args
// This gist is now maintained on github at
* WordPress Query Comprehensive Reference
* Compiled by luetkemj -
* Source: