Skip to content

Instantly share code, notes, and snippets.

View plasticbrain's full-sized avatar

Mike Everhart plasticbrain

View GitHub Profile
@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 / 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-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 / 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 / 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 / gist:6582104
Created September 16, 2013 15:22
Update Gnome Terminal Window Title on Login
Edit your .bashrc file:
$ nano ~/.bashrc
Add the following line, changing "New Title" to whatever you want
PROMPT_COMMAND='echo -ne "\033]0;New Title\007"'
NOTE: In some cases, when you switch to root or a different user, the window title may change back. If this is the case, simply add the previous line to /etc/.bashrc
@plasticbrain
plasticbrain / gist:7145317
Last active December 26, 2015 11:39
Handy Linux Commands
Get just the IP of a hostname
  • dig +short A <hostname>
Find the 10 largest files on the disk
  • du -a / | sort -n -r | head -n 10
Find/Replace text in files
  • sed -i 's/old-word/new-word/g' *.txt
@plasticbrain
plasticbrain / geoip-apache-module
Created November 8, 2013 20:54
Install MaxMind's GeoIP modules for Apache (on Ubuntu)
I. Prerequisites
$ apt-get install apache2-prefork-dev
$ apt-get install apache2-threaded-dev
$ apt-get install libgeoip-dev
1. Download and install mod_geoip2
http://www.maxmind.com/download/geoip/api/mod_geoip2/mod_geoip2-latest.tar.gz
@plasticbrain
plasticbrain / xfterm-solarized-theme
Created December 28, 2013 06:09
Xubuntu solarized color theme. Paste the following in /etc/xdg/xdg-xubuntu/Terminal/terminalrc
[Configuration]
FontName=Droid Sans Mono 10
ColorCursor=#0f0f49499999
ColorForeground=#838394949696
ColorBackground=#00002b2b3636
ColorPalette1=#070736364242
ColorPalette2=#dcdc32322f2f
ColorPalette3=#858599990000
ColorPalette4=#b5b589890000
ColorPalette5=#26268b8bd2d2
@plasticbrain
plasticbrain / cgminer.com
Created January 20, 2014 22:25
cgminer.conf - 2x Gigabyte R9 290x
{
"pools" : [
{
"url" : "",
"user" : "",
"pass" : ""
},
{
"url" : "",
"user" : "",