Skip to content

Instantly share code, notes, and snippets.

@codeck
codeck / redocker.sh
Created March 26, 2016 11:47
redsocks for docker container
cat <<EOF
TYPE The following commands:
sysctl -w net.ipv4.conf.docker0.route_localnet=1
iptables -t nat -N REDSOCKS
iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 10.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 127.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 169.254.0.0/16 -j RETURN
iptables -t nat -A REDSOCKS -d 172.16.0.0/12 -j RETURN
iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN
@codeck
codeck / siaq.sh
Last active April 4, 2016 03:59
sia query util
siaq_block() {
curl -s -A "Sia-Agent" http://localhost:9980/explorer/blocks/$1
}
siaq_blkinfo() {
date --date=@$(siaq_block $1|jq .block.rawblock.timestamp)
siaq_block $latest | jq ".block.transactions[0].height, ($(date -u +%s)-.block.rawblock.timestamp)/60, .block.rawblock.nonce"
}
siaq_latest() {

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x

Keybase proof

I hereby claim:

  • I am codeck on github.
  • I am codeck (https://keybase.io/codeck) on keybase.
  • I have a public key ASDyhlx-SXtnYi3px3miYqeOkqvB3k1VVEqUeV-TAaxh7wo

To claim this, I am signing this object:

@codeck
codeck / mk_model1.rkt
Created November 4, 2019 05:09
minikanren first practice
#lang racket
;There are 25 persons in three categories: A, B and C. Class a people always tell the truth, class B people always tell the lie, and class c people tell the truth and the lie separately (for example, if a class C person tells the truth this time, the next sentence he says must be the lie, and the next sentence is the truth again). The priest asked everyone, "are you a class?" 17 answered yes. The priest asked everyone, "are you a class B?" 12 answered yes. The priest asked everyone, "are you a class C?" Eight answered yes. Of these 25 people, how many class C person?
(require minikanren)
(define peano
(lambda (n)
(conde
((== 'z n))