Skip to content

Instantly share code, notes, and snippets.

View davejtoews's full-sized avatar

David Toews davejtoews

View GitHub Profile
<?php
namespace Nightjar\SS4UpgradeTasks;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Psr\Log\LoggerInterface;
use SilverStripe\Assets\File;
use SilverStripe\Control\Director;
use SilverStripe\Core\ClassInfo;
@ghalusa
ghalusa / youtube_id_regex.php
Created June 20, 2015 23:14
Extract the YouTube Video ID from a URL in PHP
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
@badfeather
badfeather / sunrise.php
Last active June 8, 2021 18:58
Allow nested folder paths in WordPress Multisite with subdirectories
<?php
/**
* Allow nested folder paths in WordPress Multisite with subdirectories
* Updated from http://maisonbisson.com/post/14052/wordpress-hacks-nested-paths-for-wpmu-blogs/ to account for latest WordPress code
* .htaccess rules also need to be changed to:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"