This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- A straightforward implementation of Peano's Axioms for the Natural Numbers in Haskell. | |
-- This is intended as a demonstration of similarity between functional code and its equivalent in (informal) first order logic | |
import Prelude hiding ( (+), (*) ) | |
-- There exists a set Nat with the distinguished element Zero and the function Suc, such that if n is in Nat, then Suc(n) is in Nat | |
data Nat = Zero | Suc Nat deriving (Eq, Show) | |
-- There exists a binary function + on (Nat x Nat) such that |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
# The transition matrix. Notice that each column sums to 1 | |
T = np.array([[0.25, 0.33, 0.3 ], | |
[0.5 , 0.66, 0.2 ], | |
[0.25, 0.01, 0.5 ]]) | |
# The state vector. We are initially in the first state with 100% probability | |
s = np.array([1.0, 0.0, 0.0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" set the active tmux pane for the current buffer | |
nnoremap <leader>0 :let b:activepane = 0<cr> | |
nnoremap <leader>1 :let b:activepane = 1<cr> | |
nnoremap <leader>2 :let b:activepane = 2<cr> | |
nnoremap <leader>3 :let b:activepane = 3<cr> | |
nnoremap <leader>4 :let b:activepane = 4<cr> | |
" send the current line to the active pane | |
nnoremap <leader><cr> :silent :execute ':.w !cat \| (read cmd; tmux send-keys -t' b:activepane ' "$cmd" enter)'<cr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request | |
import sys | |
app = Flask(__name__) | |
@app.route('/api/test', methods=['GET', 'POST']) | |
def test(): | |
content = '<p>handler: ' + sys._getframe(0).f_code.co_name + \ | |
'</p>\n<ul>\n' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Prevent <esc>+[key] from generating a foreign character | |
" Credit to https://github.com/neovim/neovim/issues/2093#issuecomment-135685601 | |
set ttimeout | |
set ttimeoutlen=0 | |
set matchtime=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%display latex | |
def get_vecs(n): | |
'''Get the orthonormal basis vectors of RR^n''' | |
vecs = [] | |
for i in range(n): | |
vecs.append([1 if x == i else 0 for x in range(n)]) | |
return vecs | |
def apply_permutation(lst, perm): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 \ | |
-subj "/C=US/ST=TEST/O=TEST/O=TEST/CN=localhost" \ | |
-passout pass:abc123 \ | |
-out $PWD/server.crt \ | |
-keyout $PWD/server.key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func parseEnv() (map[string]string) { | |
pass := true | |
m := make(map[string]string) | |
for _, k := range []string{ | |
"GRPC_PORT", | |
"GOOGLE_CLIENT_ID", | |
"GOOGLE_CLIENT_SECRET", | |
"CERTFILE", | |
"KEYFILE", | |
} { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOCAL_DIR=$1 | |
REMOTE_DIR=$2 | |
DEV_IP=$3 | |
while inotifywait -e modify -e create --exclude '/\..+' -r $LOCAL_DIR; do | |
rsync -avz --exclude '/\..+' $LOCAL_DIR $USER@$DEV_IP:$REMOTE_DIR | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import builtins | |
from unittest.mock import patch | |
class InputSeq(): | |
'''Emit elements of a sequence by invoking __call__''' | |
def __init__(self, input_seq): | |
self._input_seq = input_seq.copy() | |
self._index = -1 | |
def __call__(self, _=None): |
OlderNewer