Skip to content

Instantly share code, notes, and snippets.

@dschowta
dschowta / protobuf_struct_converter.go
Created August 6, 2020 05:55
golang: grpc: interface or map type conversion to protobuf struct using protojson .
// Conversion of interface{} or map[string]interface{} types to protobuf struct ("google/protobuf/struct.proto").
package codec
import (
"encoding/json"
structpb "github.com/golang/protobuf/ptypes/struct"
"google.golang.org/protobuf/encoding/protojson"
)
@akhenakh
akhenakh / app.yaml
Last active March 4, 2023 19:22
Example of graceful shutdown with grpc healthserver * httpserver
readinessProbe:
exec:
command: ["/root/grpc_health_probe", "-addr=:6666"]
initialDelaySeconds: 1
livenessProbe:
exec:
command: ["/root/grpc_health_probe", "-addr=:6666"]
initialDelaySeconds: 2
imagePullPolicy: IfNotPresent
@coin8086
coin8086 / using-proxy-for-git-or-github.md
Last active April 7, 2024 07:40
Use Proxy for Git/GitHub

Use Proxy for Git/GitHub

Generally, the Git proxy configuration depends on the Git Server Protocol you use. And there're two common protocols: SSH and HTTP/HTTPS. Both require a proxy setup already. In the following, I assume a SOCKS5 proxy set up on localhost:1080. But it can also be a HTTP proxy. I'll talk about how to set up a SOCKS5 proxy later.

SSH Protocol

When you do git clone ssh://[user@]server/project.git or git clone [user@]server:project.git, you're using the SSH protocol. You need to configurate your SSH client to use a proxy. Add the following to your SSH config file, say ~/.ssh/config:

ProxyCommand nc -x localhost:1080 %h %p
@Ryanb58
Ryanb58 / install.md
Last active May 17, 2024 13:42
How to install telnet into a alpine docker container. This is useful when using the celery remote debugger in a dev environment.
>>> docker exec -it CONTAINERID /bin/sh
/app # telnet
/bin/sh: telnet: not found

/app # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
v3.7.0-243-gf26e75a186 [http://dl-cdn.alpinelinux.org/alpine/v3.7/main]
v3.7.0-229-g087f28e29d [http://dl-cdn.alpinelinux.org/alpine/v3.7/community]
@wd
wd / config.json
Last active April 17, 2023 08:38
基于 3.8.6 以上 ss 版本的方案
{
"log": {
"loglevel": "none"
},
"inbound": {
"port": 23456,
"listen": "127.0.0.1",
"protocol": "socks",
"settings": {
"udp": true
@lukechilds
lukechilds / get_latest_release.sh
Created August 9, 2016 19:43
Shell - Get latest release from GitHub
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Usage
# $ get_latest_release "creationix/nvm"
# v0.31.4
@nk23x
nk23x / launch-gce-shadowsocks.sh
Created May 2, 2016 08:04 — forked from samos123/launch-gce-shadowsocks.sh
Shadowsocks on GCE automation scripts
#!/bin/bash
machine_type=f1-micro
image=ubuntu-14-04
gcloud compute instances create shadowsocks-1 \
--can-ip-forward --image $image --restart-on-failure \
--zone asia-east1-b --machine-type $machine_type \
--metadata-from-file startup-script=bin/shadowsocks-startup.sh
@zkan
zkan / letsencrypt-auto-renew
Created January 3, 2016 07:24 — forked from neutronth/letsencrypt-auto-renew
Let's Encrypt auto renew script
#/bin/sh
OPTS=$(getopt -o cehw: --long config:,expire-limit:,help,webservice: -n "$0" -- "$@")
if [ $? != 0 ]; then
echo "Terminating ..." >&2
exit 1
fi
CONFIG=/etc/letsencrypt/cli.ini
WEBSERVICE=nginx
@jgatjens
jgatjens / direcory_tag.rb
Created February 10, 2014 22:03
jekyll-plugin loop_directory
#usage:
#{% loop_directory directory:images iterator:image filter:*.jpg sort:descending %}
# <img src="{{ image }}" />
#{% endloop_directory %}
module Jekyll
class LoopDirectoryTag < Liquid::Block
include Liquid::StandardFilters
Syntax = /(#{Liquid::QuotedFragment}+)?/
@pkuczynski
pkuczynski / parse_yaml.sh
Last active May 29, 2024 10:18
Read YAML file from Bash script
#!/bin/sh
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}