Skip to content

Instantly share code, notes, and snippets.

View dilab's full-sized avatar

Ding dilab

  • Singapore
View GitHub Profile
@dilab
dilab / format_array.hp
Created September 6, 2015 03:36
Convert array to new format, but with the same data
$oldFormat = array(
'male' => 'Male',
'female' => 'Female'
);
$newFormat = array_map(function($value, $label) {
return array(
'label' => $label,
'value' => $value,
);
@dilab
dilab / implode_smart.php
Last active September 6, 2015 03:36
Implode array, but smart enough to filter out empty values.
function implode_filter($glue , $pieces) {
return implode($glue, array_filter($pieces));
}
@dilab
dilab / phing-remote-pull
Created April 10, 2014 07:14
This phing snippet will help you run "git pull" on remote server from your local dev machine
<?xml version="1.0" encoding="UTF-8" ?>
<project name="Awesome Application" default="update">
<target name="update" description="">
<property name="username" value="" />
<property name="hostname" value="" />
<property name="public_path" value="/srv/www/your-app/public_html" />
<exec outputProperty="result"
command="ssh ${username}@${hostname} 'cd ${public_path}; git pull;'" />