Skip to content

Instantly share code, notes, and snippets.

@talonx
talonx / ec2-ssh.rb
Created January 5, 2012 05:58 — forked from qwzybug/ec2-ssh.rb
SSH into an EC2 instance by name.
#!/usr/bin/env ruby
instance_name = ARGV[0]
abort "Please specify an instance name" unless instance_name and instance_name.length > 0
instance_info, selected_instance = {}, nil
info_keymap = {2 => :ami_id, 3 => :address, 5 => :status, 6 => :keypair_name}
instances = `ec2-describe-instances`.split("\n").map{|l| l.split("\t")}
instances.each do |line|
@talonx
talonx / ideal ops.md
Created August 14, 2012 12:18 — forked from bhenerey/ideal ops.md
ideal ops checklist

In a perfect world, where things are done well, not just quickly, I would expect to find the following when joining the company:

Documentation

  • Accurate / up-to-date systems architecture diagram

  • Accurate / up-to-date network diagram

  • Out-of-hours support plan

  • Incident management plan

@talonx
talonx / gist:dfb6a052b6370be7caa247197516b098
Created May 1, 2016 14:57 — forked from pmahoney/gist:1970815
Jenkins and Java fork()+exec() out of memory

Orien is correct, it is the fork() system call triggered by ProcessBuilder or Runtime.exec or other means of the JVM executing an external process (e.g. another JVM running ant, a git command, etc.).

There have been some posts on the Jenkins mailing lists about this: Cannot run program "git" ... error=12, Cannot allocate memory

There is a nice description of the issue on the SCons dev list: fork()+exec() vs posix_spawn()

There is a long standing JVM bug report with solutions: Use posix_spawn, not fork, on S10 to avoid swap exhaustion. But I'm not sure if this actually made it into JDK7 as the comments suggest was the plan.

In summary, on Unix-like systems, when one process (e.g. the JVM) needs to launch another process (e.g. git) a system call is made to

@talonx
talonx / ansible-conditional-delete.yml
Last active June 19, 2017 19:27 — forked from jgornick/ansible.yml
Ansible: Remove All Files Except
---
- name: Capture files in path and register
shell: >
ls -1 /path/to/files
register: files
- name: Remove files except specified
file:
path: "/path/to/files/{{ item }}"
state: absent
@talonx
talonx / reading-property-from-file.sh
Created September 19, 2017 09:46 — forked from marcelbirkner/reading-property-from-file.sh
Read property from properties file within Shell Script
#!/bin/sh
PROPERTY_FILE=apps.properties
function getProperty {
PROP_KEY=$1
PROP_VALUE=`cat $PROPERTY_FILE | grep "$PROP_KEY" | cut -d'=' -f2`
echo $PROP_VALUE
}
@talonx
talonx / convert.py
Created August 14, 2018 11:30 — forked from rednebmas/convert.py
Convert sqlite3 dump to mysql importable statements
import re, fileinput
print 'SET FOREIGN_KEY_CHECKS=0;'
def main():
for line in fileinput.input():
process = False
for nope in ('BEGIN TRANSACTION','COMMIT',
'sqlite_sequence','CREATE UNIQUE INDEX'):
if nope in line: break
@talonx
talonx / service.yaml
Created December 2, 2019 05:35 — forked from matthewpalmer/service.yaml
overview of kubernetes port definitions
kind: Service
apiVersion: v1
metadata:
name: port-example-svc
spec:
# Make the service externally visible via the node
type: NodePort
ports:
# Which port on the node is the service available through?
@talonx
talonx / Jenkinsfile.groovy
Created February 20, 2020 11:17 — forked from Faheetah/Jenkinsfile.groovy
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"
@talonx
talonx / monzo-alertmanager-config.yaml
Created November 30, 2021 05:06 — forked from milesbxf/monzo-alertmanager-config.yaml
Monzo's Alertmanager Slack templates
###################################################
##
## Alertmanager YAML configuration for routing.
##
## Will route alerts with a code_owner label to the slack-code-owners receiver
## configured above, but will continue processing them to send to both a
## central Slack channel (slack-monitoring) and PagerDuty receivers
## (pd-warning and pd-critical)
##