Skip to content

Instantly share code, notes, and snippets.

View mechastorm's full-sized avatar

Shih Oon Liong mechastorm

View GitHub Profile
@mechastorm
mechastorm / FB Locale List
Created September 4, 2012 21:27
List of locales supported by Facebook. These are the same supported locales that you can only call when loading the FB JS SDK
<?php
/**
* List of locales supported by Facebook.
*
* These are the same supported locales that you can only call when loading the FB JS SDK at
* //connect.facebook.net/{LOCALE_ID}/all.js
*
* Locales taken from http://www.facebook.com/translations/FacebookLocales.xml
*
* Last Updated: 04/09/2012
---
# Attempt to check if the folder exist.
# If it exist echo out a string. You have to echo something
# if the directory does exist or else the task is considered failed
# Output is set to $is_default_created. Note that this variable is
# object and not an atomic value.
- name: Attempt to check if a directory exist
action: shell test -d /my/folder && echo "exist" || echo ""
register: is_folder_created
@mechastorm
mechastorm / install_ansible.sh
Created June 5, 2013 04:08
Bash Shell script to install Ansible via Git
#!/usr/bin/env bash
# Usage Example:
# ./install_ansible.sh 'v1.1' path/to/local/ansible/hosts/file
# Look up https://github.com/ansible/ansible for version tags to use
versionTag=$1
ansibleHosts=$2
# Install Git
@mechastorm
mechastorm / cron_install.xml
Last active December 20, 2015 04:18
Phing task to install Cron Job Config. Must run with sudo
<!--
TargetName: cron:install
Partly based on http://codeinthehole.com/writing/deploying-cron-jobs-using-phing/
@param env.name The env name
@env.config_path Path in project for the env configs
@param project.folder AKA the name of the project
-->
<target name="cron:install" description="Install Cron Job Config. Run with sudo">
<property name="cron_source_path" value="${env.config_path}/system/cron.d" />
@mechastorm
mechastorm / php_lint_hook.yml
Created January 28, 2015 05:11
Pre-commit hook Yaml to run PHP syntax check against staged files before commit.
- id: php-lint
name: PHP Syntax Check (Quick)
description: Runs php -l on all staged files. Exits when it hits the first
errored file
entry: php -l
language: system
files: \.php$
@mechastorm
mechastorm / gist:e1e4867e21987cd78342
Created January 28, 2015 05:13
Example of adding a pre-commit hook to your .pre-commit-config.yml
- repo: http://source/to/your/hook/repo/url
sha: master
hooks:
- id: php-lint
@mechastorm
mechastorm / nginx_view_stage.conf
Created April 25, 2015 02:26
nginx_view_stage
server {
set $rootPath /var/www/vhosts/mysite/public;
listen 80;
server_name assets.mydomain.com;
root $rootPath;
access_log /var/log/nginx/access_assets.log;
@mechastorm
mechastorm / gist:a9547d808c3ca5962bebc7b73f421797
Created May 5, 2017 21:28
Auto tag Owner if tag does not exist
policies:
- name: ec2-auto-tag-owner
mode:
type: cloud-trail
events:
- CreateInstance
filters:
- tag:Owner: absent
actions:
- type: auto-tag-user
(custodian) vagrant@sliong:/workspace/custodian$ custodian validate test.yml
2017-05-05 21:32:41,128: custodian.commands:ERROR Configuration invalid: test.yml
2017-05-05 21:32:41,136: custodian.commands:ERROR {'filters': [{'tag:Owner': 'absent'}], 'name': 'ec2-auto-tag-owner', 'actions': [{'tag': 'OwnerContact', 'type': 'auto-tag-user'}], 'mode': {'type': 'cloud-trail', 'events': ['CreateInstance']}} is not valid under any of the given schemas
Failed validating 'anyOf' in schema['properties']['policies']['items']:
{'anyOf': [{'$ref': '#/definitions/resources/firehose/policy'},
{'$ref': '#/definitions/resources/rds-cluster-snapshot/policy'},
{'$ref': '#/definitions/resources/event-rule/policy'},
{'$ref': '#/definitions/resources/elb/policy'},
{'$ref': '#/definitions/resources/redshift-snapshot/policy'},
@mechastorm
mechastorm / gist:2e379788e5f56239d5f32d9cb98c420a
Created May 5, 2017 21:39
Correct Custodian Policy that validates correctly
policies:
- name: ec2-auto-tag-owner
resource: ec2
mode:
type: cloudtrail
events:
- RunInstances
filters:
- "tag:Owner": absent
actions: