Skip to content

Instantly share code, notes, and snippets.

@phylake
phylake / tcp_send_challenge_ack.stap
Created June 12, 2019 19:02
tcp_send_challenge_ack.stap
probe kernel.function("tcp_send_challenge_ack") {
printf("tcp_send_challenge_ack local=%s:%d remote=%s:%d\n",
format_ipaddr(tcpmib_local_addr($sk), AF_INET),
tcpmib_local_port($sk),
format_ipaddr(tcpmib_remote_addr($sk), AF_INET),
tcpmib_remote_port($sk)
);
}
@phylake
phylake / openssl.md
Last active February 4, 2019 20:25
openssl help
#!/bin/bash
# LC_CTYPE is for darwin
cat /dev/urandom | LC_CTYPE=C tr -cd 'a-f0-9' | head -c 32

Assignment in most other languages could be thought of as a stateful computation. For instance, when we do x = 5 in an imperative language, it will usually assign the value 5 to the variable x and it will also have the value 5 as an expression. If you look at that functionally, you could look at it as a function that takes a state (that is, all the variables that have been assigned previously) and returns a result (in this case 5) and a new state, which would be all the previous variable mappings plus the newly assigned variable.

http://learnyouahaskell.com/for-a-few-monads-more#state

@phylake
phylake / Main.as
Last active December 16, 2015 17:29
closure challenge
package
{
import flash.display.Sprite;
import flash.events.Event;
/**
* 1. What will be printed to the console (via the trace statement)?
* 2. What is the value of this inside of nested()
*/
public class Main extends Sprite
@phylake
phylake / logicalOR_replacement.md
Last active December 16, 2015 04:49
reg ex goodies

Replace all logical or assignment A ||= B with A || (A = B)

([^\s]+) \|\|= (.*);

$1 || ($1 = $2);

@phylake
phylake / hosts.sh
Created December 5, 2015 18:13
discover hosts on a network
ifconfig | grep broadcast | arp -a
@phylake
phylake / .gemrc
Created February 29, 2012 20:18
gemrc
gem: --no-rdoc --no-ri
@phylake
phylake / vigenere.rb
Created February 9, 2012 23:35
1.61803398874.com solution
l = "xfbhlqtlj".split('').collect {|c| c[0] - 97}
k = [6,1,8,0,3,3,9,8,8]
l = l.zip(k).collect do |p|
t = (p[0] - p[1]) % 26
t += 97
t.chr
end
p l.join('')

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?