Skip to content

Instantly share code, notes, and snippets.

View albert-yu's full-sized avatar
🎹

Albert Yu albert-yu

🎹
  • Navattic
  • New York, NY
View GitHub Profile
;;-------------------------------------------
;; FUNCTIONS
;; https://clojure.org/guides/learn/functions
;;-------------------------------------------
;; 1)
;; Define a function greet that takes no arguments and prints "Hello".
;; Replace the _ with the implementation: (defn greet [] _)
(defn greet [] (println "Hello"))
@albert-yu
albert-yu / ch04-sequences.clj
Last active September 13, 2018 19:38
Clojure from the ground up
;;-----------------------------------------------------------------
;; SEQUENCES
;; https://aphyr.com/posts/304-clojure-from-the-ground-up-sequences
;;-----------------------------------------------------------------
;; [] vector
;; #{} hashset?
; Problems
@albert-yu
albert-yu / eq-binary-tree.go
Created June 24, 2019 23:08
Small exercise comparing binary trees from A Tour of Go
// Exercise page can be found at
// https://tour.golang.org/concurrency/8
package main
import (
"fmt"
"golang.org/x/tour/tree"
)
/*
@albert-yu
albert-yu / compress.test.ts
Created August 5, 2019 21:25
RLE compression
import { compress, decompress } from './compress'
test('basic-compress', () => {
const input = [100, 0, 0, 0, 43, 4, 43, 43]
expect(compress(input)).toBe('100,0:3,43,4,43:2')
})
test('long-compress', () => {
const longInput = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@albert-yu
albert-yu / certbot-ring.md
Last active January 8, 2020 05:25
How to use Certbot with Ring

SSL, Certbot, and Ring

To run our Ring app in production with a valid signed certificate, we need to do a few things.

  1. Generate the signed certificate/chain and private key by following steps 1-3 on Certbot here. The two files generated will be at
/etc/letsencrypt/live/mydomain.com/fullchain.pem
/etc/letsencrypt/live/mydomain.com/privkey.pem
@albert-yu
albert-yu / .vimrc
Last active June 3, 2023 07:48
Vim settings
:set background=dark
:set t_Co=256
" :set number
:set relativenumber
:set rnu
" default tab settings
:set expandtab
:set shiftwidth=4
:set tabstop=4
@albert-yu
albert-yu / bondmath.py
Last active May 8, 2020 17:48
Some potentially useful functions for bond math
def _solver_try(y, face_val, num_periods, coupon_payment):
result = 0
for t in range(1, num_periods + 1):
result += coupon_payment / (1 + y) ** t
if t == num_periods:
result += face_val / (1 + y) ** t
return result
@albert-yu
albert-yu / imslp_scratchpad.py
Last active August 1, 2020 01:07
A supposedly fun thing I'll never do again
# this script was used to convert instrumentation data from IMSLP
# to a collection of objects, decoupling instrument count and misc.
# notes from the long string blob
import os
import json
import re
files = os.listdir(".")
jsons = filter(lambda x: x.endswith(".json"), files)
@albert-yu
albert-yu / certbot-ec2.md
Last active August 16, 2020 04:55
CertBot and Amazon EC2

Getting certbot to work

Download the RPM

curl -O http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Then install it

@albert-yu
albert-yu / certbot-instructions.md
Last active March 19, 2021 19:05
Notes and instructions for deploying React app with nginx and Certbot to EC2 instance

Getting certs for HTTPS

  1. Run yarn build or npm run build on your local machine. scp it over to the EC2 box (you can compress it into a build.zip file and then unzip once it's copied).
  2. Install docker and docker-compose on the EC2 box following these instructions.
  3. Create sym link for docker-compose: sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
  4. Install git on the EC2 if you haven't already. Then clone this repo onto the box. cd into the repo.
  5. Following the README from the above repo, update all necessary configurations (email address, server names).
  6. Run sudo "PATH=$PATH" sh init-letsencrypt.sh.
  7. The generated certs should be at ./data/certbox/live/sub.mysite.com/fullchain.pem and ./data/certbox/live/sub.mysite.com/privkey.pem. Look at the volumes section in the docker-compose.yml in case the configuration is different.
  8. Now, you