⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
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 | |
$max_upload_in_mb = min((int)(ini_get('upload_max_filesize')), (int)(ini_get('post_max_size')), (int)(ini_get('memory_limit'))); | |
echo $max_upload_in_mb . 'mb'; | |
?> |
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
function current_page($params=NULL, $no_trailing_slash=TRUE) { | |
// http(s)://domain.com | |
$url = @$_SERVER['HTTPS'] == 'on' ? 'https://'. $_SERVER['SERVER_NAME'] : 'http://'.$_SERVER['SERVER_NAME']; | |
// add the port number, if there is one | |
if( @$_SERVER['SERVER_PORT'] != "80" && @$_SERVER['SERVER_PORT'] != "443" ) $url .= ':'. @$_SERVER['SERVER_PORT']; | |
// Append the query string | |
$url .= $_SERVER['REQUEST_URI']; |
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
#! /usr/bin/env ruby | |
# | |
# metrics-curl | |
# | |
# DESCRIPTION: | |
# Simple wrapper around curl for getting timing stats from the various phases | |
# of connecting to an HTTP/HTTPS server. | |
# | |
# OUTPUT: | |
# metric data |
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
### Force www | |
RewriteCond %{HTTP_HOST} !^www\. | |
RewriteRule (.*) http://www.%{SERVER_NAME}%{REQUEST_URI} [R=301] |
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
### Force https:// | |
RewriteCond %{HTTPS} !=on | |
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301] |
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 | |
// Usage | |
$occurrences = next_occurrence('Friday', 13); | |
foreach($occurrences as $day) { | |
echo $day->format('D M j, Y') . PHP_EOL; | |
} | |
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
SELECT table_schema AS DatabaseName, | |
table_name AS TableName, | |
update_time AS LastAccessTime, | |
check_time AS LastCheckTime | |
FROM information_schema.tables | |
WHERE update_time < 'yyyy-mm-dd' | |
GROUP BY table_schema | |
ORDER BY update_time ASC; |
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
function send_email( $to, $from, $subject, $message, $html=true ){ | |
// Set the headers | |
$headers = "From: ".$from."\r\n"; | |
$headers .= "Reply-To: ".$from."\r\n"; | |
if( defined('BCC_CONTACT_EMAIL') ) { | |
$headers .= 'Bcc: ' . BCC_CONTACT_EMAIL . "\r\n"; | |
} | |
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
function uuid() { | |
$data = openssl_random_pseudo_bytes(16); | |
$data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0010 | |
$data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10 | |
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); | |
} |