Skip to content

Instantly share code, notes, and snippets.

:octocat:
I may be slow to respond.

Darkness navono

:octocat:
I may be slow to respond.
Block or report user

Report or block navono

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View convertion.js
function Uint8ArrayToString(fileData){
var dataString = "";
for (var i = 0; i < fileData.length; i++) {
dataString += String.fromCharCode(fileData[i]);
}
return dataString
}
@navono
navono / protobufjs
Created Jun 21, 2019
Load proto(with third party proto files) with protobufjs
View protobufjs
const root = new protobuf.Root();
root.resolvePath = function(origin, target) {
if (origin.length === 0) {
return target;
}
if (target.startsWith('are')) {
const protoPath = path.resolve(__dirname, '../', target)
console.log('path: ', protoPath);
@navono
navono / gracefulStop.go
Created Jun 18, 2019
Golang graceful stop
View gracefulStop.go
package main
import (
"os"
"os/signal"
"syscall"
"fmt"
"time"
"net/http"
)
func main() {
@navono
navono / protoc.sh
Last active Jun 13, 2019
proto shell 编译脚本
View protoc.sh
#! /bin/bash
# test.sh
PROTOC_GEN_TS_PATH=$(pwd)/node_modules/.bin/protoc-gen-ts.cmd
# Directory to write generated code to
OUT_DIR="./generated"
JS_DIR=$OUT_DIR/js
GO_DIR=$OUT_DIR/go
SWAGGER_DIR=$OUT_DIR/swagger
@navono
navono / protoc.cmd
Last active Jun 20, 2019
使用 batch 编译 proto 文件
View protoc.cmd
@ECHO OFF
REM 声明采用UTF-8编码
chcp 65001
echo "请先安装 Golang 和 protoc,然后安装 protoc 插件"
REM plugin binary path
set PROTOC_GEN_TS_PATH=%cd%\\bin\\node_modules\\.bin\\protoc-gen-ts.cmd
set PROTOC_GEN_GRPC_PATH=%cd%\\bin\\grpc_cpp_plugin.exe
set PROTOC_GEN_LINT_PATH=%cd%\\bin\\protoc-gen-lint.exe
@navono
navono / prefix.sh
Created Jun 12, 2019
add prefix string in list
View prefix.sh
MYLIST=(var1 var2 var3)
echo ${MYLIST[@]/#/my_}
# Output: my_var1 my_var2 my_var3
DATABASE="database1"
IGNORE_TABLES=(table1 table2 table3)
echo mysqldump ${IGNORE_TABLES[@]/#/--ignore-table=${DATABASE}.} ${DATABASE}
# Output: mysqldump --ignore-table=database1.table1 --ignore-table=database1.table2 --ignore-table=database1.table3 database1
@navono
navono / file.sh
Created Jun 11, 2019
extract file name related info
View file.sh
#!/bin/bash
fullfilename=$1
filename=$(basename "$fullfilename")
fname="${filename%.*}"
ext="${filename##*.}"
echo "Input File: $fullfilename"
echo "Filename without Path: $filename"
echo "Filename without Extension: $fname"
@navono
navono / Dockerfile
Created May 22, 2019
create image that compile proto files
View Dockerfile
FROM ubuntu:latest
RUN apt-get update && apt-get install -y \
automake \
build-essential \
git \
libtool \
make \
npm \
wget \
@navono
navono / protoc-gen-cpp.sh
Created May 22, 2019
create cpp output with protoc
View protoc-gen-cpp.sh
protoc -Iapi/proto/v1 -Ithird_party --grpc-cpp_out=cmd/client-rest-cpp/api/v1 --cpp_out=cmd/client-rest-cpp/api/v1 --plugin=protoc-gen-grpc-cpp="C:\\Program Files (x86)\\grpc\\bin\\grpc_cpp_plugin.exe" todo-service.proto
protoc -Ithird_party --plugin=protoc-gen-grpc-cpp="C:\\Program Files (x86)\\grpc\\bin\\grpc_cpp_plugin.exe" --cpp_out=cmd/client-rest-cpp/api/v1 third_party/google/api/annotations.proto
protoc -Ithird_party --plugin=protoc-gen-grpc-cpp="C:\\Program Files (x86)\\grpc\\bin\\grpc_cpp_plugin.exe" --cpp_out=cmd/client-rest-cpp/api/v1 third_party/google/api/http.proto
protoc -Ithird_party --plugin=protoc-gen-grpc-cpp="C:\\Program Files (x86)\\grpc\\bin\\grpc_cpp_plugin.exe" --cpp_out=cmd/client-rest-cpp/api/v1 third_party/protoc-gen-swagger/options/annotations.proto
protoc -Ithird_party --plugin=protoc-gen-grpc-cpp="C:\\Program Files (x86)\\grpc\\bin\\grpc_cpp_plugin.exe" --cpp_out=cmd/client-rest-cpp/api/v1 third_party/protoc-gen-swagger/options/openapiv2.proto
@navono
navono / jsonParser.sh
Created May 21, 2019
parse json with jq in shell
View jsonParser.sh
// {
// "sync": true,
// "machines": [
// {
// "name": "1911-1",
// "address": "192.168.1.14",
// "user": "administrator",
// "passwd": "supcon_1",
// "path": "C:\\AppDev"
// },
You can’t perform that action at this time.