Skip to content

Instantly share code, notes, and snippets.

View Sitebase's full-sized avatar
🤘

Wim Mostmans Sitebase

🤘
View GitHub Profile
@Sitebase
Sitebase / Procfile
Created November 13, 2012 13:03
PHP Worker file that restarts after crash
worker: while true; do cd /app/www/ && /app/bin/php worker.php; sleep 1; done
@Sitebase
Sitebase / 0-dependencies.sh
Created December 1, 2012 17:42
EC2 Bootstrap LAMP
#!/bin/bash
logger="logger -t bbbx-boot"
install()
{
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y \
-o DPkg::Options::=--force-confdef \
-o DPkg::Options::=--force-confold \
install $@
@Sitebase
Sitebase / gist:4510386
Created January 11, 2013 12:43
Phing list fileset
<fileset id="src.php.custom" dir="${base.dir}src/application/">
<include name="controllers/**/*.php" />
<include name="core/**/*.php" />
<include name="models/**/*.php" />
<include name="modules/**/*.php" />
<include name="helpers/**/*.php" />
<exclude name="**/libraries/**/*.php" />
</fileset>
<target name="fileset-list">
@Sitebase
Sitebase / Unit testing
Last active December 11, 2015 04:48
Requirements for unit testing
## Install ##
* nodejs: http://nodejs.org/download/ (how to guide for win if needed: http://dailyjs.com/2012/05/03/windows-and-node-1/)
* pear
* phpunit:
* pear channel-discover pear.phpunit.de
* pear install phpunit/PHPUnit
* jshint: npm install jshint
## Sublime config ##
https://github.com/Sitebase/sublime-config
@Sitebase
Sitebase / Doctrine.php
Created February 22, 2013 13:48
Custom doctrine type to store uuid's as binary(16) values in a MySQL database. Set the column type that you want to use as BINARY(16) in MySQL and your good to go.
\Doctrine\DBAL\Types\Type::addType('uuid', 'BuboBox\Doctrine2\DBAL\Types\UuidType');
@Sitebase
Sitebase / gist:5134567
Created March 11, 2013 14:20
Use array explode in combination with list and support different number of array items. In this example $params can have one, two or three items. Not set items will be null.
list($field1, $field2, $field3) = array_pad(explode('.', $params, 3), 3, NULL);
@Sitebase
Sitebase / MY_Form_validation.php
Created March 11, 2013 14:47
CodeIgniter unique validator that has support for excluding a specific row.
public function unique($value, $params)
{
$CI =& get_instance();
list($table, $field, $exclude_field, $exclude_value) = array_pad(explode('.', $params, 4), 4, NULL);
$CI->form_validation->set_message('unique', 'The %s that you requested is unavailable.');
$CI->db->select('COUNT(*) AS dupe')->from($table)->where($field, $value)->limit(1);
if($exclude_field AND $exclude_value)
{
@Sitebase
Sitebase / gist:5168380
Created March 15, 2013 08:43
Favelet to generate QR code from the current website URL. This way you can just scan to QR code if you want to test it on your mobile device.
javascript:(function(){var api="http://chart.apis.google.com/chart?cht=qr&chs=200x200&chl=" + encodeURIComponent(document.location.href) + "&chld=H|0";document.write('<img src="' + api + '" width="200" height="200" />');})()
@Sitebase
Sitebase / Makefile
Created March 23, 2013 14:55
Makefile for building flex project
FLEX="/Applications/Adobe Flash Builder 4/sdks/4.0.0"
FLEXBIN=${FLEX}/bin
MXMLC=${FLEXBIN}/mxmlc
OPTIMIZER=${FLEXBIN}/optimizer
debug:
${MXMLC} -debug=true -incremental=true -benchmark=false -static-link-runtime-shared-libraries=true -o bin-debug/WebcamRecorderApp.swf src/WebcamRecorderApp.mxml
final:
${MXMLC} -optimize=true -static-link-runtime-shared-libraries=true -o bin-final/WebcamRecorderApp.tmp.swf src/WebcamRecorderApp.mxml
@Sitebase
Sitebase / gist:5236109
Created March 25, 2013 10:01
Handy RequireJS trick to bust cache when developing
require.config({
urlArgs: "bust=" + (new Date()).getTime()
});