Skip to content

Instantly share code, notes, and snippets.

View wliao008's full-sized avatar

Wei Liao wliao008

  • Disney Streaming
  • Buffalo, NY
View GitHub Profile
@wliao008
wliao008 / gist:cb0b301da18293c3075d
Created March 26, 2015 13:21
Blinking On-Board LED
int led = D7;
void setup()
{
Spark.function("led", ledControl);
pinMode(led, OUTPUT);
digitalWrite(led, LOW);
}
void loop()
@wliao008
wliao008 / sumosource.go
Last active December 19, 2016 22:04
monitor docker events
package main
import (
"flag"
"fmt"
"os"
"text/template"
"io/ioutil"
dockerapi "github.com/fsouza/go-dockerclient"
{
"family": "<service_name>",
"containerDefinitions": [
{
"name": "<service_name>",
"image": "<image_name>",
"cpu": 1,
"memory": 512,
"links": [],
"portMappings": [
@wliao008
wliao008 / find_unused_launch_configs.txt
Last active June 21, 2017 14:49
Quick (kinda) way to find unused aws launch configurations
1. Get the list of all launch configurations
aws autoscaling describe-launch-configurations
--region us-east-1
--output text
--query 'LaunchConfigurations[*].LaunchConfigurationName' > launch_configs.txt
2. Get the list of in-use launch configurations from auto scaling groups, these are the configurations that are in use.
aws autoscaling describe-auto-scaling-groups
@wliao008
wliao008 / add-item-to-list-dynamodb.go
Created January 15, 2018 03:27
How to add item to a dynamodb list with golang
/*
Took me a while to figure this out, this should never be so difficult IMHO. The dynamodb api could use more examples in its doc.
The documentation for doing this is scattered in a few places:
1. dynamodb api doc for golang: https://docs.aws.amazon.com/sdk-for-go/api/service/dynamodb/
2. the Update Expression: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html
The structs belowed are abbreviated for the sake of the demo: adding a string to the questions slice in the dynamodb table.
@wliao008
wliao008 / upload-package-to-aem.go
Last active April 22, 2021 13:27
upload package to aem server in golang
/*
Packages can be uploaded via CURL as specified in this document:
https://experienceleague.adobe.com/docs/experience-manager-65/administering/operations/curl.html?lang=en#user-management
$ curl -u <user>:<password> -F cmd=upload -F force=true -F [email protected] http://localhost:4502/crx/packmgr/service/.json
This is how it can be done in Golang, please note I've removed all error checking for brevity.
*/
import (