Skip to content

Instantly share code, notes, and snippets.

View abserari's full-sized avatar
🐱
Let's build a better world

DingRui Yang abserari

🐱
Let's build a better world
View GitHub Profile
@abserari
abserari / Hi Friends.md
Last active August 28, 2020 14:57
Welcome to be my Company
@abserari
abserari / closure.md
Created June 12, 2019 19:30
Good for Code
func (s SqlTokenStore) Save(token *model.Token) store.StoreChannel {
  return store.Do(func(result *store.StoreResult) {
    if result.Err = token.IsValid(); result.Err != nil {
      return
    }
    
    if err := s.GetMaster().Insert(token); err != nil {
      result.Err = model.NewAppError("SqlTokenStore.Save", "store.sql_recover.save.app_error", nil, "", http.StatusInternalServerError)
    }
@abserari
abserari / BitSwap.md
Last active June 17, 2019 13:58
design for IPFS and go code

This allows nodes to keep track of history and avoid tampering.

type Ledger struct {
owner NodeId
partner NodeId
bytes_sent int
bytes_recv int
timestamp Timestamp
}
@abserari
abserari / grpc.go
Created August 17, 2019 15:11
reflect call method grpc method
// CallUnary
// [3]reflect.Value in[0] is context.Context, in[1] is your message type which generated by pb file.
// in[2] is grpc.CallOption
func (c *Client) CallUnary(methodName string,in []reflect.Value)(interface{},error) {
m, ok := reflect.TypeOf(c.c).MethodByName(methodName)
if !ok{
log.Fatal("method not found")
return nil,errors.New("method not found")
}
FROM ubuntu:16.04
# system basics
RUN apt-get update && \
apt-get -y --no-install-recommends install \
build-essential \
curl \
python3 \
python3-dev \
python3-setuptools \
@abserari
abserari / nginx.conf
Created October 12, 2019 15:15
use for nginx proxy my jupyterLab service on my server.
server
{
listen 80;
server_name jupyter.abser.top;
chunked_transfer_encoding on;
location / {
proxy_pass http://127.0.0.1:8888;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_504;
@abserari
abserari / scheduler.go
Created August 30, 2020 07:04
golang schduler by google pubsub
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@abserari
abserari / replication.go
Created September 8, 2020 02:36
minio set bucket replication
package main
import (
"encoding/xml"
"github.com/minio/minio-go/v7/pkg/replication"
"github.com/silverswords/muses.minio/bucketStorage"
"log"
)
func main() {
func echo(wq *waiter.Queue, ep tcpip.Endpoint) {
defer ep.Close()
// Create wait queue entry that notifies a channel.
waitEntry, notifyCh := waiter.NewChannelEntry(nil)
wq.EventRegister(&waitEntry, waiter.EventIn)
defer wq.EventUnregister(&waitEntry)
for {
@abserari
abserari / bytesconv.go
Created November 12, 2020 13:50
Zero-Copy, Fast Convert.
// Copyright 2020 Gin Core Team. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package bytesconv
import (
"reflect"
"unsafe"
)