Skip to content

Instantly share code, notes, and snippets.

View josephspurrier's full-sized avatar

Joseph Spurrier josephspurrier

View GitHub Profile
@josephspurrier
josephspurrier / color.php
Last active August 29, 2015 13:55
CSS Style Selectors for Color
<!DOCTYPE HTML>
<html>
<style>
* {
color: white;
}
p {
color: green;
}
@josephspurrier
josephspurrier / .htaccess
Last active August 29, 2015 13:57
Apache root configuration for Trailing Slash Solution - http://josephspurrier.com/trailing-slash-solution/
# Remove Apache variations on URL, best for SEO
Options -MultiViews
<IfModule mod_dir.c>
# Ensure index.php is only allowed as index
DirectoryIndex index.php
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
@josephspurrier
josephspurrier / .htaccess
Last active August 29, 2015 13:57
Apache CheckSpelling for .htaccess
<IfModule mod_speling.c>
CheckSpelling On
CheckCaseOnly On
</IfModule>
@josephspurrier
josephspurrier / .htaccess
Last active August 29, 2015 13:57
Apache sub folder configuration for Trailing Slash Solution - http://josephspurrier.com/trailing-slash-solution/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test/
# Strip main index.php and query string
RewriteCond %{THE_REQUEST} ^GET./+test/+index\.php\?
RewriteRule . /test/? [R=301,NE,L]
# Strip multiple slashes and query string
RewriteCond %{THE_REQUEST} (.*)//(.*)
@josephspurrier
josephspurrier / contentstrip.php
Last active August 29, 2015 13:58
Strip content from between header and footer tags and insert into WordPress database
<?php
function getMiddle($first, $end, $contents, $file)
{
$arrBegin = explode($first, $contents);
if (count($arrBegin) != 2)
{
echo 'Bad Begin: '.$file;
die();
/**
* Get the OS from the HTTP_USER_AGENT string
*
* * @link http://stackoverflow.com/questions/18070154/get-operating-system-info-with-php
*
* @return string
*/
function getOS()
{
$user_agent = (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'NA');
@josephspurrier
josephspurrier / index.php
Last active August 29, 2015 14:02
WordPress Disconnected from Themes
<?php
/**
* Model for interfacing with a Wordpress backend
*
* @author Alex Crooks, Si digital http://sidigital.co
**/
// Just replace your WordPress index.php content with this code to test.
define('APP_PATH', dirname( __FILE__ ));
@josephspurrier
josephspurrier / disable_wordpress_editor_cleanup.php
Last active August 29, 2015 14:04
Disable the WordPress Editor Cleanup
/**
* Disable the Visual and Text Editor p and br tag modifications when saving
*
* When you call the editor, it will automatically add a filter depending
* on which editor you have open:
* * Text Editor: add_filter('the_editor_content', 'wp_htmledit_pre');
* * Visual Editor: add_filter('the_editor_content', 'wp_richedit_pre');
*
* The only way to stop this is to remove the filter because it's applied.
* The next call after is do_action( 'media_buttons', $editor_id );
@josephspurrier
josephspurrier / centerbackground.htm
Last active August 29, 2015 14:04
Center a Background Image on a Webpage
<!DOCTYPE html>
<html lang="en" style="overflow: auto; height: 100%;">
<body style="background: #222222; margin: 0; height: 100%;">
<div style="overflow: hidden; height: 100%;">
<img id="background-image" src="https://www.gstatic.com/chat/hangouts/bg/a432eb7bf6eef1cccf7946ca20e5c2c0-NeilKremer.jpg">
</div>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
@josephspurrier
josephspurrier / primecounter.go
Last active August 29, 2015 14:27
Prime Number Counter in Golang
/*
I was able to achieve these speeds on my laptop: Intel Core i7-4500U @ 1.80GHZ
2015/08/20 09:28:05 Test 1: 664579 took 47.0074ms
2015/08/20 09:28:05 Test 2: 5761455 took 626.9954ms
2015/08/20 09:28:13 Test 3: 50847534 took 8.0860009s
*/
package main
import (