Skip to content

Instantly share code, notes, and snippets.

View weidonglian's full-sized avatar

Weidong Lian weidonglian

View GitHub Profile
@weidonglian
weidonglian / docker-compose.yml
Created October 23, 2022 11:04 — forked from oxlb/docker-compose.yml
cloud-spanner
version: '3'
services:
spanner:
image: gcr.io/cloud-spanner-emulator/emulator:latest
ports:
- "9010:9010"
- "9020:9020"
gcloud-spanner-init:
image: gcr.io/google.com/cloudsdktool/cloud-sdk:latest
@weidonglian
weidonglian / S3-Static-Sites.md
Created June 16, 2022 15:00 — forked from bradwestfall/S3-Static-Sites.md
Use S3 and CloudFront to host Static Single Page Apps (SPAs) with HTTPs and www-redirects. Also covers deployments.

S3 Static Sites

What this will cover

  • Host a static website at S3
  • Redirect www.website.com to website.com
  • Website can be an SPA (requiring all requests to return index.html)
  • Free AWS SSL certs
  • Deployment with CDN invalidation

Resources

//
// Companion code to https://medium.com/statuscode/pipeline-patterns-in-go-a37bb3a7e61d
//
// To run:
// go get github.com/pkg/errors
// go run -race pipeline_demo.go
//
package main
func main() {
s := time.Now()
args := os.Args[1:]
if len(args) != 6 { // for format LogExtractor.exe -f "From Time" -t "To Time" -i "Log file directory location"
fmt.Println("Please give proper command line arguments")
return
}
startTimeArg := args[1]
finishTimeArg := args[3]
@weidonglian
weidonglian / notifyAddrChange.go
Created September 27, 2020 19:07 — forked from KatelynHaworth/notifyAddrChange.go
A simple go program leveraging the Window API to listen for IPv4 network address change events
package main
import (
"log"
"syscall"
"unsafe"
"golang.org/x/sys/windows"
)
struct Connection {
void disconnected()
{
m_connection = Disconnected();
}
void interrupted()
{
m_connection = std::visit(InterruptedEvent(*this), m_connection);
}
@weidonglian
weidonglian / gist:9b48baa9d032f558a490f4993c53c45e
Created August 28, 2018 11:43 — forked from bengolder/gist:2709743
Quick Git Guide [written in markdown]

Git, used along with Github, is a great way to manage the work of writing code. It allows you to collaborate easily on even very large-scale projects, and provides a great place to quickly host code for sharing it with others. If you're going to write significant amounts of code, I highly recommend using it.

Below is a list of commented Git commands in rough order of probable workflow. I use this as a quick reference for using Git. If you happen to want to add comments or questions, I'm making this blog entry into a Github Gist. You can view it here.

git init #start a repo
git add mynewfile.py #track a file
git rm --cached myoldfile.py #untrack a file
git commit -m 'my commit message' #commit changes with a note 
git push -u origin master # push to the 'master' branch on the 'origin' remote

git branch mynewbranch #create a new branch

@weidonglian
weidonglian / greeter_async_server.cc
Created April 7, 2018 19:02 — forked from yang-g/greeter_async_server.cc
grpc async server toy example
// Class encompasing the state and logic needed to serve a request.
class CallDataBase {
public:
// Take in the "service" instance (in this case representing an asynchronous
// server) and the completion queue "cq" used for asynchronous communication
// with the gRPC runtime.
CallDataBase(Greeter::AsyncService* service, ServerCompletionQueue* cq)
: service_(service), cq_(cq), status_(PROCESS) {}
virtual ~CallDataBase() {}
@weidonglian
weidonglian / main.go
Created November 12, 2017 22:38 — forked from nmerouze/main.go
JSON-API with Go and MongoDB: Final Part
package main
import (
"encoding/json"
"log"
"net/http"
"reflect"
"time"
"github.com/gorilla/context"