Skip to content

Instantly share code, notes, and snippets.

var EventEmitter = require('events').EventEmitter;
var _ = require('lodash');
function PastEventEmitter() {
EventEmitter.call(this);
this.past = [];
var old_emit = this.emit;
this.emit = function(event) {
this.past.push(event);
@extraordinaire
extraordinaire / 0-README.md
Last active August 29, 2015 14:04
Ansible play that creates Route53 records based on AutoScaling groups

ASG Route53 Updater

At TVbeat we run this on a cron within each of our cloudformation stacks.

R53 records look like zookeeper-staging.example.com

Requirements

ansible :) & awscli: sudo pip install awscli

EC2 IAM policy:

@extraordinaire
extraordinaire / gist:9807715
Created March 27, 2014 13:37
Ansible remount root with ACL
- name: remount root with acl
when: item.mount == "/" and not item.options|search("acl")
mount:
name=/
fstype=ext4
opts=acl,rw,errors=remount-ro
src=item.device
state=mounted
with_items: ansible_mounts
"msg":{
"incident":{
"incident_id":"f2e08c333dc64cb09f75eaab355393bz",
"resource_name":"webserver-85",
"ended_at":null,
"resource_id":"i-4a266a2d",
"url":"https://app.stackdriver.com/incidents/f2e08c333dc64cb09f75eaab355393bz",
"summary":"CPU (agent) for webserver-85 is above the threshold of 1% with a value of 28.5%",
"state":"open",
"started_at":1385085727
(defn describe-previous-role
[{[_ {role :role}] :employment}]
role)
(describe-previous-role {:name "john"
:employment [{:company "Example"
:role "Engineer"},
{:company "Example"
:role "Engineering Intern"}]})
def provision
resource.catalog.resource('chroot', resource[:chroot].title).provider.source_exec(puppet_apply_cmd)
end
SELECT * FROM `table_name`
ORDER BY ( CASE
WHEN order_column = 2 THEN 0
WHEN order_column = 1 THEN 1
WHEN order_column = 3 THEN 2
END )
<?php
function getHtmlFromDomElement($element) {
$doc = new DOMDocument();
foreach($element->childNodes as $child)
{
$doc->appendChild($doc->importNode($child, true));
}
return $doc->saveHTML();
}
<taskdef name=”ExportProperties” classname=”Path.To.Phing.Task.ExportProperties” />
<ExportProperties targetFile=”phing.properties” />
<?php
require_once "phing/Task.php";
/**
* Saves currently defined properties into a specified file
*
* @author Andrei Serdeliuc
* @extends Task
*/