Skip to content

Instantly share code, notes, and snippets.

View peteygao's full-sized avatar
💭
Writing Elm @ LearningLoop.com

Peter Gao peteygao

💭
Writing Elm @ LearningLoop.com
  • CTO @ LearningLoop.com
  • Singapore / San Francisco
View GitHub Profile
@peteygao
peteygao / install_docker.sh
Last active February 17, 2024 05:03
Auto-Install Docker and Docker Compose on AWS Lightsail running Ubuntu 20.04
# Create a 1GiB Swap File
# Lightsail ubuntu image doesn't boot with swap.
# If you run out of RAM, the system hangs OOM.
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
@peteygao
peteygao / expandable-text.js
Created November 24, 2023 08:14
Expandable Text web component (hide text behind a "Read more" button)
class ExpandableText extends HTMLElement {
private shadow: ShadowRoot;
private container: HTMLDivElement;
private readMoreBtn: HTMLSpanElement;
private expanded: boolean;
private containerLargerThanText: boolean;
constructor() {
super();
this.shadow = this.attachShadow({ mode: 'open' });
### Keybase proof
I hereby claim:
* I am peteygao on github.
* I am pyg (https://keybase.io/pyg) on keybase.
* I have a public key ASD5uulFcfkEJ-omky9YHgW4ZwaBSf4K47Jo-bhaqe7twQo
To claim this, I am signing this object:
@peteygao
peteygao / Cordova for iOS
Last active February 21, 2021 23:57
Step by Step guide to installing Cordova for iOS development
1. Install Xcode, if you haven't already.
a. Once installed, run Xcode and accept the license agreement.
b. Go into Xcode Prefs (Cmd + ,), go to Downloads, and install "Command Line Tools for Xcode" (or something named similarily)
2. Install Homebrew (copy and paste the following into your terminal):
```bash
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
CSV Import
Empty State
submits good CSV -> Modal Closes
submits bad CSV -> Modal Shows Error
Modal Closes
Modal Shows Error
User Manually Clicks on Modal to Dismiss -> Empty State
@peteygao
peteygao / Linux Snippets
Created November 16, 2016 02:26
Linux Snippets
watch -n 1 cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq # including logical processors (HyperThreading)
watch -n 1 cat /sys/bus/platform/devices/coretemp.0/hwmon/hwmon1/temp{1,2,3}_input # temp1 is the highest core's temp
alsamixer # Terminal audio mixer (if the volume setting doesn't show up in desktop UI)
@peteygao
peteygao / .xmodmap
Last active November 16, 2016 01:14
xmodmap to swap Ctrl_L with Alt_L and remap Capslock to BackSpace
remove control = Control_L
remove mod1 = Alt_L
keycode 37 = Alt_L
keycode 64 = Control_L
add control = Control_L
add mod2 = Alt_L
clear lock
keycode 66 = BackSpace
@peteygao
peteygao / rubinius_segfault.log
Created March 21, 2016 20:52
Rubinius Segfaults during build
** Invoke gems:melbourne (first_time)
** Execute gems:melbourne
/home/pi/rubinius-3.19/staging/bin/rbx ./extconf.rbc
make && make install
compiling var_table.cpp
compiling symbols.cpp
compiling grammar.cpp
compiling melbourne.cpp
compiling visitor.cpp
compiling encoding_compat.cpp
@peteygao
peteygao / trollface.ascii
Created March 15, 2016 20:59
Trollface ACSII art
░░░░░░░░░░░░▄▀▀▀▀▀▀▀▀▄
░░░░░█░░░░▒▒▒▒▒▒▒▒▒▒▒▒▀▀▄
░░░░█░░░▒▒▒▒▒▒░░░░░░░░▒▒▒░█
░░░█░░░░░░▄██▀▄▄░░░░░▄▄▄░░░█
░▄▀▒▄▄▄▒░█▀▀▀▀▄▄█░░░██▄▄█░░░█
█░▒█▒▄░▀▄▄▄▀░░░░░░░░█░░░▒▒▒▒▒█
█░▒█░█▀▄▄░░░░░█▀░░░░▀▄░░▄▀▀▄▒█
░█░▀▄░█▄░█▀▄▄░▀░▀▀░▄▄▀░░░░░█
░░█░░░░██░░▀█▄▄▄█▄▄█▄████░█
░░░█░░░░▀▀▄░█░░░█░█▀██████░█
@peteygao
peteygao / micro_ruby_benchmark_results
Created March 2, 2016 09:45
Results of the micro Ruby benchmark testing MRI 2.3.0 vs Rubinius 3.19
RUBINIUS 3.19 MRI 2.3.0
Warming up '#sum 10 million elements' Warming up '#sum 10 million elements'
Average of 3 runs: 0.8526433626666666 Average of 3 runs: 0.7457792716666667
================================================== ==================================================
Warming up '#md5 200k elements with NO threading' Warming up '#md5 200k elements with NO threading'
Average of 3 runs: 1.4279883816666665 Average of 3 runs: 0.2355165813333333
================================================== ==================================================
Warming up '#md5 200k elements with 1 thread' Warming up '#md5 200k elements with 1 thread'
Average of 3 runs: 3.084292838666667 Average of 3 runs: 0.7009185860000001
================================================== ==================================================