Skip to content

Instantly share code, notes, and snippets.

@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)
@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 / 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 / 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
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 / .gitattributes
Created October 18, 2014 21:16
.gitattributes
* text=auto
*.bat text eol=crlf

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 / 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('')
@phylake
phylake / .gemrc
Created February 29, 2012 20:18
gemrc
gem: --no-rdoc --no-ri
@phylake
phylake / hosts.sh
Created December 5, 2015 18:13
discover hosts on a network
ifconfig | grep broadcast | arp -a