Skip to content

Instantly share code, notes, and snippets.

@atedja
atedja / resolve-custom-rss.py
Created March 31, 2023 19:23
Manually resolve custom CloudFormation resource
import json
from urllib.request import Request, urlopen
print(f"Copy-paste the JSON received by the custom resource lambda")
line = input()
event = json.loads(line)
r = json.dumps({
'Status': 'SUCCESS',
'Reason': 'Forced',
@atedja
atedja / cloudformation_vpc.yaml
Last active July 31, 2018 06:46
CloudFormation to create a VPC with Public/Private Subnets and SSH/HTTPS Security Groups
AWSTemplateFormatVersion: "2010-09-09"
Resources:
VPC:
Type: "AWS::EC2::VPC"
Properties:
CidrBlock: "10.0.0.0/16"
EnableDnsSupport: true
EnableDnsHostnames: true
InstanceTenancy: default
Tags:
@atedja
atedja / golang-json-stream-decoder
Last active November 2, 2018 10:00
Example of using JSON Stream Decoder from STDIN
package main
import (
"encoding/json"
"fmt"
"os"
)
func main() {
decoder := json.NewDecoder(os.Stdin)
@atedja
atedja / dockerize
Last active July 20, 2018 06:05
Dockerize script that can be used to build and push a Docker image from any Git repo that has a Dockerfile. This script uses the git commit sha as the docker tag.
#!/bin/bash
# dockerize
# Albert Tedja <albert@siliconaxon.com>
# Color stuff
yellow='\e[1;33m'
nc='\e[0m'
color=$yellow
@atedja
atedja / golang-httptest
Last active August 29, 2015 14:12
How to use httptest in Go
import "net/http/httptest"
import "net/http"
type DummyHttp struct {
}
func (d DummyHttp) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
rw.Header().Set("Content-Type", "text/plain")
rw.Write([]byte("Result from Dummy Server"))
}
@atedja
atedja / golang-fanout
Created December 31, 2014 00:35
Fan-out example in Go
package main
import "fmt"
import "bufio"
import "os"
import "strings"
var id int = 0
func WorkerProcess(in <-chan string) {
@atedja
atedja / golang-fanin-fanout
Created December 31, 2014 00:34
Fan-in and Fan-out example in Go
package main
import "fmt"
import "time"
var workerId int = 0
var publisherId int = 0
// Publishers push data into a channel
func Publisher(out chan string) {
@atedja
atedja / golang-http
Created December 31, 2014 00:32
Simple HTTP wrapper in Go
package main
import "net/http"
import "io/ioutil"
import "os"
import "fmt"
import "bytes"
func handleError(e error) {
if e != nil {