Skip to content

Instantly share code, notes, and snippets.

@jordanmaslyn
jordanmaslyn / gist:2854905
Created June 1, 2012 20:20 — forked from hmert/slug.php
PHP: Create Slug Function
function create_slug($string){
$string = preg_replace( '/[«»""!?,.!@£$%^&*{};:()]+/', '', $string );
$string = strtolower($string);
$slug=preg_replace('/[^A-Za-z0-9-]+/', '-', $string);
return $slug;
}
@jordanmaslyn
jordanmaslyn / gist:2855137
Created June 1, 2012 21:02
CodeIgniter: New Controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Controllername extends CI_Controller {
public function __construct()
{
parent::__construct();
// Your own constructor code
}
@jordanmaslyn
jordanmaslyn / gist:2861878
Created June 3, 2012 04:25
CodeIgniter: .htaccess file (from CodeIgniter.tv)
<IfModule mod_rewrite.c>
# allow_override On
# mod_rewrite is installed
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_php5.c>
@jordanmaslyn
jordanmaslyn / gist:2861884
Created June 3, 2012 04:28
CodeIgniter: MY_Model
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Model extends CI_Model {
/**
* The database table to use.
* @var string
*/
public $table_name = '';
@jordanmaslyn
jordanmaslyn / toolbox.scss
Last active February 8, 2016 14:47
Handy Sass resources from around the web
/*** From http://hugogiraudel.com/2014/05/19/new-offsets-sass-mixin/ ***/
// ----
// Sass (v3.3.7)
// Compass (v1.0.0.alpha.18)
// ----
// Helper mixin for offset positioning
// About: From http://hugogiraudel.com/2014/05/19/new-offsets-sass-mixin/
// ---
# Shell prompt based on the Solarized Dark theme.
# Screenshot: http://i.imgur.com/EkEtphC.png
# Heavily inspired by @necolas’s prompt: https://github.com/necolas/dotfiles
# iTerm → Profiles → Text → use 13pt Monaco with 1.1 vertical spacing.
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM='gnome-256color';
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM='xterm-256color';
fi;
@jordanmaslyn
jordanmaslyn / nginx.conf
Created November 23, 2015 20:17
Redirect missing assets in local VVV Wordpress to the production installation (place this within the server declaration within the site-specific conf file).
# Directives to send expires headers and turn off 404 error logging.
location ~* \.(js|css|png|jpe?g|gif|ico|svg)$ {
expires 24h;
log_not_found off;
try_files $uri $uri/ @production;
}
location @production {
resolver 8.8.8.8;
proxy_pass http://www.WEBSITEURL.TLD/$uri;
@jordanmaslyn
jordanmaslyn / .htaccess
Created December 23, 2015 22:17
Drop this in an .htaccess in your Wordpress uploads folder. It will check for the upload on your existing site, and if it doesn't find it there, will look for it on your live site.
# /wp-content/uploads/.htaccess
# Attempt to load files from production if they're not in our local version
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) http://www.LIVESITEURL.TLD/wp-content/uploads/$1
</IfModule>
@jordanmaslyn
jordanmaslyn / redirects.php
Last active January 11, 2016 16:23
PHP Redirects to emulate .htaccess redirects on nginx
<?php
// include this file in your root index.php before any Wordpress files start getting pulled in.
// allow us to force garbage collection (for performance)
// commented out for now because it should be enabled by default. Going to test without it first.
// gc_enable(); // PHP >= 5.3.0
// old_path => new_path
// make sure all of your old_paths have no trailing slash
@jordanmaslyn
jordanmaslyn / redirects.csv
Created January 8, 2016 17:11
Redirection CSV template
/culture /about-us/
/culture/team /about-us/team/
/culture/careers /about-us/careers/
/culture/awards /about-us/awards/
/About /about-us/
/about /about-us/