Skip to content

Instantly share code, notes, and snippets.

@Luke-zhang-04
Luke-zhang-04 / dirname.js
Created February 1, 2022 22:52
dirname in mjs
// __dirname in esm
import {dirname} from "path"
import {fileURLToPath} from "url"
const __dirname = dirname(fileURLToPath(import.meta.url))
@Luke-zhang-04
Luke-zhang-04 / download.mjs
Last active June 29, 2021 19:51
batch upload/download files from Firebase Storage
// Run with `node --experimental-json-modules images.mjs`
// Requires node 14+
// Dependencies are in the imports below
import admin from "firebase-admin"
import fetch from "node-fetch"
import fs from "fs"
import serviceAccount from "./adminsdk.json"
@Luke-zhang-04
Luke-zhang-04 / main.cpp
Last active February 7, 2021 17:05
C++ basics
#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
@Luke-zhang-04
Luke-zhang-04 / .clang-format
Last active April 18, 2025 19:34
Clang-format, ESLint, and Prettier config
---
BasedOnStyle: LLVM
Language: Cpp
PointerAlignment: Left
AccessModifierOffset: 4
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveBitFields: false
@Luke-zhang-04
Luke-zhang-04 / http-status-codes.ts
Last active July 14, 2022 15:12
Typescript const enum of http response status codes
/**
* ## Hypertext Transfer Protocol (HTTP) response status codes
*
* HTTP response status codes indicate whether a specific HTTP request has been successfully
* completed. Responses are grouped in five classes:
*
* 1. Informational responses (100–199)
* 2. Successful responses (200–299)
* 3. Redirects (300–399)
* 4. Client errors (400–499)
@Luke-zhang-04
Luke-zhang-04 / footer.jsx
Last active June 9, 2025 15:45
React and Bootstrap 5 footer
@Luke-zhang-04
Luke-zhang-04 / HTML Template.code-snippets
Created July 14, 2020 18:21
Code Snippets for VSCode (the best IDE)
// Paste this into your "HTML Template.code-snippets" file (ctrl/cmd + p
{
"meta": {
"prefix": ["meta", "meta-tags"],
"body": [
"<title>$1</title>",
"<meta charset=\"utf-8\"/>",
"<meta property=\"viewport\" name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>",
"<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">",
@Luke-zhang-04
Luke-zhang-04 / $quickstart.md
Last active July 13, 2020 14:58
Quickstart

Welcome to

logo

One command to quickstart your project.


@Luke-zhang-04
Luke-zhang-04 / .eslintignore
Last active October 6, 2020 20:40
Eslint JSON Template
# This eslintignore file auto-generated by Quickstart. You are free to modify it as you please.
# https://github.com/Luke-zhang-04/quickstart
# To find out more about Eslint, visit https://eslint.org/
*/node_modules/
**/functions/lib/*
**/*.d.ts
/src/serviceWorker.ts
@Luke-zhang-04
Luke-zhang-04 / baseConverter.py
Created April 8, 2020 18:45
Binary to Hexadecimal code (also a test for gists)
#bruh what is a gist
hexes = {"A": 10, "B": 11, "C": 12, "D": 13, "E": 14, "F": 15}
hexes_reversed = {10: "A", 11: "B", 12: "C", 13: "D", 14: "E", 15: "F"}
class Decimal: #everything from decimal/base 10
@staticmethod
def to_binary(number): #decimal to binary
value = int(number)
total = []