Skip to content

Instantly share code, notes, and snippets.

View kfriend's full-sized avatar

Kevin Friend kfriend

  • 742 Evergreen Terrace
View GitHub Profile
@kfriend
kfriend / gist:6ac6b0d54bdfc5c7544304945ce004a0
Created September 13, 2017 20:17
Windows: Proxy Windows VM HTTP traffic to host machine
netsh interface portproxy add v4tov4 listenport=80 connectport=80 connectaddress=[HOST MACHINE IP]
@kfriend
kfriend / gist:38d93627f3d1c4fb99b21d03aeb115e5
Created July 27, 2017 18:35
Example ExpressionEngine to Wordpress Import Format
<?php $authors = array() ?>
<?= '<?' ?>xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:excerpt="http://wordpress.org/export/1.0/excerpt/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/1.0/"
>
<channel>
@kfriend
kfriend / gist:bf9a014818f3a4fd903ad1d44ceb5212
Created March 22, 2017 01:43
644 and 755 files and directories
# Source: http://stackoverflow.com/a/37287625/419673
chmod -R 644 dirName
chmod -R +X dirName
@kfriend
kfriend / wordpress_key_gen.sh
Created July 28, 2016 13:14
Generate PHP Dotenv vars for Wordpress's hashes and keys
php -r 'eval(file_get_contents("https://api.wordpress.org/secret-key/1.1/salt/"));foreach(explode(" ","AUTH_KEY AUTH_SALT LOGGED_IN_KEY LOGGED_IN_SALT NONCE_KEY NONCE_SALT SECURE_AUTH_KEY SECURE_AUTH_SALT")as$n){echo "WP_{$n} = '\''".constant($n)."'\''".PHP_EOL;}'
@kfriend
kfriend / respond_and_process.php
Created March 11, 2016 01:35
PHP: Send response and continue processing
<?php
// Buffer all upcoming output...
ob_start();
// Send your response.
echo "Testing response";
// Get the size of the output.
$size = ob_get_length();
@kfriend
kfriend / get_unique_tags.php
Created March 9, 2016 04:15
Quick and dirty way to get all HTML/XML tags in a string
<?php
function get_unique_tags($data) {
preg_match_all('/<([^>]+)>/i', $data, $matches);
$matches = $matches[1];
foreach ($matches as $i => $match) {
$matches[$i] = trim($match, '/');
}
@kfriend
kfriend / gist:0c81cd0b0bcd5dec2b9f
Created December 14, 2015 04:42
OS X: Create El Capitan ISO compatible with VirtualBox
#!/usr/bin/env bash
# All credit goes to http://apple.stackexchange.com/a/211722, and thanks to Jesse Web
# for posting the article at http://apple.stackexchange.com/questions/198737/install-el-capitan-in-virtual-box-for-testing-purposes
hdiutil attach "/Applications/Install OS X El Capitan.app/Contents/SharedSupport/InstallESD.dmg" -noverify -nobrowse -mountpoint /Volumes/esd
hdiutil create -o elcapitan.cdr -size 7316m -layout SPUD -fs HFS+J
hdiutil attach elcapitan.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/iso
asr restore -source /Volumes/esd/BaseSystem.dmg -target /Volumes/iso -noprompt -noverify -erase
rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
@kfriend
kfriend / helpers.php
Created August 16, 2015 15:01
PHP Helper Functions
<?php
// =============================================================================
// Array helpers
// =============================================================================
/**
* Array splice, associatively
*
* Splices a value into an array by targeting a key, instead of an offset.
@kfriend
kfriend / gist:1c05ce5d82cb222cc0d9
Last active August 29, 2015 14:24
Remove .svn directories
find . -type d -name .svn -exec rm -rf {} \;
@kfriend
kfriend / gist:af101ac05651cefac3f0
Created April 8, 2015 22:19
Apache: Redirect missing WP uploads to production server (via .htaccess)
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/wp-content/uploads/.*
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) http://www.production.com/$1 [R=301,L]