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
#!/bin/bash
# This file is managed by vagrant, do not modify manually
# To override, on the host copy default/files/usr/local/bin/migrateDb
# to local/files/usr/local/bin/migrateDb
# and reprovision
DATABASE_URL=${DATABASE_URL:-mysql://user:pass@host/db}
if [[ "$DATABASE_URL" =~ ^([^:]+)://([^:]+):([^@]*)@([^/]+)/(.*)$ ]]; then
DATABASE_SCHEME=${BASH_REMATCH[1]}
DATABASE_USER=${BASH_REMATCH[2]}

Keybase proof

I hereby claim:

  • I am AD7six on github.
  • I am ad7six (https://keybase.io/ad7six) on keybase.
  • I have a public key whose fingerprint is 4994 615D FE59 DDAC 8D4E F0AB C001 2651 63E9 C1C4

To claim this, I am signing this object:

@AD7six
AD7six / tree.diff
Created August 11, 2015 07:11
tree.diff
www-data @ dev [ /home/andy/repos/cakephp/cakephp ] (master *$%=)
-> git diff
diff --git tests/TestCase/ORM/Behavior/TreeBehaviorTest.php tests/TestCase/ORM/Behavior/TreeBehaviorTe
index 42a0bad..0955c25 100644
--- tests/TestCase/ORM/Behavior/TreeBehaviorTest.php
+++ tests/TestCase/ORM/Behavior/TreeBehaviorTest.php
@@ -51,6 +51,23 @@ class TreeBehaviorTest extends TestCase
TableRegistry::clear();
}
@AD7six
AD7six / example.php
Last active August 29, 2015 14:24
A simple presenter example based on CakePHP 2 code
<?php
class Dummy extends Model {
public function price() {
return (float)1,234.56; // db stored value
}
}
class DummyPresenter {
@AD7six
AD7six / awful.php
Last active August 29, 2015 14:17
Nest less and use more functions.
public function syncProducts() {
$db = JFactory::getDbo();
JLog::addLogger(
array(
'text_file' => 'com_example_product.syncerrors.' . date('d-m-Y') . '.php'
), JLog::ALL, array('com_example_product')
);
// get products that need to be added
// UPDATED 1 feb 2015. No more Join, no more upper price limit. We are going all in @ IceCat
@AD7six
AD7six / gist:0afcf0f206b13a877fab
Last active August 29, 2015 14:16
Run phinx migrations in a loop until they pass. This is useful if the phinx log is not in sync with the schema, which can happen through error or e.g. by taking a bare schema from one environment (without data) and importing it to another and then running migratiions.
#!/bin/bash
re="[0-9]{14}" # migration ids are the datetime as a 14 digit number - find them
env=${1-development}
db="app"
if [[ $env != 'development' ]]; then
db="app_test"
fi
root@h5bp:~# cat /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
ServerName www.example.com
ServerAlias *.example.*
DocumentRoot /var/www/html5-boilerplate/fixtures/
ErrorLog ${APACHE_LOG_DIR}/example-error.log
CustomLog ${APACHE_LOG_DIR}/example-access.log combined
# Send the output of these commands to me
MAILTO=me@example.com
0 0 * * * /usr/local/bin/giveMeStats
0 4 * * * /usr/local/bin/giveMeMoreStats
# Send the output of these commands to you
MAILTO=you@example.com
0 0 * * * /usr/local/bin/boringStuff
-> cd example/
www-data @ dev [ /tmp/example ]
-> echo "some stuff" > somefile
www-data @ dev [ /tmp/example ]
-> git init
Initialized empty Git repository in /tmp/example/.git/
www-data @ dev [ /tmp/example ] (master #%)
-> git add somefile
www-data @ dev [ /tmp/example ] (master #)
-> echo "somefile" > .gitignore
@AD7six
AD7six / purgePath
Created January 7, 2015 10:55
Script to ensure a folder used for caching always has x% free space. Generated with new_script http://linuxcommand.org/script_library.php
#!/bin/bash
################################################################################
#
# Delete least used files
#
################################################################################
PROGNAME=${0##*/}
PROGDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
VERSION="0.1"