Skip to content

Instantly share code, notes, and snippets.

View plasticbrain's full-sized avatar

Mike Everhart plasticbrain

View GitHub Profile
@plasticbrain
plasticbrain / gulpfile.js
Last active February 13, 2024 14:31
gulp.js task to deploy code to remote servers
/*******************************************************************************
* Description:
*
* Gulp file to push changes to remote servers (eg: staging/production)
*
* Usage:
*
* gulp deploy --target
*
* Examples:
@plasticbrain
plasticbrain / gist:3887245
Created October 14, 2012 04:00
PHP: mime types (array format)
<?php
$mime_types = array(
'.3dm' => 'x-world/x-3dmf',
'.3dmf' => 'x-world/x-3dmf',
'.a' => 'application/octet-stream',
'.aab' => 'application/x-authorware-bin',
'.aam' => 'application/x-authorware-map',
'.aas' => 'application/x-authorware-seg',
'.abc' => 'text/vnd.abc',
'.acgi' => 'text/html',
@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);
@plasticbrain
plasticbrain / gist:3863749
Created October 10, 2012 07:34
PHP: (REGEX/preg_match) check for http(s)://
//--------------------------------------------------------------------------
// See if a url contains http:// or https://
//--------------------------------------------------------------------------
if( !preg_match('/http(s?)\:\/\//i', $url) ) {
// URL does NOT contain http:// or https://
}
@plasticbrain
plasticbrain / AWS - EC2 - Change PEM Key
Created April 15, 2015 19:12
AWS - EC2 - Change PEM Key
1. From the AWS EC2 Console go to "Key Pairs" and generate a new key pair (eg: NewKey.pem); Download the generated pem key, and chmod it to 0666
2. Use the new pem key to generate a public key
$ ssh-keygen -y
When prompted, enter the path to NewKey.pem. This will generate NewKey.pub
Tip: Edit NewKey.pub and append the key's name so you can identify it easier in the next steps.
Just append a single space, then a tag/name for the key
@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 / gist:49b07885914129150f16
Last active May 3, 2021 19:28
AWS - EC2 - Assign Multiple IPs to the Same Instance
1. Assign a secondary private ip to the instance
- Select the instance, then choose Actions > Mange Private IP Addresses
- In the Manage Private IP Addresses dialog box, Click "Assign new IP"
- Enter a specific IP address that's within the subnet range for the instance (or just leave the field blank to have it choose one for you)
- (Optional) Select Allow reassignment to allow the secondary private IP address to be reassigned if it is already assigned to another network interface.
- Click Yes, Update, and then click Close.
2. Add the new IP to the instance's network interface.
- SSH into the instance
- $ sudo ip addr add new.ip.address.here/20 dev eth0
@plasticbrain
plasticbrain / aws-instance.php
Created February 5, 2014 04:13
Get Amazon AWS Instance ID (PHP / wget)
<?php
//---------------------------------------------------------------------------------
// You can get the metadata for an AWS instance by loading the following URL
// Note: This URL must be loaded from an AWS instance
//
//---------------------------------------------------------------------------------
// URL:
// http://169.254.169.254/latest/meta-data/instance-id
//
//---------------------------------------------------------------------------------
@plasticbrain
plasticbrain / add_domain.sh
Last active March 12, 2021 07:31
Bash Script to Add a New Domain
#!/bin/sh
################################################################################
# Bash script to add a new domain (Apache2)
# (c) 2014 Mike Everhart | PlasticBrain Media LLC
#
# Prerequisites:
# Create a vhosts "template" in $APACHEDIR/sites-available. The template should
# include placeholders ($TOKEN) that will be replaced with the new domain name.
# See https://gist.github.com/plasticbrain/9620846 for an example template
#
@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/