Skip to content

Instantly share code, notes, and snippets.

View AD7six's full-sized avatar
:shipit:
Busy shippin'

Andy Dawson AD7six

:shipit:
Busy shippin'
View GitHub Profile
<?php
// In a model, far far away.... there was some DRY action
function doesComplexWork($id, $conditions) {
return "Complex shenanigans";
}
function doesMoreComplexWork($id) {
return "More Complex shenanigans";
}
# NOTE
# .htaccess files are an overhead, this logic should be in your webserver config if poss
# Changing webserver (lighttpd, nginx) will probably improve site response times more than these tweaks
# Here goes any other rules you, your framework, or whatever app you're using needs
FileETag All
# if it's not a php file (and it's a real file, in the webroot)
<FilesMatch "\.(?!php).*$">
@AD7six
AD7six / .htaccess
Created October 16, 2010 18:48
A simple means of generating a local mirror of another website as you use it.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
@AD7six
AD7six / cleanurl-v7.lua
Created January 20, 2011 11:49
cleanurl-v7.lua - file checking a webroot html cache path too.
function check_path(path)
local rv = path
if (not file_info(path, "is_file")) then
rv = nil
local html_file = path .. ".html"
if (file_info(html_file, "is_file")) then
rv = html_file
else
-- handle directory indeces
-- we first check if we have a dir and than look for an index.html
@AD7six
AD7six / pablo.php
Created January 21, 2011 17:50
standalone i18n slug function
<?php
function cleanstring($input = '', $seperator = '-') {
$pattern = '\x00-\x1f\x26\x3c\x7f-\x9f\x{d800}-\x{dfff}\x{fffe}-\x{ffff}';
$pattern .= preg_quote(' \'"/?!<>.$/:;?@=+&%\#', '@');
$return = preg_replace('@[' . $pattern . ']@Su', $seperator, $input);
return trim(mb_strtolower(preg_replace('/' . $seperator. '+/', $seperator, $return), 'UTF-8'), $seperator);
}
#!/usr/bin/php
<?php
if (!defined('TMP')) {
define('TMP', getcwd() . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR);
}
$file = getcwd() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'database.php';
if (!is_readable($file)) {
echo "Can't find database config at : $file\n";
die(1);
<?php
/**
* This script will attempt to sycronize table structures in a multisite wordpress install
*
* Crete a backup before running this script
*/
$host = $dbname = $username = $password = '';
require 'connection_settings.php';
$prefix = substr(basename(__FILE__), 0, -4);
@AD7six
AD7six / example.vim
Created March 16, 2011 09:53
an example taken directly from vim help
:let len = strlen(substitute(str, ".", "x", "g"))
:let foo = "a string"
@AD7six
AD7six / nginx.conf
Created March 16, 2011 12:36
Local development nginx config
# Set another default user than root for security reasons
# local development - use yourself
user andy wheel;
# As a thumb rule: One per CPU. If you are serving a large amount
# of static files, which requires blocking disk reads, you may want
# to increase this from the number of cpu_cores available on your
# system.
#
# The maximum number of connections for Nginx is calculated by:
[18:11][andy@work:~/www/apps/skel(master)]$ cake mi_db backup
Welcome to CakePHP v1.3.8 Console
---------------------------------------------------------------
App : skel
Path: /home/andy/www/apps/skel
---------------------------------------------------------------
Running backup
generating /home/andy/www/apps/skel/config/schema/backups/default_110726-1810.sql
[18:11][andy@work:~/www/apps/skel(master)]$