Skip to content

Instantly share code, notes, and snippets.

View cogdog's full-sized avatar

Alan Levine cogdog

View GitHub Profile
@dfwood
dfwood / wp-iso8601-datetime.php
Last active March 6, 2017 20:24
Datetime conversion functions for WordPress using the ISO8601 standard.
<?php
/**
* Why does this exist? http://xkcd.com/1179/ 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.
*/
@simplethemes
simplethemes / youtube-url.php
Created November 21, 2013 23:00
Extracts YouTube video ID from various URL structures
<?php
$url = array (
'http://youtu.be/dQw4w9WgXcA',
'http://www.youtube.com/embed/dQw4w9WgXcB',
'http://www.youtube.com/watch?v=dQw4w9WgXcC',
'http://www.youtube.com/?v=dQw4w9WgXcD',
'http://www.youtube.com/v/dQw4w9WgXcE',
'http://www.youtube.com/e/dQw4w9WgXcF',
'http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcG',
@troutcolor
troutcolor / pum.sh
Last active December 15, 2019 06:31
#script to download pile of flickr images and make a movie like the pummelvision service # example https://vimeo.com/196182638 #needs ffmpeg sox & jhead #needs sips so a mac I think
#!/bin/bash
#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
<html>
<head>
<title>Hello River</title>
<!--
The Hello World of Rivers
https://github.com/scripting/river5/blob/master/docs/HELLOWORLD.md
-->
@kzrl
kzrl / wordpress-admin.php
Created November 29, 2012 21:52
AJAX autocomplete on wordpress admin pages
<?php /* From http://sudarmuthu.com/blog/using-wordpress-built-in-tag-auto-complete-script-in-your-plugins */ ?>
<?php
// Register hooks
add_action('admin_print_scripts', 'add_script');
add_action('admin_head', 'add_script_config');
/**
* Add script to admin page
@rtanglao
rtanglao / getGastownPhotos.rb
Created September 9, 2010 04:02
get Roland's Gastown's photos
#!/usr/bin/env ruby
require 'json'
require 'net/http'
require 'pp'
require 'Time'
require 'uri'
require 'parseconfig'
flickr_config = ParseConfig.new('flickr.conf').params
api_key = flickr_config['api_key']
@magnetikonline
magnetikonline / README.md
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.

@b4oshany
b4oshany / discourse-api.php
Created October 8, 2020 10:28
Discourse API - Generate new topics, posts and PM
<?php
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"]) : '';
<?php
/*
Plugin Name: UTF8mb4-convert
Version: 1.0
*/
function update_db_to_utf8mb4() {
if ( ! isset( $_GET['update-utf8bm4'] ) ) {
return;
}
@robflaherty
robflaherty / csv-to-json.php
Created September 1, 2011 02:26
Convert CSV to JSON
<?php
/*
* Converts CSV to JSON
* Example uses Google Spreadsheet CSV feed
* csvToArray function I think I found on php.net
*/
header('Content-type: application/json');
// Set your CSV feed