Skip to content

Instantly share code, notes, and snippets.

View arledesma's full-sized avatar
🐛
I may be slow to respond

Anthony Ledesma arledesma

🐛
I may be slow to respond
View GitHub Profile
@zerolagtime
zerolagtime / internal_envsubst.sh
Created June 1, 2020 20:01
envsubst in pure bash/sed
#!/bin/bash
# this is a poor man's substitute for the envsubst command
function internal_envsubst() {
tfile=$(mktemp)
# use sed to build a sed input file specific to the current environment variables
env | sed -E -e '
# delete any special cases that make a mess of things
/^_=/d;
# deal with variables that have backslashes in them: \\tsclient\home
@zachboyd
zachboyd / AWSSubscriptionClient.ts
Last active September 22, 2022 15:09
Appsync Subscription support for subscriptions-transport-ws
import { uniqBy } from 'lodash';
import { ClientOptions, SubscriptionClient } from 'subscriptions-transport-ws';
export class AWSSubscriptionClient extends SubscriptionClient {
constructor(
url: string,
options?: ClientOptions,
webSocketImpl?: any,
webSocketProtocols?: string | string[]
) {
@arledesma
arledesma / allocate-shard.sh
Last active July 28, 2017 00:33
ES scripts
#!/bin/bash
if [ -n "$1" ]; then index=$1; fi
if [ -n "$2" ]; then shard=$2; fi
if [ -n "$3" ]; then targetNode=$3; fi
curl -u es_admin:$ESPASS -sS -XPOST 'localhost:9200/_cluster/reroute' -d "{
\"commands\" : [ {
\"allocate\" : {
\"index\" : \"${index}\",
@kwilczynski
kwilczynski / tags.tf
Last active March 21, 2021 20:21
Terraform hack to set tags on a spot instance
// This is to solve issue with tags creation for spot instances,
// see: https://github.com/hashicorp/terraform/issues/3263
resource "null_resource" "module" {
triggers {
spot_instance_id = "${aws_spot_instance_request.module.spot_instance_id}"
}
provisioner "local-exec" {
command = "AWS_ACCESS_KEY_ID=${var.access_key} AWS_SECRET_ACCESS_KEY=${var.secret_key} aws ec2 create-tags --color=off --region ${var.region} --resources ${aws_spot_instance_request.module.spot_instance_id} --tags Key=Name,Value=${format("%s-%s-grafana-instance", var.stack, var.environment)} Key=Stack,Value=${var.stack} Key=Environment,Value=${var.environment} Key=Version,Value=${var.version} Key=Role,Value=${var.role}"
}
@alessonforposterity
alessonforposterity / drgn.txt
Created April 12, 2015 04:43
Abandon all hope, ye who enter here
This file has been truncated, but you can view the full file.
//Dr. Seuss once wrote, "IF." He meant, "If you give a fuck, maybe,
//JUST MAYBE, you can change this shitty world in some small way for
//the better." I might've been an writer of children's books someday,
//but instead, I decided to make this. So in lieu of The Lorax,
//let's call this The Dragon, and have my word be, "DON'T." As in,
//"Don't do something stupid like this the way I did, you jackass."
//But the truth is humans are very stubborn creatures. You probably
//won't listen to my advice and, chances are, neither will I.