Skip to content

Instantly share code, notes, and snippets.

View yeukhon's full-sized avatar

Yeuk Hon Wong yeukhon

  • TikTok USDS / ByteDance
  • New York, NY
  • 04:36 (UTC -05:00)
View GitHub Profile
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
#!/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
// 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")
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"`
>>> @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
@yeukhon
yeukhon / keybase.md
Created January 14, 2017 14:11
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 August 9, 2016 21:11
Tired of Python version? Me too. Recurse Center's coding challenge
// 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 March 22, 2015 23:45
Docker Jumpbox

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.
#!/bin/sh
#
# Nagios script to check website is up and responding in a timely manner
# Written by Chris Freeman ([email protected])
# Version 1.1
# (c) GPLv2 2011
#
# Special thanks to dkwiebe and Konstantine Vinogradov for suggestions and feedback
#