Skip to content

Instantly share code, notes, and snippets.

View jeremysells's full-sized avatar

Jeremy Sells jeremysells

View GitHub Profile
@jeremysells
jeremysells / xdebug.ini
Created October 19, 2015 22:40
local xdebug settings
zend_extension=xdebug.so
xdebug.remote_host=127.0.0.1
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.idekey=netbeans-xdebug
xdebug.remote_autostart=1
@jeremysells
jeremysells / DeclarationShouldBeCompatibleWithBase.php
Created November 9, 2015 22:50
Declaration should be compatible with Base
<?php
class ModelA{
public function sayHi() { return "hi"; }
}
class ModelB extends ModelA {
public function sayHi() { return "hello"; }
}
class SomethingA{
@jeremysells
jeremysells / ShowingHtmlEscape.php
Last active February 29, 2016 21:16
Showing html escape
<?php
$value = "some\"string'™";
?>
<form name="test" action="<?php echo time(); ?>" method="POST">
<input type="text" value="<?php echo htmlentities($value, ENT_QUOTES, 'UTF-8'); ?>" name="test">
<input type="submit" value="go" name="go" />
</form>
<br/>
<br/>
@jeremysells
jeremysells / vhost disable caching.conf
Created March 7, 2016 01:02
vhost disable caching.conf
vhost disable asset cacheing
<Directory .../public_html>
#disable caching
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</Directory>
@jeremysells
jeremysells / php_dev_machine.sh
Last active April 5, 2016 22:11
php_dev_machine.sh
sudo apt-get install \
gparted \
gedit \
apache2 \
libapache2-mpm-itk \
php5 \
php5-xdebug \
php5-xsl \
php5-mcrypt \
php5-curl \
@jeremysells
jeremysells / netbeans_phpcs_xml.php
Last active July 27, 2018 17:45
Netbeans PHP QA tweaks
#!/bin/bash
# This script makes Netbeans use a custom phpcs.xml (PHP Codesniffer)
# Note: git dir does not work (NB runs out of the git dir)
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# When asked for the standards, return them
# note: The last file is our standard!
if [ $1 = '-i' ]; then
@jeremysells
jeremysells / objects pass by reference examples.php
Last active March 2, 2017 11:18
objects pass by reference examples.php
<?php
//---TEST1----------------------------------------------------
function objectTest(stdClass $input) {
$input->name = "Sally";
}
$object = new stdClass;
$object->name = "Bob";
$object->address = "1 Test Street";
objectTest($object);
echo $object->name; //Sally
@jeremysells
jeremysells / reverse engineer tables.sql
Last active June 27, 2017 21:52
reverse engineer tables.sql
--Useful queries for database(s) with no documentation
--Note: Phpmyadmin, database() will not work and this needs to be a param
SET @inspect_table = 'change_me';
SET @database = database();
--SELECT ALL
SET @s = CONCAT('select * from ', @inspect_table);
PREPARE stmt1 FROM @s;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;
@jeremysells
jeremysells / interpolation_vs_concatination.php
Last active May 9, 2017 23:41
interpolation_vs_concatenation.php
<?php
//This is not just about performance, but also readability!
//But if you can get a win win, why not!
//Please read https://nikic.github.io/2012/01/09/Disproving-the-Single-Quotes-Performance-Myth.html
$varA = "Some really long string here dasdlasmd;mas;lemas;lem;lasmel;asme";
$varB = "Some other string here";
//Test 1
@jeremysells
jeremysells / permissions-cheat-sheet.sh
Last active September 1, 2017 20:24
permissions cheat sheet.sh
---x------ 1 nobody nogroup 0 Sep 1 20:34 100
--w------- 1 nobody nogroup 0 Sep 1 20:34 200
--wx------ 1 nobody nogroup 0 Sep 1 20:34 300
-r-------- 1 nobody nogroup 0 Sep 1 20:34 400
-r-x------ 1 nobody nogroup 0 Sep 1 20:34 500
-rw------- 1 nobody nogroup 0 Sep 1 20:34 600
-rwx------ 1 nobody nogroup 0 Sep 1 20:34 700