Skip to content

Instantly share code, notes, and snippets.

View hongbo-miao's full-sized avatar
❣️
🥥🏝️🌺🍍🌸

Hongbo Miao hongbo-miao

❣️
🥥🏝️🌺🍍🌸
View GitHub Profile
@hongbo-miao
hongbo-miao / Count lines in Git repo
Created June 18, 2021 18:07 — forked from mandiwise/Count lines in Git repo
A command to calculate lines of code in all tracked files in a Git repo
// Reference: http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository
$ git ls-files | xargs wc -l
@hongbo-miao
hongbo-miao / min-char-rnn.py
Created May 4, 2021 13:30 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
from math import sqrt
import torch
from tqdm import tqdm
import matplotlib.pyplot as plt
import networkx as nx
from torch_geometric.nn import MessagePassing
from torch_geometric.data import Data
from torch_geometric.utils import k_hop_subgraph, to_networkx
import numpy as np
@hongbo-miao
hongbo-miao / health.md
Last active February 18, 2021 12:09
Health Form

Version 2/18/2021

The script is for IT employees who work in Shanghai office.

Feel free to contact me if you have any questions.

How to use the script?

Step 1

<link rel="shortcut icon" width=32px>
<canvas style="display: none" id="loader" width="16" height="16"></canvas>
<script>
class Loader {
constructor(link, canvas) {
this.link = link;
this.canvas = canvas;
this.context = canvas.getContext('2d');
this.context.lineWidth = 2;
@hongbo-miao
hongbo-miao / opentelemetry.js
Last active October 30, 2020 00:11
OpenTelemetry
/* Front End */
import { CollectorTraceExporter } from '@opentelemetry/exporter-collector';
import { DocumentLoad } from '@opentelemetry/plugin-document-load';
import { XMLHttpRequestPlugin } from '@opentelemetry/plugin-xml-http-request';
import { BatchSpanProcessor, ConsoleSpanExporter } from '@opentelemetry/tracing';
import { WebTracerProvider } from '@opentelemetry/web';
const tracerProvider = new WebTracerProvider({
plugins: [new DocumentLoad(), new XMLHttpRequestPlugin()],
});
@hongbo-miao
hongbo-miao / index.md
Created October 4, 2020 22:26 — forked from bvaughn/index.md
How to use profiling in production mode for react-dom
@hongbo-miao
hongbo-miao / nginx.conf
Created September 13, 2020 16:42 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@hongbo-miao
hongbo-miao / encryption.js
Created September 9, 2020 18:08 — forked from vlucas/encryption.ts
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
@hongbo-miao
hongbo-miao / index.js
Last active October 15, 2019 23:54
Chat
// 1. Server
// node index.js
//
// 2. Client
// 1) Start
// telnet localhost 3001
//
// 2) Quit
// Click Ctrl + ], then Ctrl + C