Skip to content

Instantly share code, notes, and snippets.

View mark-rushakoff's full-sized avatar
🙈
I'm not watching GitHub notifications. Contact me directly to get my attention.

Mark Rushakoff mark-rushakoff

🙈
I'm not watching GitHub notifications. Contact me directly to get my attention.
View GitHub Profile
@mark-rushakoff
mark-rushakoff / log.md
Created November 26, 2013 07:03
Benchmarking NATS connectivity in a CloudFoundry deployment

On nats_z2/0 (only NATS server):

$ sudo su
$ cd /var/vcap/bosh/bin
$ ./nats-server --port 12121 --user foo --pass bar

On api_z1/1 (Working CC, different AZ from NATS):

@mark-rushakoff
mark-rushakoff / Dockerfile
Created September 18, 2013 07:11
cf-deployer Dockerfile
FROM ubuntu:precise
MAINTAINER Mark Rushakoff <mark.rushakoff@gmail.com>
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y build-essential libffi-dev libgdbm-dev libncurses5-dev libreadline-dev libssl-dev libyaml-dev zlib1g-dev
RUN apt-get install -y wget
@mark-rushakoff
mark-rushakoff / wrapped_func_benchmark_test.go
Created August 16, 2013 22:45
Is there a difference when using `go foo()` vs. `go func() { foo() }()`? (This never finished when I ran it on my MacBook Air.)
package wrapped_func
// Run this benchmark with `go test -bench=.`
import "testing"
func BenchmarkSendItClean(b *testing.B) {
total := b.N
c := make(chan bool)
for i := 0; i < total; i++ {
@mark-rushakoff
mark-rushakoff / results.txt
Created December 19, 2015 18:48
Which is faster: `s += str` or `buf.WriteString(str) ... buf.String()`?
PASS
BenchmarkStringConcat-4 2000000 3901 ns/op
BenchmarkByteBuffer-4 10000000 966 ns/op
@mark-rushakoff
mark-rushakoff / leanpub_word_count.sh
Created April 5, 2013 14:58
Count words in your Leanpub book
#!/bin/sh
BOOK_SRC="${$1:-Book.txt}"
cat "$BOOK_SRC" | xargs cat | # dump out all the files in the book
sed 's/%%.*$//g' | # naively strip comment delimiter to end of line
wc -w | # print out the word count
@mark-rushakoff
mark-rushakoff / find_rescue.sh
Created March 17, 2013 02:35
Finding number of particular statements in a git project
#!/usr/bin/sh
git grep -c rescue . | # or whatever word it is you want
tr ':' "\t" | # translate grep -c delimiter to tab for sort
sort -nr -k2 # sort Numeric, Reverse, "kolumn" 2
@mark-rushakoff
mark-rushakoff / bash_tar.sh
Last active December 14, 2015 02:49
Demonstration of how gzip seems to embed a timestamp
> echo 'Hello!' > hello.txt
> # Create 2 tarballs at right about the same time:
> tar czf hello1.tar.gz hello.txt; tar czf hello2.tar.gz hello.txt
> md5 * # The tarballs have the same md5
MD5 (hello.txt) = e134ced312b3511d88943d57ccd70c83
MD5 (hello1.tar.gz) = bfdacca1166009500d60151d73c4da7e
MD5 (hello2.tar.gz) = bfdacca1166009500d60151d73c4da7e
> tar czf hello1.tar.gz hello.txt; tar czf hello2.tar.gz hello.txt
> md5 * # The tarballs have a different md5
MD5 (hello.txt) = e134ced312b3511d88943d57ccd70c83
@mark-rushakoff
mark-rushakoff / io_popen_example.rb
Last active December 13, 2015 20:48
How to simultaneously print and capture the output of an external command in Ruby
#!/usr/bin/env ruby
cmd = %q[echo '3...'; sleep 1;
echo '2...'; sleep 1;
echo '1...'; sleep 1;
echo 'Liftoff!']
puts '------ beginning command ------'
output_log = []
IO.popen(cmd).each do |line|
@mark-rushakoff
mark-rushakoff / .vimrc
Created March 31, 2012 18:36
My .vimrc
syn on
set syn=auto
filetype on
filetype plugin on
filetype indent on
autocmd FileType haml set ts=2 shiftwidth=2
autocmd FileType ruby set ts=2 shiftwidth=2
autocmd FileType javascript set nocindent
@mark-rushakoff
mark-rushakoff / sample.js
Created March 2, 2012 21:10
Sample gist for try-jasmine
function add(a, b) {
return a + b;
}