Skip to content

Instantly share code, notes, and snippets.

@yogeshlonkar
yogeshlonkar / terraform.tf
Created July 9, 2021 15:06
Cheap Static Hosting with AWS and Cloudflare
# other ACM, S3 resources
resource "aws_cloudfront_distribution" "site_distribution" {
enabled = true
is_ipv6_enabled = true
aliases = [var.site_name, "www.${var.site_name}"]
price_class = "PriceClass_100"
default_root_object = "index.html"
# ...
}
@yogeshlonkar
yogeshlonkar / gopls_log
Last active March 22, 2021 12:14
ycm_gopls_issue
[Trace - 17:42:11.817 PM] Sending request 'initialize - (1)'.
Params: {"capabilities":{"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"completion":{"completionItem":{"documentationFormat":["plaintext","markdown"]},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"contentFormat":["plaintext","markdown"]},"signatureHelp":{"signatureInformation":{"documentationFormat":["plaintext","markdown"],"parameterInformation":{"labelOffsetSupport":true}}},"synchronization":{"didSave":true}},"workspace":{"applyEdit":true,"configuration":true,"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"workspaceEdit":{"documentChanges":true}}},"initializationOptions":{"hoverKind":"Structured"},"processId":8
@yogeshlonkar
yogeshlonkar / test.sh
Created February 9, 2020 06:57
AWS Golang monorepo lambdas test.sh
#!/usr/bin/env bash
source ./functions.sh
for func in "${function_dirs[@]}"
do
cd "${BASE_DIR}/${func}"
go test
done
@yogeshlonkar
yogeshlonkar / example_test.go
Created February 9, 2020 06:46
AWS Golang monorepo lambdas example_test.go
package main
import (
"testing"
atl "github.com/yogeshlonkar/aws-lambda-go-test/local"
)
func TestMain(t *testing.T) {
response, err := atl.Run(atl.Input{})
@yogeshlonkar
yogeshlonkar / build.sh
Last active February 10, 2020 18:18
AWS Golang monorepo lambdas build.sh
#!/usr/bin/env bash
source ./functions.sh
# iterate over each package in array, create function and zip it
for func in "${function_dirs[@]}"
do
lambda_func=${func}-function
echo "Generating ${lambda_func} artifact"
# since each lambda directory contains exactly same main.go
@yogeshlonkar
yogeshlonkar / example-main.go
Created February 8, 2020 19:08
AWS Golang monorepo lambdas example-main.go
package main
import (
"github.com/aws/aws-lambda-go/lambda"
"your-repo/handlers"
)
func main() {
lambda.Start(handlers.RequestHandler)
}
@yogeshlonkar
yogeshlonkar / example-handler.go
Last active February 8, 2020 19:07
AWS Golang monorepo lambdas example-handler.go
package handlers
import (
"context"
)
func RequestHandler(ctx context.Context) (string, error) {
return "some-string", nil
}
@yogeshlonkar
yogeshlonkar / Abc.js
Last active July 3, 2019 08:51
Smart ES6 class mock, Create method proxies on module for easier mocking
class Abc {
func1() {
return 'This is function 1'
}
func2() {
return 2;
}
func3() {
return Promise.resolve('three');
}
@yogeshlonkar
yogeshlonkar / signals_for_process.py
Created June 4, 2019 10:49
get all signals being listen by process - credit to https://unix.stackexchange.com/a/85365/48479
import subprocess
ALL_SIGNALS = {}
for sig in range(64):
sig += 1
sig_cmd = "kill -l " + str(sig) + " 2>/dev/null"
ALL_SIGNALS[sig] = subprocess.Popen(sig_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True).communicate()[0].strip()
def getSignals(pid, sigCat):
signal_cmd = "grep \"^" + sigCat + ":\" \"/proc/" + str(pid) + "/status\" | cut -c 9-"