Skip to content

Instantly share code, notes, and snippets.

View plasticbrain's full-sized avatar

Mike Everhart plasticbrain

View GitHub Profile
@plasticbrain
plasticbrain / gist:6427717
Last active December 22, 2015 05:58 — forked from kbav/gist:4126337
Email Preheader
<style>
/* ... */
/*--- Preheader declaration in style block in addition to inline for Outlook */
.preheader { display:none !important; visibility:hidden; opacity:0; color:transparent; height:0; width:0; }
</style>
</head>
<body>
<!-- PRE-HEADER TEXT -->
<span class="preheader" style="display: none !important; visibility: hidden; opacity: 0; color: transparent; height: 0; width: 0;">Preheader text shows up in GMail, iOS, Mail.app, &amp; more: 75 text char limit</span>
@plasticbrain
plasticbrain / wget-copy-site
Last active December 25, 2020 21:21
Use wget to download an entire site
wget \
-e robots=off \
--referer="http://www.google.com" \
--user-agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6" \
--recursive \
--no-clobber \
--page-requisites \
--convert-links \
--domains website.com \
website.com/
@plasticbrain
plasticbrain / php-send-email.php
Created June 18, 2013 03:03
PHP - Send Email
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";
}
@plasticbrain
plasticbrain / php-generate-uuid.php
Created June 18, 2013 03:02
PHP - Generate UUID
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));
}
@plasticbrain
plasticbrain / PHP - Get months in date range
Created June 6, 2013 18:31
PHP - Get months in date range
function get_months_in_range($start, $end, $format='timestamp', $create_empty_array=false) {
$i = $formatted_i = $start = strtotime($start);
if( $format != 'timestamp' ) $formatted_i = date($format, $i);
$end = strtotime($end);
$dates = $create_empty_array ? array($formatted_i => array()) : array($formatted_i);
while($i < $end) {
$month = $formatted_day = mktime(0, 0, 0, date('m', $i)+1, date('d',$i), date('Y', $i));
if( $format != 'timestamp' ) {
$formatted_month = date($format, $month);
}
@plasticbrain
plasticbrain / MySQL - last accessed tables
Created February 1, 2013 21:55
Get the last accessed tables from database
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;
@plasticbrain
plasticbrain / gist:4151302
Created November 26, 2012 23:15
HTACCESS: Force https
### Force https://
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301]
@plasticbrain
plasticbrain / gist:4151298
Created November 26, 2012 23:15
HTACCESS: Force www
### Force www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) http://www.%{SERVER_NAME}%{REQUEST_URI} [R=301]
@plasticbrain
plasticbrain / sections.css
Created October 31, 2012 00:02
Show/Hide page sections (jQuery, CSS, HTML)
div#page-menu {
float: left;
width: 250px;
margin: 0;
}
div#page-menu ul {
border: 2px solid #ccc;
border-top: none;
padding: 0;
@plasticbrain
plasticbrain / error-reporting.php
Created October 17, 2012 23:20
PHP: Error Reporting
// Report ALL errors, and show them to the user
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Log errors to log file, and do NOT show them to the user
ini_set('log_errors', 1);
ini_set('display_errors', 0);