This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* GoogleGeo | |
* | |
* Google maps geolocation, to find coordinates of a location | |
* @author J. Miller | |
*/ | |
class GoogleGeo { | |
// GoogleMaps API Key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Download a remote file to a local file | |
* | |
* @param string $url URL to remote file | |
* @param string $localPathToFile Absolute path to local file where it will be saved | |
* @return boolean True if file saved successfully | |
*/ | |
function downloadFile($url, $localPathToFile) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tar -cf - relative/path/to/dir | gzip -c | ssh user@example.com 'cd ~/path/to/dir; tar xfz -' | |
# If using a fast lan (I have just tested gigabyte ethernet) it is faster to not compress the data so the command would be: | |
# tar -cf - relative/path/to/dir | ssh user@example.com 'cd ~/path/to/dir; tar xf -' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
launchctl unload /System/Library/LaunchAgents/com.apple.soagent.plist && launchctl load /System/Library/LaunchAgents/com.apple.soagent.plist && killall Dock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
App::uses('Model', 'Model'); | |
App::uses('String', 'Utility'); | |
class AppModel extends Model { | |
/** | |
* @author Reed Dadoune | |
* distanceQuery |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Convert any string to an integer between 0-9 | |
* | |
* @param string $str Any string | |
* @return integer Integer between 0-9 | |
*/ | |
function strToInt($str) { | |
preg_match('/\d/', md5((string) $str), $matches, PREG_OFFSET_CAPTURE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .gz | |
mysqldump -h 'db.example.com' -u'username' -p'password' 'database' --single-transaction | gzip -c | cat > 'database_backup_2014-01-01.sql.gz' | |
# .sql | |
mysqldump -h 'db.example.com' -u'username' -p'password' 'database' --single-transaction > 'database_backup_2014-01-01.sql' |
OlderNewer