Skip to content

Instantly share code, notes, and snippets.

View ryanhanwu's full-sized avatar
🎯
Focusing

Ryan Wu ryanhanwu

🎯
Focusing
View GitHub Profile
@ryanhanwu
ryanhanwu / MinHeap.js
Last active February 6, 2021 19:29
Heap
class MinHeap {
constructor() {
this.heap = [];
}
getMin() {
return this.heap[0];
}
insert(node) {
/* Inserting the new node at the end of the heap array */
this.heap.push(node);
@ryanhanwu
ryanhanwu / Fastfile
Created February 2, 2021 19:16
Build React Native Android App and submit to Firebase App Distribution via Github Actions
default_platform(:android)
platform :android do
desc "Deploy a new version to the Firebase App Distribution"
lane :beta_ci do
gradle(task: "clean assembleRelease")
firebase_app_distribution(
app: "1:123123123123123123123", #https://console.firebase.google.com/u/2/project/
service_credentials_file: "./firebase-app-distribution.json", # Created from android_workflow.yml steps
@ryanhanwu
ryanhanwu / index.js
Created January 29, 2021 03:01
Hubspot Code Assessment
const fetch = require('node-fetch');
const dayjs = require('dayjs')
const DATASET_API = "https://candidate.hubteam.com/candidateTest/v3/problem/dataset?userKey=USER_KEY"
const RESULT_API = "https://candidate.hubteam.com/candidateTest/v3/problem/result?userKey=USER_KEY"
const findIdealStartDatePartners = (country, partners) => {
let partnersByDate = {}
let mostAvailDate = null
let maxAttendee = -1
@ryanhanwu
ryanhanwu / Makefile
Created May 5, 2020 15:03 — forked from jonschlinkert/Makefile
Simple Makefile to build, run, tag and publish a docker containier to AWS-ECR
# import config.
# You can change the default config with `make cnf="config_special.env" build`
cnf ?= config.env
include $(cnf)
export $(shell sed 's/=.*//' $(cnf))
# import deploy config
# You can change the default deploy config with `make cnf="deploy_special.env" release`
dpl ?= deploy.env
include $(dpl)
const csv = require('csv-parser');
const fs = require('fs');
const endPoints = {}
console.log("digraph g{")
console.log("rankdir=LR;")
console.log("node [style=filled];")
fs.createReadStream('data.csv')
.pipe(csv())
.on('data', (row) => {
@ryanhanwu
ryanhanwu / docker_est.sh
Last active January 16, 2020 18:55
Set #docker timezone to EST
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
apt-get update && apt-get install -y tzdata
ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime
dpkg-reconfigure --frontend noninteractive tzdata
@ryanhanwu
ryanhanwu / setup.sh
Created January 16, 2020 18:52
#Ubuntu Setup
## Update Hostname
```
sudo hostname YOUR_HOSTNAME
# UPDATE your hostname and change it to YOUR_HOSTNAME
vim /etc/hostname
# Update your hosts
echo "127.0.0.1 YOUR_HOSTNAME" >> /etc/hosts
@ryanhanwu
ryanhanwu / vpn.applescript
Created January 16, 2020 18:50
Apple script for automatically create VPN
on create_vpn_service(vpn_name)
tell application "System Preferences"
reveal pane "com.apple.preference.network"
activate
tell application "System Events"
tell process "System Preferences"
tell window 1
click button 1 -- "Add Service"
@ryanhanwu
ryanhanwu / test.js
Created January 9, 2020 15:31
Promise + Async/Await Test1
console.log(1);
(async () => {
const promiseF = new Promise((resolve, reject) => {
console.log(2)
setTimeout(()=>{
try {
console.log(3)
resolve()
console.log(4)
} catch (error) {