Skip to content

Instantly share code, notes, and snippets.

View wingkwong's full-sized avatar
👁️‍🗨️
Focusing

WK wingkwong

👁️‍🗨️
Focusing
View GitHub Profile
@wingkwong
wingkwong / authHandler.go
Created December 30, 2019 09:13
A Simple Amazon API Gateway Lambda Authoriser in Go
package main
import (
"errors"
"strings"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
jwt "github.com/dgrijalva/jwt-go"
"os"
@wingkwong
wingkwong / Operations.cs
Created January 9, 2020 14:26
Azure Storage CRUD Operations Using C#
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
namespace azure.storage.crud.operations
{
@wingkwong
wingkwong / remove-docker-images-and-containers.sh
Created January 27, 2020 04:17
A script to remove all docker images and containers
#!/bin/bash
docker rm -vf $(docker ps -a -q)
docker rmi -f $(docker images -a -q)
@wingkwong
wingkwong / cobra-info.go
Created February 6, 2020 14:54
Cobra MakeInfo
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
func MakeInfo() *cobra.Command {
@wingkwong
wingkwong / delete-kubernetes-dashboard.sh
Created March 12, 2020 16:19
Delete Kubernetes Dashboard in one go
# kubectl get secret,sa,role,rolebinding,services,deployments --namespace=kube-system | grep dashboard
kubectl delete deployment kubernetes-dashboard --namespace=kube-system
kubectl delete service kubernetes-dashboard --namespace=kube-system
kubectl delete role kubernetes-dashboard-minimal --namespace=kube-system
kubectl delete rolebinding kubernetes-dashboard-minimal --namespace=kube-system
kubectl delete sa kubernetes-dashboard --namespace=kube-system
kubectl delete secret kubernetes-dashboard-certs --namespace=kube-system
kubectl delete secret kubernetes-dashboard-key-holder --namespace=kube-system
@wingkwong
wingkwong / fast-gen-csv-from-oracle-db.sql
Created May 14, 2020 09:59
Fast Generation of CSV from Oracle Database
set markup csv on
set feedback off
set termout off
spool 'EXPORTED_RESULT.csv';
SELECT * FROM FOO_TABLE;
spool off;
@wingkwong
wingkwong / app.js
Created July 26, 2020 14:00
Converting errant callback-based functions to promised-based ones to avoid AWS Lambda execution leaks
exports.handler = async (event, context) => {
const readFileAsync = util.promisify(readFile);
const result = await readFileAsync('foo.json')
return result;
};
@wingkwong
wingkwong / s3-one-bucket-policy.json
Created July 27, 2020 10:36
Grant a user Amazon S3 console access to only a certain bucket
{
"Version":"2012-10-17",
"Statement":[
{
"Effect":"Allow",
"Action":[
"s3:ListBucket"
],
"Resource":"arn:aws:s3:::awsexamplebucket"
},
@wingkwong
wingkwong / merge.sh
Created August 26, 2020 13:40
Merging other repositories to an existing one
git remote add -f foo https://github.com/wingkwong/foo.git
git remote add -f bar https://github.com/wingkwong/bar.git
git remote add -f baz https://github.com/wingkwong/baz.git
git merge foo/master --allow-unrelated-histories
git merge bar/master --allow-unrelated-histories
git merge baz/master --allow-unrelated-histories
@wingkwong
wingkwong / About.md
Last active April 22, 2024 04:58
About.md

Hello World!