Skip to content

Instantly share code, notes, and snippets.

@meetme2meat
meetme2meat / unmarshal_interface.go
Created September 23, 2019 14:06 — forked from tkrajina/unmarshal_interface.go
Unmarshal JSON to specific interface implementation
package main
import (
"encoding/json"
"fmt"
"reflect"
)
type Something interface{}
@meetme2meat
meetme2meat / gist:ed1223b7f9675243b9e0da082726fe2e
Created February 3, 2019 05:07 — forked from pbailis/gist:5660980
Assorted distributed database readings

Context: I was asked for a list of interesting reading relating to "distributed databases, behavior under partitions and failures, failure detection." Here's what I came up with in about an hour.

For textbooks, "Introduction to Reliable and Secure Distributed Programming" is a superb introduction to distributed computing from a formal perspective; it's really not about "programming" or "engineering" but about distributed system fundamentals like consensus, distributed registers, and broadcast. Used in Berkeley's Distributed Computing course (and HT to @lalithsuresh) Book Site

Notes from courses like Lorenzo Alvisi's Distributed Computing class can be great.

There are a bunch of classics on causality, [Paxos](ht

@meetme2meat
meetme2meat / Gemfile
Created February 20, 2018 07:17 — forked from karmi/Gemfile
Sinatra + EventSource JavaScript Streaming
source "http://rubygems.org/"
gem "sinatra", "~> 1.3.0"
gem "thin"
@meetme2meat
meetme2meat / requestor.awk
Created November 17, 2017 03:08 — forked from sinegar/requestor.awk
Combine tcpdump packets into requests and response times.
#!/usr/bin/awk -f
# #
#
# Inspired by http://www.percona.com/doc/percona-toolkit/2.1/pt-tcp-model.html
#
# Example usage:
# $ tcpdump -i any -s 0 -nnq -tt 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
# 1349692787.492311 IP X.X.X.X.XXXX > X.X.X.X.XXXX: tcp 1448
# $ ./requestor.awk dump.file
@meetme2meat
meetme2meat / call-apply-bind-proxy.js
Created September 26, 2016 07:42 — forked from branneman/call-apply-bind-proxy.js
JavaScript call() vs apply() vs bind() vs $.proxy()
var fn = function(arg1, arg2) {
var str = '<p>aap ' + this.noot + ' ' + arg1 + ' ' + arg2 + '</p>';
document.body.innerHTML += str;
};
var context = {
'noot': 'noot'
};
var args = ['mies', 'wim'];
// Calls a function with a given 'this' value and arguments provided individually.
@meetme2meat
meetme2meat / gist:f22f0b62eeb314fb3c51eac96b059f1c
Created July 26, 2016 04:41
Ruby's performance tuning way
tell application "SystemUIServer"
set actionSelected to the button returned of (display dialog "What you want to do?" buttons {"Send file", "Receive file"} default button 2)
if actionSelected = "Send file" then
set filepath to POSIX path of (choose file)
display dialog "Please enter IP address of receiver:" default answer ""
set ipAddress to text returned of result
if ipAddress = "" then
repeat
display dialog "IP address cant be blank,Please enter IP address of receiver:" default answer ""
> - In ruby 1.8.x, what is the functional difference between rb_thread_schedule and rb_thread_select?
rb_thread_schedule() is the guts of the thread scheduler, it traverses
over the linked list of threads (several times) to find the next one
to switch into. The function is long (250 lines) and messy, and covers
all the combinations of thread status (RUNNABLE, TO_KILL, STOPPED,
KILLED) and wait state (FD, SELECT, TIME, JOIN, PID).
If there are no threads doing i/o or waiting on a timeout,
rb_thread_schedule() picks another thread from the list (considering