Skip to content

Instantly share code, notes, and snippets.

View jamesmoey's full-sized avatar

James Moey jamesmoey

  • Sydney Australia
View GitHub Profile
@jamesmoey
jamesmoey / EasyDateColumn.js
Last active December 18, 2015 03:29
Ext grid date column with date formatting for human.
/**
* Ext grid column for formatting date that is human friendly.
*/
Ext.define('Ms.EasyDateColumn', {
extend: 'Ext.grid.column.Column',
alias: ['widget.easydatecolumn'],
requires: ['Ext.Date'],
/**
* @cfg {String} recentFormat
@jamesmoey
jamesmoey / compilePhp.sh
Last active December 18, 2015 11:59
Compile PHP from source code, install common pecl and pear component
yum install -y libicu-devel gmp-devel libpng-devel libjpeg-devel curl-devel libxml2-devel libmcrypt-devel ImageMagick-devel libtool-ltdl-devel libzip-devel openssl-devel
PREFIX=/opt/php-5.4; (./configure --prefix=$PREFIX --with-config-file-scan-dir=$PREFIX/etc/conf.d --with-config-file-path=$PREFIX/etc --enable-bcmath --with-curl --enable-debug --enable-zip --with-pdo-mysql=mysqlnd --with-mysql=mysqlnd --with-freetype-dir=/usr/include/freetype2/freetype --with-mysqli=mysqlnd --with-mcrypt --enable-mbstring --enable-intl --with-gd --enable-fpm --with-gmp --enable-soap --enable-sockets --with-openssl --with-zip --with-zlib --enable-pcntl --with-bz2 --enable-ftp --enable-gd-native-ttf && nice make && make install) | tee build.log
./pecl channel-update pecl.php.net
./pecl install mongo xdebug memcache apc imagick amqp gnupg ssh2
./pear clear-cache
./pear config-set auto_discover 1
@jamesmoey
jamesmoey / menu.js
Last active December 20, 2015 03:49
(function() {
var menuLevel = 0;
var module = angular.module("merp.base.menu", ['ui.bootstrap']);
module.directive('menubar', ['$location', function($location) {
return {
restrict: 'E',
scope: {},
transclude: true,
replace: false,
template: '<div class="navbar"><div class="navbar-inner" ng-transclude></div></div>',
@jamesmoey
jamesmoey / ExtendedArrayCollection.php
Last active July 24, 2023 07:02
Extend array collection from Doctrine with operation to perform on all the item in the collection.
<?php
namespace Collections;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\PropertyAccess\PropertyAccess;
class ExtendedArrayCollection extends ArrayCollection
{
/**
@jamesmoey
jamesmoey / nginx_php5
Created August 1, 2014 23:56
Setup Nginx and PHP5 manifest
service { "php5-fpm":
ensure => running,
enable => true,
provider => init
}
service { "nginx":
ensure => running,
enable => true,
provider => init
@jamesmoey
jamesmoey / Docker UI
Last active September 30, 2015 22:35
Systemd Setup for Etcd + SkyDns + Registrator
[Unit]
Description=Docker UI Service
Documentation=https://github.com/crosbymichael/dockerui
After=docker.service
Requires=docker.service
[Service]
ExecStartPre=-/usr/bin/docker pull dockerui/dockerui
ExecStartPre=-/usr/bin/docker rm -f dockerui
ExecStart=/usr/bin/docker run --name dockerui -m 16M -v /var/run/docker.sock:/var/run/docker.sock dockerui/dockerui
@jamesmoey
jamesmoey / dedup-sqs.sh
Created June 26, 2015 01:46
De duplicate message in AWS SQS
declare -A messages;
for i in {1..10000};
do
msg=$(aws --region ap-southeast-2 sqs receive-message \
--queue-url $1 \
--max-number-of-messages 1);
msgMd5=$(echo $msg | jq -r '.Messages[].MD5OfBody');
msgId=$(echo $msg | jq -r '.Messages[].MessageId');
if [ -n "${messages[$msgMd5]}" -a "${messages[$msgMd5]}" != "$msgId" ];
then
@jamesmoey
jamesmoey / rabbitjs.ts
Created March 22, 2016 20:35
Rabbit.js as RxJS Observable in Typescript
/// <reference path="../typings/tsd.d.ts" />
/// <reference path="../node_modules/rx/ts/rx.all.d.ts" />
import * as Rx from 'rx';
import * as rabbit from 'rabbit.js';
export module Messaging {
export enum PubSocketType {
PUBLISH = <any>'PUB',

Keybase proof

                                                                                                                                                                                          I hereby claim:                                                                                                                                                                                                                              
  • I am jamesmoey on github.
  • I am jamesmoey (https://keybase.io/jamesmoey) on keybase.
  • I have a public key ASDeQcViwyv4oVi7sEMxoPhpXzbY6NY2DmEpPSMKq1IbQgo

To claim this, I am signing this object:

{                           
@jamesmoey
jamesmoey / makeMapJsonSafe.go
Last active November 28, 2016 01:18
Go - Convert unsafe map interface into JSON safe
import (
"strconv"
"reflect"
)
func makeMapJsonSafe(unsafe interface{}) (interface{}) {
if unsafe != nil && reflect.TypeOf(unsafe).Kind() == reflect.Map {
if isArray(unsafe.(map[interface{}]interface{})) {
var jsonSafe = make([]interface{}, len(unsafe.(map[interface{}]interface{})))
for key, value := range unsafe.(map[interface{}]interface{}) {