Skip to content

Instantly share code, notes, and snippets.

Statement : Average distance of values from the mean is always 0.
Proof : Let values be n1, n2, n3....nn.
Then mean M = (sum (ni | i = 1 to n))/n
Average distance of values from mean
= ( (M - n1) + (M - n2) ... + (M-nn) ) / n
= ( M x n - (n1 + n2 + .... nn) ) / n
= M - (sum (ni | i = 1 to n))/n
talonx / gist:852730
Created March 3, 2011 13:08
[Statistics] Why squares instead of absolute values in calculating variance?
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 / ideal
Created August 14, 2012 12:18 — forked from bhenerey/ideal
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:


  • Accurate / up-to-date systems architecture diagram

  • Accurate / up-to-date network diagram

  • Out-of-hours support plan

  • Incident management plan

talonx / rot13.go
Last active December 13, 2015 11:51
rot13 using lookup table
package main
import (
type rot13Reader struct {
package main
import (
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
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

curl --verbose --user admin:admin -d '{"hello:input": { "name":"talonx"}}' -H "Content-Type: application/json" "http://localhost:8181/restconf/operations/hello:hello-world"
import scala.collection.mutable.Map
object reduce {
def reduceByKey(func: (Int, Int) => Int, pairs: List[(String, Int)]): Map[String, Int] = {
val ret = Map[String, Int]()
for (tup <- pairs) {
val k = tup._1
val v = tup._2
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
path: "/path/to/files/{{ item }}"
state: absent