Skip to content

Instantly share code, notes, and snippets.

View jmillerdesign's full-sized avatar

J. Miller jmillerdesign

View GitHub Profile
@jmillerdesign
jmillerdesign / gist:4283199
Created December 14, 2012 06:38
Slugify a string
/**
* Convert a human-readable string into a slug
*
* 'Sample input string!' gets converted to 'sample-input-string'
*
* @param {string} string Source string
* @param {integer} maxLength Maximum length of slug (defaults to 100)
* @return {string} Slug
*/
var convertToSlug = function (string, maxLength) {
@jmillerdesign
jmillerdesign / gist:1610602
Created January 14, 2012 07:24
Output a standardized JSON response for an API call
<?php
/**
* Output a JSON response for an API call
*
* @param array $data Data to return
* @param boolean|string $status Status type
* Available status types:
* - true (outputs 'ok')
* - false (outputs 'error')
@jmillerdesign
jmillerdesign / gist:1604737
Last active March 31, 2019 03:53
Google Maps Geolocation
<?php
/**
* GoogleGeo
*
* Google maps geolocation, to find coordinates of a location
* @author J. Miller
*/
class GoogleGeo {
// GoogleMaps API Key
@jmillerdesign
jmillerdesign / gist:1553772
Last active August 11, 2023 23:00
Get YouTube video ID from URL
<?php
/*
Works for the following inputs and more:
dQw4w9WgXcQ
http://www.youtube.com/?v=dQw4w9WgXcQ
http://www.youtube.com/embed/dQw4w9WgXcQ
http://www.youtube.com/username#p/c/5555550123/0/dQw4w9WgXcQ
http://www.youtube.com/v/dQw4w9WgXcQ
http://www.youtube.com/v/dQw4w9WgXcQ?feature=autoshare&version=3&autohide=1&autoplay=1
http://www.youtube.com/watch?v=dQw4w9WgXcQ&hd=1&t=26s