Skip to content

Instantly share code, notes, and snippets.

View kmsheng's full-sized avatar
🏠
Working from home

kmsheng kmsheng

🏠
Working from home
View GitHub Profile
const puppeteer = require('puppeteer-extra')
const StealthPlugin = require('puppeteer-extra-plugin-stealth')
puppeteer.use(StealthPlugin)
;(async () => {
const browser = await puppeteer.launch({
headless: false,
executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
})
analytics.js:31
_ _ _ _
| | | | | | (_)
__ _ ___ ___ __ _| | ___ __ _ _ __ __ _| |_ _| |_ _ ___ ___
/ _` |/ _ \ / _ \ / _` | |/ _ \ / _` | '_ \ / _` | | | | | __| |/ __/ __|
| (_| | (_) | (_) | (_| | | __/ | (_| | | | | (_| | | |_| | |_| | (__\__ \
\__, |\___/ \___/ \__, |_|\___| \__,_|_| |_|\__,_|_|\__, |\__|_|\___|___/
__/ | __/ | __/ |
|___/ |___/ |___/
@kmsheng
kmsheng / https-instance-securitygroup.config
Created August 10, 2017 15:11
AWS Elastic Beanstalk single instance deploy using Docker and Let’s Encrypt Automatic SSL Certificate Renewal
Resources:
sslSecurityGroupIngress:
Type: AWS::EC2::SecurityGroupIngress
Properties:
GroupId: {"Fn::GetAtt" : ["AWSEBSecurityGroup", "GroupId"]}
IpProtocol: tcp
ToPort: 443
FromPort: 443
CidrIp: 0.0.0.0/0
@kmsheng
kmsheng / create.ts
Last active April 8, 2019 08:06
redux-react-hook / src / create.ts
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import {
createContext,
useContext,
useEffect,
useMemo,
useReducer,
useRef,
} from 'react';
@kmsheng
kmsheng / shallowEqual.ts
Last active April 8, 2019 07:49
redux-react-hook / src / shallowEqual.ts
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
// From https://github.com/reduxjs/react-redux/blob/3e53ff96ed10f71c21346f08823e503df724db35/src/utils/shallowEqual.js
const hasOwn = Object.prototype.hasOwnProperty;
// 這個是 Object.is 的 polyfill 版本,應該是給 IE 看的...
function is(x: any, y: any) {
if (x === y) {
return x !== 0 || y !== 0 || 1 / x === 1 / y; // 這裡使 +0 與 -0 比對會是 false
@kmsheng
kmsheng / index.ts
Last active April 8, 2019 06:23
redux-react-hook / src / index.ts
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import {create} from './create'; // 將 create 方法從檔案 create.ts 引入
// 底下呼叫 create 方法的 return 結果 StoreContext, useDispatch 和 useMappedState export 出去
// 這樣外部檔案可以使用 import 語法叫用
export const {StoreContext, useDispatch, useMappedState} = create<
any,
any,
any
const add = require('./add');
console.log(`1 + 1 = ${add(1, 1)}`);
@kmsheng
kmsheng / dollar-signs.sh
Last active August 15, 2018 09:54
All kinds of dollar signs in shell
#!/bin/bash
# Run this script with dollar-sign.sh a b c
echo "process id =" $$
echo
echo "how many arguments = $#"
@kmsheng
kmsheng / Makefile
Created August 15, 2018 09:03
include example
include ./Makefile2.mk
all: target
@kmsheng
kmsheng / Makefile
Last active August 15, 2018 08:28
.INTERMEDIATE example
all: pre target1
pre:
@echo "running pre"
@touch pre
target1:
@echo "target1"
.PHONY: all pre target1