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
import protobuf from 'protobufjs';
const migrationProto = `
syntax = "proto3";
message MigrationPayload {
enum Algorithm {
ALGORITHM_UNSPECIFIED = 0;
ALGORITHM_SHA1 = 1;
ALGORITHM_SHA256 = 2;
.modal {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
text-align: left;
z-index: 1000;
@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.";
}
}