Skip to content

Instantly share code, notes, and snippets.

View carltondickson's full-sized avatar
🏠
Working from home

Carlton carltondickson

🏠
Working from home
  • Carlton Dickson Development Ltd.
  • London
View GitHub Profile
@carltondickson
carltondickson / gist:3f0dc856eebc7a76a8d3
Created January 19, 2015 16:59
git diff between two commits in same file
# https://stackoverflow.com/questions/3338126/git-how-to-diff-the-same-file-between-two-different-commits-on-the-same-branch/3338145#3338145
git diff old_commit_id..now_commit_id file.php
# Head request and show headers only
curl -I www.acooke.org
curl --head www.acooke.org
@carltondickson
carltondickson / gist:aa923e1c07f6023805f7
Created February 18, 2015 10:14
Doctrine - Reverse engineer single table
/** @var \Doctrine\DBAL\Connection $connection */
$config = $connection->getConfiguration();
// for excluding an specific table
$config->setFilterSchemaAssetsExpression('/^(?!table_name_to_exclude).*$/');
When we try to generate Entities from database, with:
$config->setFilterSchemaAssetsExpression('/^(recipes|ingredients).*$/');
# Source: https://coderwall.com/p/jofhdw/doctrine-tell-which-tables-to-work-with
@carltondickson
carltondickson / gist:dd291d5897d770c554c7
Last active August 29, 2015 14:15
Log MySQL output to file without restart - FILE and TABLE approach
# http://stackoverflow.com/a/20485975/682754
# Log to file
#### Turn on and configure
SET global log_output = 'FILE';
SET global general_log_file='/tmp/mysql_general.log';
SET global general_log = 1;
#### Turn off
@carltondickson
carltondickson / gist:c4be6fe89197cc2c8c86
Created March 13, 2015 11:39
Turn on xdebug via the CLI
# Assuming the following xdebug.ini is used
zend_extension=xdebug.so
xdebug.default_enable=0
xdebug.idekey="PHPSTORM"
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_autostart=0
xdebug.remote_port=9000
@carltondickson
carltondickson / gist:9b863ba52e12e49ca1ac
Created March 13, 2015 13:12
Shows commits only on current branch
# http://stackoverflow.com/questions/4649356/how-do-i-run-git-log-to-see-changes-only-for-a-specific-branch
git cherry -v master
# or
git log master..
@carltondickson
carltondickson / gist:9dfeb4c81d77a6cdf2a2
Created March 31, 2015 09:33
MySQL - Drop INDEX or COLUMN with IF EXISTS check first
# DROP INDEX
SELECT IF (
EXISTS(
SELECT * FROM INFORMATION_SCHEMA.statistics
WHERE table_schema = DATABASE() AND TABLE_NAME = '<table_name>' AND index_name LIKE '<index_name>'
)
,'ALTER TABLE `<table_name>` DROP INDEX `<index_name>`'
,'select "index <index_name> does not exist";') INTO @a;
PREPARE stmt1 FROM @a;
EXECUTE stmt1;
@carltondickson
carltondickson / gist:ddae15ce1bab5410695c
Last active August 29, 2015 14:19
Handlebarjs debug helper
Handlebars.registerHelper("debug", function(optionalValue) {
console.log("Current Context");
console.log("====================");
console.log(this);
if (optionalValue) {
console.log("Value");
console.log("====================");
console.log(optionalValue);
}
# Use public IP as per EC2 dashboard
ssh ubuntu@54.x.x.x -i ~/.ssh/some_key.pem
@carltondickson
carltondickson / gist:a3267b1c31694b5992e2
Created April 22, 2015 15:10
AWS EC/SCP - Copy local files to remote
# from -> to
# Copy to home directory as if web root isn't owned by the "ubuntu" user will get permission denied
scp -r -i ~/.ssh/adapt_framework_test.pem /home/carlton/Desktop/work ubuntu@54.x.x.x:/home/ubuntu/
# Move files from home to web root
mv /home/ubuntu/ /var/www/html
# May have to set permissions on relocated files so the web server can serve them