Skip to content

Instantly share code, notes, and snippets.

#ifndef __dbg_h__
#define __dbg_h__
#include <stdio.h>
#include <errno.h>
#include <string.h>
#ifdef NDEBUG
#define debug(M, ...)
#else
@stantona
stantona / 0_reuse_code.js
Created March 26, 2014 00:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@stantona
stantona / Pascal's Triangle
Last active August 29, 2015 14:01
I struggled to find a solution for Pascal's triangle in scheme.
(define (pascal-value row elem)
(cond ((= row 1) 1)
((= elem 1) 1)
((= row elem) 1)
(else (+ (pascal-value (- row 1) (- elem 1))
(pascal-value (- row 1) elem)))))
@stantona
stantona / template.yaml
Created February 19, 2020 20:47
Inherit Instance tags
UserData:
Fn::Base64: |
#!/bin/bash
AWS_AVAIL_ZONE="$(curl http://169.254.169.254/latest/meta-data/placement/availability-zone)"
AWS_INSTANCE_ID="$(curl http://169.254.169.254/latest/meta-data/instance-id)"
AWS_REGION="$(echo "${AWS_AVAIL_ZONE}" | sed 's/[a-z]$//')"
VOLUME_IDS="$(aws ec2 describe-instances --region $AWS_REGION --instance-id $AWS_INSTANCE_ID --output text --query Reservations[0].Instances[0].BlockDeviceMappings[*].Ebs.VolumeId)"
for TAG_DEF in $(aws ec2 describe-tags --filter="Name=resource-id,Values=${AWS_INSTANCE_ID}" --region "${AWS_REGION}" | jq .'Tags | .[] | "Name=\(.Key),Value=\(.Value)"'); do
aws ec2 create-tags --dry-run --resources "${VOLUME_IDS//$'\t'/ }" --region "${AWS_REGION}" --tags "${TAG_DEF}"