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 / hosts.sh
Created December 5, 2015 18:13
discover hosts on a network
ifconfig | grep broadcast | arp -a

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?
@phylake
phylake / .gitattributes
Created October 18, 2014 21:16
.gitattributes
* text=auto
*.bat text eol=crlf
wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb
sudo apt-get update
sudo apt-get install -y erlang
@phylake
phylake / ssh_port_forward.sh
Created August 14, 2014 15:46
ssh port forwarding
# forward local port 8080 to remotehost.com:3001
ssh -L 8080:localhost:3001 -N user@remotehost.com
@phylake
phylake / main.hs
Created July 21, 2014 23:24
could not deduce b ~ b1
module Main where
class A a where
class B a where
foo :: (A a, B b) => IO a -> (a -> IO b) -> IO ()
foo _ func = return ()
where
-- this breaks because func is not passed in
barBroken :: (A a, B b) => a -> IO b
@phylake
phylake / warp.hs
Last active August 29, 2015 14:04
"hello world" warp app
-- warp-2.1.5.2
-- ghc -O2 -threaded -rtsopts warp
-- ./warp +RTS -N -A1G
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Blaze.ByteString.Builder (copyByteString)
import Data.Text (unpack)
import Network.HTTP.Types.Status (status200)
import Network.Wai
@phylake
phylake / _service.md
Last active August 29, 2015 13:56 — forked from naholyr/_service.md

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
#!/bin/bash
# LC_CTYPE is for darwin
cat /dev/urandom | LC_CTYPE=C tr -cd 'a-f0-9' | head -c 32