Skip to content

Instantly share code, notes, and snippets.

View microamp's full-sized avatar
💭
>°))彡

Sangho Na microamp

💭
>°))彡
  • Auckland, New Zealand
  • 11:18 (UTC +12:00)
View GitHub Profile
@microamp
microamp / gluepyspark3-setup.md
Last active April 29, 2021 11:15
Using Emacs for AWS Glue PySpark Development

Emacs AWS Glue PySpark Development Setup

  1. Create a new developer endpoint

    • Specify $HOME/.ssh/jumphost.pub as your public key
  2. Update $HOME/.ssh/config accordingly:

@microamp
microamp / markov.py
Created March 26, 2021 05:36
A super simple implementation of Markov chain
import collections
import random
def iter_words(rows):
return (
s.strip() for row in rows for s in row.split(" ") if s.strip() != ""
)
@microamp
microamp / study.org
Last active August 16, 2021 02:21
Study Group - 2021-03-26

“Through the night and day”

The Problem

  • Never written a poem before

The Solution

  • Make the computer generate a poem for me

How?

Markov Chain

  • Wikipedia:
    	 A Markov chain is a stochastic model describing a sequence of possible events in which the probability of each event depends only on the state attained in the previous event.
        
@microamp
microamp / Eva.js
Created November 4, 2020 00:09
Eva.js (WIP)
const assert = require("assert");
const Environment = require("./Environment");
const GlobalEnvironment = new Environment({
null: null,
true: true,
false: false,
VERSION: "0.1",
@microamp
microamp / isset.rkt
Created August 7, 2020 11:13
set? with no helper function
#lang racket
(define set?
(lambda (lat)
(cond
[(null? lat) #t]
[(null? (cdr lat)) #t]
[(eq? (car lat) (car (cdr lat))) #f]
[else (and (set? (cons (car lat) (cdr (cdr lat))))
(set? (cdr lat)))])))
@microamp
microamp / what-if.md
Last active August 3, 2020 05:45
nzkrdev study group 20200731

What If?

@microamp

Preface: Syntax vs Semantics

  • Syntax:
#lang racket
(provide (all-defined-out))
;; definition of structures for MUPL programs - Do NOT change
(struct var (string) #:transparent) ;; a variable, e.g., (var "foo")
(struct int (num) #:transparent) ;; a constant number, e.g., (int 17)
(struct add (e1 e2) #:transparent) ;; add two expressions
(struct ifgreater (e1 e2 e3 e4) #:transparent) ;; if e1 > e2 then e3 else e4
(struct fun (nameopt formal body) #:transparent) ;; a recursive(?) 1-argument function
#lang racket
(provide (all-defined-out))
;; 1
(define (sequence low high stride)
(if (> low high)
null
(cons low (sequence (+ low stride) high stride))))
@microamp
microamp / unless.rkt
Last active July 16, 2020 07:24
The simplest possible macro
(define-syntax unless
(syntax-rules ()
[(unless e1 e2 e3)
(if (not e1) e2 e3)]
[(unless e1 e2)
(if (not e1) e2 #f)]))
(unless #t (/ 1 0) (+ 1 2 3 4)) ;; 10
(unless #t (/ 1 0)) ;; #f
@microamp
microamp / fns.rkt
Created July 13, 2020 09:40
Stop playing games with my funcs
(define (pow1 x y)
(if (zero? y)
1
(* x (pow1 x (- y 1)))))
(define pow2
(lambda (x)
(lambda (y)
(if (zero? y)