Instantly share code, notes, and snippets.

# Hrishikesh Barua talonx

Created January 23, 2011 10:35
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 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
Created March 3, 2011 13:08
[Statistics] Why squares instead of absolute values in calculating variance?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Created January 5, 2012 05:58 — forked from qwzybug/ec2-ssh.rb
SSH into an EC2 instance by name.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #!/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|
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

Last active December 13, 2015 11:51
rot13 using lookup table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 package main import ( "fmt" "io" "os" "strings" ) type rot13Reader struct {
Created December 14, 2015 18:39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 package main import ( "golang.org/x/tour/tree" "fmt" ) // Walk walks the tree t sending all values // from the tree to the channel ch. func Walk(t *tree.Tree, ch chan int) {
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

Created November 12, 2016 19:26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 curl --verbose --user admin:admin -d '{"hello:input": { "name":"talonx"}}' -H "Content-Type: application/json" "http://localhost:8181/restconf/operations/hello:hello-world"
Last active April 27, 2017 15:29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 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
Last active June 19, 2017 19:27 — forked from jgornick/ansible.yml
Ansible: Remove All Files Except
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 --- - 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