Skip to content

Instantly share code, notes, and snippets.

View htdangkhoa's full-sized avatar
💪
Every problem has more than one way to solve it.

Huỳnh Trần Đăng Khoa htdangkhoa

💪
Every problem has more than one way to solve it.
View GitHub Profile
@htdangkhoa
htdangkhoa / mila_api_scratchpad.py
Created January 8, 2024 06:41 — forked from sanghviharshit/mila_api_scratchpad.py
Scratch pad for working with Milacares API for monitoring and controlling Mila air purifier. Read my blog post for more details - https://blog.sanghviharshit.com/reverse-engineering-private-api-ssl-pinning/
# Scratch pad for working with Milacares API for monitoring and controlling their air purifier devices.
# Based on the code from https://www.stefaanlippens.net/oauth-code-flow-pkce.html for PKCE code verifier and challenge.
import base64
import hashlib
import html
import json
import os
import re
import urllib.parse
@htdangkhoa
htdangkhoa / Nework_throttling_profiles.md
Created July 6, 2023 03:55 — forked from theodorosploumis/Nework_throttling_profiles.md
Web development - Custom network throttling profiles
Profile download (kb/s) upload (kb/s) latency (ms)
Native 0 0 0
GPRS 50 20 500
56K Dial-up 50 30 120
Mobile EDGE 240 200 840
2G Regular 250 50 300
2G Good 450 150 150
3G Slow 780 330 200
@htdangkhoa
htdangkhoa / setup.sh
Created April 24, 2022 19:26
Setup Raspberry Pi cluster using NodeJS, Docker & K3S
# update apt
sudo apt update -y
# install git
sudo apt install -y git
# install NodeJS
curl -sSL https://deb.nodesource.com/setup_16.x | sudo bash -
sudo apt install -y nodejs
import { AbstractFactory } from './AbstractFactory';
import { ConcreteFactory1, ConcreteFactory2 } from './ConcreteFactory'
function clientCode(factory: AbstractFactory) {
const productA = factory.createProductA();
const productB = factory.createProductB();
console.log(productA.usefulFunctionA());
console.log(productB.usefulFunctionB());
}
import { AbstractFactory } from 'AbstractFactory';
import { ConcreteProductA1, ConcreteProductA2 } from 'ProductA';
import { ConcreteProductB1, ConcreteProductB2 } from 'ProductB';
export class ConcreteFactory1 implements AbstractFactory {
public createProductA(): AbstractProductA {
return new ConcreteProductA1();
}
public createProductB(): AbstractProductB {
export interface AbstractFactory {
createProductA(): AbstractProductA;
createProductB(): AbstractProductB;
}
export interface AbstractProductB {
usefulFunctionB(): string;
}
export class ConcreteProductB1 implements AbstractProductB {
public usefulFunctionB(): string {
return "The result of the product B1.";
}
}
export interface AbstractProductA {
usefulFunctionA(): string;
}
export class ConcreteProductA1 implements AbstractProductA {
public usefulFunctionA(): string {
return "The result of the product A1.";
}
}
@htdangkhoa
htdangkhoa / AbstractFactory.ts
Last active April 21, 2022 06:54
Abstract Factory Pattern in Typescript
export interface AbstractFactory {
createProductA(): AbstractProductA;
createProductB(): AbstractProductB;
}
@htdangkhoa
htdangkhoa / docker-compose.yml
Created March 7, 2022 14:11 — forked from pantsel/docker-compose.yml
example docker-compose.yml for kong, postgres and konga
version: "3"
networks:
kong-net:
driver: bridge
services:
#######################################
# Postgres: The database used by Kong