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 / 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.js
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
https://press.one/p/v?s=a98d146efa2ee83dafcbef33da78eadae5b3c861e16fe4bc66344ea4bf4fbfb35c52bdb5b8f9c82f15a42cea9e68cc51a5602324503960bcf3152d824190175601&h=e317ecaf519eedbfbf39deda7515d970b93b3488549aa9d1157bfd43befe3ab2&a=83f94ab86a1749d7682b0087d4b81d73ef0f0103&f=P1&v=3
@hongbo-miao
hongbo-miao / app-1.spec.ts
Last active December 7, 2016 01:45 — forked from wkwiatek/app-1.spec.ts
Angular 2 test snippets for Angular final version. Codebase for https://developers.livechatinc.com/blog/category/programming/angular-2/
// App
import { Component } from '@angular/core';
@Component({
selector: 'app',
template: '<span>{{ sayHello() }}</span>',
})
export class App {
public name: string = 'John';

Keybase proof

I hereby claim:

  • I am hongbo-miao on github.
  • I am hongbo_miao (https://keybase.io/hongbo_miao) on keybase.
  • I have a public key ASD2n4Xue3rP7-aQhXDNj9EBv0Xk5a-az4CAMV_wGxbsPgo

To claim this, I am signing this object:

@hongbo-miao
hongbo-miao / transpose.js
Created November 1, 2016 05:04 — forked from femto113/transpose.js
one line transpose for 2-dimensional Javascript arrays
function transpose(a)
{
return a[0].map(function (_, c) { return a.map(function (r) { return r[c]; }); });
}

Linux fun-o-matic

How to have some fun using the terminal.

  1. Install cowsay [0] via : sudo apt-get install cowsay
  2. Install fortune [1] via : sudo apt-get install fortune
  3. Make sure you have Ruby installed via : ruby -v
  4. Install the lolcat [2] via : gem gem install lolcat
  5. Profit!