Skip to content

Instantly share code, notes, and snippets.

View yanjun-zhou6's full-sized avatar
🌴
In hot days

YanJun Zhou yanjun-zhou6

🌴
In hot days
View GitHub Profile
{
"environment": "staging"
}
@yanjun-zhou6
yanjun-zhou6 / Self-Signed SSL with SAN.md
Created October 28, 2024 03:01 — forked from KeithYeh/Self-Signed SSL with SAN.md
Create self-signed SSL certificate with SubjectAltName(SAN)

How to create a self-signed SSL Certificate with SubjectAltName(SAN)

After Chrome 58, self-signed certificate without SAN is not valid anymore.

Step 1: Generate a Private Key

openssl genrsa -des3 -out example.com.key 2048

Step 2: Generate a CSR (Certificate Signing Request)

@yanjun-zhou6
yanjun-zhou6 / gist:47a19fe9f327af8914b777d557f5c491
Created April 20, 2024 11:35 — forked from getify/gist:1b26accb1a09aa53ad25
first draft sketch of a "Worker" polyfill
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Worker Polyfill</title>
<script src="polyfill.worker.js"></script>
</head>
<body>
<h1>Worker Polyfill</h1>
<script>
@yanjun-zhou6
yanjun-zhou6 / gist:87c400e38b0e3e304bddf08010f115a3
Last active September 4, 2019 03:18
sso: prerender nginx配置
server {
listen 8080;
server_name example.com;
location / {
#proxy_set_header X-Prerender-Token YOUR_TOKEN;
set $prerender 0;
if ($http_user_agent ~* "googlebot|bingbot|yandex|baiduspider|twitterbot|facebookexternalhit|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator") {
@yanjun-zhou6
yanjun-zhou6 / gist:6fdadca561089e1e193eded8ac7432ab
Created September 4, 2019 01:46
16年对jq ajax的封装
/**
* Created by common on 2016/11/21.
*/
;(function ($) {
var _ajax = $.ajax;
$.extend({
/**
* 重写ajax实现
* 主要封装了接口在未登录的情况下调用,弹窗登入弹窗
* 比juqery的ajax多了一个可配置参数 noIdentity
@yanjun-zhou6
yanjun-zhou6 / js
Last active September 5, 2019 16:12
redux: reducer create
/**
* Model base class
*/
const asyncActionFactry = Symbol("asyncActionFactry");
export class Model {
static getInstance = function(clazz) {
const instance = new clazz();
instance.createActions();
return instance;
@yanjun-zhou6
yanjun-zhou6 / gist:51e29cb1c436ae3a7818e75f7d5e05d8
Created September 3, 2019 23:55
redux: store create methods
import {
applyMiddleware,
compose,
createStore as reduxCreateStore
} from "redux";
import thunk from "redux-thunk";
import { combineReducers } from "redux";
import { Model } from "./model";
const reducerMap = {};
@yanjun-zhou6
yanjun-zhou6 / routers.js
Last active March 29, 2024 07:10
SSR: Initial state injects to page component
<Switch>
{routes.map((route, i) => (
<Route
key={`route--${i}`}
path={route.path}
exact={route.exact}
strict={route.strict}
location={previousLocation || location}
render={props =>
React.createElement(route.component, {
@yanjun-zhou6
yanjun-zhou6 / load_Initial_props.js
Last active March 29, 2024 07:08
SSR: Get initial state only for root route.
export async function loadInitialProps (routes, path, ctx) {
const initialPropsPromises = [];
const isMatchedComponent = routes.find (route => {
const match = matchPath (path, route);
//if matched, judge compoent and getInitialProps is existed
if (
match &&
route.component &&
(route.component.getInitialProps || route.component.load)
@yanjun-zhou6
yanjun-zhou6 / server.js
Last active March 29, 2024 07:09
SSR: Get initial state through both root and children routes.
server
.disable("x-powered-by")
.use(express.static(process.env.RAZZLE_PUBLIC_DIR))
.configProxy()
.get("/*", (req, res) => {
const { url } = req;
const branch = matchRoutes(staticRoutes, url);
const context = {};
const promises = branch.map(({ route, match }) => {
const { component } = route;