Skip to content

Instantly share code, notes, and snippets.

Avatar

Yeuk Hon Wong yeukhon

  • Oscar Health, Inc
  • New York, NY
  • Twitter @y3ukhon
View GitHub Profile
View integral.f90
program integral
implicit none
! we will solve integral of x^2 using the Trapezoidal Rule
integer :: n
real :: a, b, step, delta, coeff, f0, fn, inner_total, x
! We integrate x^2 from 0 to 4 with n intervals
a = 0.0
b = 4.0
View wait_for_rds_instance.sh
#!/bin/bash
# This script takes two arguments: rds database identifier and timeout.
DB_ID=$1
TIMEOUT=$2
POLL_INTERVAL=60
OK_STATES=("backing-up" "available" "modifying" "resetting-master-credentials")
seconds_left=$TIMEOUT
View gist:60a4475c824d7597665a3097cd18b4f4
// NOTE: Ideally we want this kind of output, rather than hardcoing slicing up to 6 chars.
// fmt.Printf("%-13.4f\n", RedIt(StrToNum(stock.Open) - StrToNum(stock.Price)))
// fmt.Printf("%-13s\n", "\x1b[31;1m" + stock.Price + "\x1b[0m")
// I get multiple-value fmt.Printf() in single-value context if:
// fmt.Printf("%-13s\n", "\x1b[31;1m" + fmt.Sprint(fmt.Printf("%.4f", "num)) + "\x1b[0m")
View api_struct.go
package lib
type StockQuoteResponse struct {
Metadata ResponseMetadata `json:"Meta Data"`
BatchQuote BatchQuoteResponse `json:"Stock Batch Quotes"`
}
type ResponseMetadata struct {
Information string `json:"1. Information"`
Notes string `json:"2. Notes"`
View gist:32aa89429a70e577e69b71e8c070ae96
>>> @print
... @print
... @print
... class print(print, print, print, metaclass=print):
... print = print = print
...
print (<built-in function print>, <built-in function print>, <built-in function print>) {'__module__': '__main__', 'print': <built-in function print>, '__qualname__': 'print'}
None
None
None
View keybase.md

Keybase proof

I hereby claim:

  • I am yeukhon on github.
  • I am yeukhon (https://keybase.io/yeukhon) on keybase.
  • I have a public key whose fingerprint is 8914 C10F 1482 1547 4F7B 8124 86F3 41C6 3285 494D

To claim this, I am signing this object:

@yeukhon
yeukhon / main.rs
Created Aug 9, 2016
Tired of Python version? Me too. Recurse Center's coding challenge
View main.rs
// Tired of Python version? Me too.
fn main() {
for x in 1..101 {
match(x%3, x%5) {
// Most specific has to go first
(0, 0) => println!("CracklePop"),
(0, _) => println!("Crackle"),
(_, 0) => println!("Pop"),
(_, _) => { } // do nothing
@yeukhon
yeukhon / jumpie.md
Created Mar 22, 2015
Docker Jumpbox
View jumpie.md

jumpie

  • When a user is authenticated for the first time, a docker container is created for the user.
  • After X minutes, the container is automatically stopped.
  • After X minutes of going above the container's resource cap (CPU for example), the container is stopped.
View gist:452bcac939eb14a25b21
#!/bin/sh
#
# Nagios script to check website is up and responding in a timely manner
# Written by Chris Freeman (cfree6223@gmail.com)
# Version 1.1
# (c) GPLv2 2011
#
# Special thanks to dkwiebe and Konstantine Vinogradov for suggestions and feedback
#