Skip to content

Instantly share code, notes, and snippets.

View psaunders88's full-sized avatar

Paul Saunders psaunders88

  • Livepoint UK
  • Liverpool, UK
View GitHub Profile
@psaunders88
psaunders88 / wordpress.htacess
Last active September 28, 2016 08:28
wordpress htaccess with extra
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
# Added to stop us serving content to internal dummy connections
RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
RewriteRule .* - [F,L]
#End of added
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
@psaunders88
psaunders88 / .htacess
Created April 12, 2016 13:54
A reminder of how I stopped someone trying to brute force a client site
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
# Added to stop us serving content to internal dummy connections
RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
RewriteRule .* - [F,L]
#End of added
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
#!/bin/bash
cd /var/www/
PROJECT_DIR_NAME="DiTest"
TIME="`date +%Y%m%d%H%M%S`"
# save copy of old file somewhere
cp -R $PROJECT_DIR_NAME backups/$PROJECT_DIR_NAME-$TIME
@psaunders88
psaunders88 / gist:2b653d8d6abc28fd59f7
Created July 15, 2015 09:13
Doctrine2 QB workaround for indexBy
// I want to modify the DQL include the 'index by'
// Reason: Often I find the indexBy function in the query builder frustrating
$qb = $qb->getQuery()->setDQL(
str_replace(
'WHERE',
'INDEX BY s.id WHERE', $qb->getDQL()
)
);
@psaunders88
psaunders88 / cli-git-branch-highlight
Last active February 15, 2016 16:48
Shows branch name on command line
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOR="\[\033[0m\]"
PS1="$GREEN\u@\h$NO_COLOR:\w$YELLOW\$(parse_git_branch)$NO_COLOR\$ "
@psaunders88
psaunders88 / DoctrineDQLExample
Last active December 31, 2015 05:49
A simple example of a function that gathers data from a doctrine and makes use of the join. Nothing special just good for reference
/**
* Function to select particpants by their particiation
*
* @param integer $statusId Status id of partipation
* @param integer $value Value for query
* @param string $operator Operator for claus opions: moreThan, lessThan, atLeast, equals
*
* @return array
*/
public function selectUsersByParticipation($statusId, $value, $operator)
@psaunders88
psaunders88 / add_date_filter_clause.php
Created November 8, 2013 18:03
A function to add date clauses Zend_Db_Select filtering by day/month/year
/**
* Add clauses for date values chosen to select
*
* @param Zend_Db_Select $oSelect
* @param integer $day
* @param integer $month
* @param integer $year
*
* @return Zend_Db_Select
*/