Skip to content

Instantly share code, notes, and snippets.

param1={% for z in groups['zookeeper'] %}{% if loop.index > 1 %}:{% endif %}{{ hostvars[z]['ansible_fqdn'] }}:{{ port }}{% endfor %}
param2=something
param3=something
# {{ansible_managed}}
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
{% for item in groups['all'] %}
{% set ip = next(ip for ip in hostvars[item]['ansible_all_ipv4_addresses'] if ip.find("10.") == 0, hostvars[item]['ansible_default_ipv4']) %}
{% if ip %}
{{ ip }} {{ item }}
{% endif %}
{% endfor %}
irb> RUBY_VERSION
=> "1.9.3"
# it's 1.9.3-p374 if you wanna get picky..
> JSON::VERSION
=> "1.5.4"
# So I have some json, from the body of a RestClient response that looks something like this:
irb> json = "{\"name\":\"Centrale Laiti\\u00e8re\"}"
=> "{\"name\":\"Centrale Laiti\\u00e8re\"}"
@agile
agile / rate.sh
Created November 8, 2012 21:22
Determine modification rate for a file
#!/bin/bash
#
# Hack to extract stats for a file including the actual creation time
#
# Uses debugfs which includes the crtime value in it's output:
#
# Inode: 23072101 Type: regular Mode: 0664 Flags: 0x80000
# Generation: 1861227769 Version: 0x00000000:00000001
# User: 1000 Group: 1000 Size: 0
# File ACL: 0 Directory ACL: 0
@agile
agile / fork.rb
Created October 11, 2011 14:55
Example forking with signal handler and message pipe
#!/usr/bin/env ruby
#
# Forking example using pipes to communicate from child processes
def log(msg)
case msg
when Array then msg.each {|m| log(" #{m}") }
else
puts "[#{Time.now}][#{$$}] #{msg}"
end
@agile
agile / remote.rb
Created May 31, 2011 14:41
Make capistrano's scm_run limit the number of hosts
# re: capistrano-2.6.0/lib/capistrano/recipes/deploy/strategy/remote.rb
require 'capistrano/recipes/deploy/strategy/base'
module Capistrano
module Deploy
module Strategy
# An abstract superclass, which forms the base for all deployment
# strategies which work by grabbing the code from the repository directly
# from remote host. This includes deploying by checkout (the default),
@agile
agile / InsertTabComplete.vim
Created January 4, 2011 16:07
drop this in ~/.vim/plugins and you can complete in insert mode using the tab key
function InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
@agile
agile / tcp_syslog.rb
Created November 2, 2010 21:16 — forked from gravis/readme
require 'socket'
require 'syslog'
require 'logger'
require 'hoptoad_notifier'
# TcpSyslog is used are a dead-simple replacement for
# syslog ruby libs. None of them is able to send logs
# to a remote server, and even less in TCP.
#
# Example:
@agile
agile / compact_progress_bar_formatter.rb
Created September 17, 2010 13:44
Nice progress bar and immediate feedback for failures, pending and slow specs
# Copyright (c) 2008 Nicholas A. Evans
# http://ekenosen.net/nick/devblog/2008/12/better-progress-bar-for-rspec/
#
# With some tweaks (slow spec profiler, growl support)
# By Nick Zadrozny
# http://gist.github.com/71340
#
# Further tweaks (formatador, elapsed time instead of eta)
# By geemus (Wesley Beary)
# http://gist.github.com/266222
# Copyright (c) 2008 Nicholas A. Evans
# http://ekenosen.net/nick/devblog/2008/12/better-progress-bar-for-rspec/
#
# With some tweaks (slow spec profiler, growl support)
# By Nick Zadrozny
# http://gist.github.com/71340
#
# Further tweaks (formatador, elapsed time instead of eta)
# By geemus (Wesley Beary)
# http://gist.github.com/266222