Skip to content

Instantly share code, notes, and snippets.

@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))

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:

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
@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() {
@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
/*****************************************************************************
* QuantCup 1: Price-Time Matching Engine
*
* Submitted by: voyager
*
* Design Overview:
* In this implementation, the limit order book is represented using
* a flat linear array (pricePoints), indexed by the numeric price value.
* Each entry in this array corresponds to a specific price point and holds
* an instance of struct pricePoint. This data structure maintains a list
@codeck
codeck / gist:05c7240f3eab48919aac
Created December 5, 2015 14:34
debug scala implicit
$sbt
> projects
> project <subproject>
> set scalacOptions += "-Xlog-implicits"
> session list-all
@codeck
codeck / tune_wal_sqlite.sql
Created September 30, 2015 13:23
if .wal of sqlite increase always
PRAGMA journal_size_limit=0;
@codeck
codeck / run_es6.sh
Created August 25, 2015 03:35
how to run es6 javascript
#apt-get install npm
#ln -s /usr/bin/nodejs /usr/bin/node
echo 'prefix = ${HOME}/.npm-packages' >> ~/.npmrc
git clone https://github.com/stellar/js-stellar-base.git && cd js-stellar-base
npm install -g babel
npm install
babel-node examples/test.js