Skip to content

Instantly share code, notes, and snippets.

View zhiachong's full-sized avatar

Zhia Chong zhiachong

View GitHub Profile
prototype:
api: &api
stack: node # remove this line
test:
npm run-script test-local
daemon: node frozenyak/bin/www
run:
./custom.sh
npm install -g grunt-cli && grunt
env: &env
bash %{
sudo apt-get install nodejs
sudo apt-get install npm
sudo ln -s /usr/bin/nodejs /usr/bin/node #adds a symbolic link because most apps use node instead of nodejs
echo "Installed nodeJS: "
node -v
echo "Installed npm: "
npm -v
@zhiachong
zhiachong / geotargeting.php
Created January 8, 2016 02:42
How to decouple GeoTargetWrapper from this function?
public function getGeotargetingPopulationData($requestBody)
{
return parent::processMessage(
function () use ($requestBody)
{
$this->myPlaceLocal->authorization->validateLoggedInUser();
if (empty($requestBody['geotargeting']) || empty($requestBody['impressions']))
{
throw new InvalidApiParameterException("Expecting geo-targeting and impressions.");
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@zhiachong
zhiachong / add.php
Last active August 29, 2015 14:03
Adding two numbers w/o arithmetic operator
// my initial version
function add($x, $y)
{
$result = 0;
$i = 0; // the first bit to look at
$max = max($x, $y);
$msb = log($max, 2); // get the most signicant bit
$carry = 0;