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"
)
#sudo apt-get update
#sudo apt-get install -y build-essential autoconf libtool git pkg-config curl automake libtool curl make g++ unzip
#sudo apt-get clean
GRPC_RELEASE_TAG=v1.11.x
GRPC_DIR=$(pwd)
cd ${GRPC_DIR}
#git clone -b ${GRPC_RELEASE_TAG} https://github.com/grpc/grpc ${GRPC_DIR} && \
cd ${GRPC_DIR} && \
# git submodule update --init && \
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 / docker
Last active August 7, 2018 21:02
Docker cheat sheet
# Fix the docker sudo issue
sudo usermod -aG docker $USER # Require logout and then login.
@weidonglian
weidonglian / allocator.cpp
Last active July 16, 2018 12:50
C++ Collection
template <class T, class TAlloc>
class FlVecAllocator {
public:
template <typename U>
using rebind = FlVecAllocator<U, TAlloc>;
using value_type = T;
using pointer = value_type *;
FlVecAllocator() noexcept = default;