Skip to content

Instantly share code, notes, and snippets.

Zhia Chong zhiachong

View GitHub Profile
View boxfile
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
View custom.sh
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 Jan 8, 2016
How to decouple GeoTargetWrapper from this function?
View geotargeting.php
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.");
View osx-for-hackers.sh
#!/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 Aug 29, 2015
Adding two numbers w/o arithmetic operator
View add.php
// 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;
You can’t perform that action at this time.