Skip to content

Instantly share code, notes, and snippets.

@quchao
quchao / How_to_Enable_gRPC_Binary_Module_in_WeChat_Mini_Program_Cloud_Functions.md
Created April 10, 2020 08:30
在微信小程序云函数中使用 gRPC 二进制模块。

在微信小程序云函数中使用 gRPC 二进制模块。

[TOC]

截止 10 Apr, 2020 , 微信小程序的云函数仅支持 Node.js 语言,函数在生产环境执行于 CentOS 7.2 的 Node.js 8.9,因此若有二进制模块使用需求请注意相关配置。

现以 gRPC 为例说明。

本地调试

@quchao
quchao / nvmrc-loader.plugin.zsh
Created January 23, 2019 14:25
Calling `nvm use` automatically in a directory with a .nvmrc file
#! /usr/bin/env zsh
# Ref: https://github.com/creationix/nvm#calling-nvm-use-automatically-in-a-directory-with-a-nvmrc-file
# place this after nvm initialization!
autoload -Uz add-zsh-hook
# Function: load-nvmrc
load-nvmrc() {
local _CUR_NODE_VER="$(nvm version)"
@quchao
quchao / dnsmasq2unbound.sh
Last active July 28, 2016 08:49
Convert .conf files in dnsmasq format to unbound format
#!/bin/bash
CN_DNS="182.254.116.116" # DNSPod Shenzhen
CN_DNS_2="114.114.114.114" # 114DNS
cat dnsmasq.conf | grep -v '^#' | sed -e "s|^server=/\([^0-9].*\)/[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}$|forward-zone:\n\tname: \"\1\"\n\tforward-addr: ${CN_DNS}\n\tforward-addr: ${CN_DNS_2}\n\tforward-first: yes|g" -e "s|^address=/\([^0-9].*\)/\([0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}\)$|local-zone: \"\1 A \2\"|g" > unbound.conf
@quchao
quchao / machook_removal.sh
Created January 18, 2016 09:48
MacHook (a.k.a. WireLurker) Removal Script
#!/bin/bash
mkdir -p ~/ppappinstaller/Library/LaunchDaemons ~/ppappinstaller/usr/bin ~/ppappinstaller/usr/local
sudo launchctl unload /Library/LaunchDaemons/com.apple.globalupdate.plist
sudo mv /Library/LaunchDaemons/com.apple.globalupdate.plist ~/ppappinstaller/Library/LaunchDaemons
sudo mv /usr/bin/globalupdate ~/ppappinstaller/usr/bin
sudo launchctl unload /Library/LaunchDaemons/com.apple.itunesupdate.plist
sudo mv /Library/LaunchDaemons/com.apple.itunesupdate.plist ~/ppappinstaller/Library/LaunchDaemons
sudo mv /usr/bin/itunesupdate ~/ppappinstaller/usr/bin
@quchao
quchao / Accelerate_the_loading_of_static_resources_with_China_Unicom_CDNs.json
Last active July 26, 2016 11:26
Accelerate the loading of static resources with China Unicom CDNs (http://120.52.72.*/)
[
{
"name":"Accelerate the loading of static resources with China Unicom CDNs (http://120.52.72.*/)",
"match":{
"str":"^http:\\/\\/(?!(120\\.52\\.72\\.\\d+)).*\\/.*\\.(?:manifest|appcache|html?|xml|json|jpe?g|gif|png|webp|ico|cur|gz|svgz?|mp4|ogg|ogv|webm|htc|css|js|txt|ttf|ttc|otf|eot|woff2?)(?:\\?|#|$)",
"type":0,
"modi":true
},
"sub":{
"str":"^http:\\/\\/(.*)$",