This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __dbg_h__ | |
#define __dbg_h__ | |
#include <stdio.h> | |
#include <errno.h> | |
#include <string.h> | |
#ifdef NDEBUG | |
#define debug(M, ...) | |
#else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __dbg_h__ | |
#define __dbg_h__ | |
#include <stdio.h> | |
#include <errno.h> | |
#include <string.h> | |
#ifdef NDEBUG | |
#define debug(M, ...) | |
#else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __dbg_h__ | |
#define __dbg_h__ | |
#include <stdio.h> | |
#include <errno.h> | |
#include <string.h> | |
#ifdef NDEBUG | |
#define debug(M, ...) | |
#else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <errno.h> | |
void die(const char *message) | |
{ | |
if(errno) { | |
perror(message); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <assert.h> | |
#include <stdlib.h> | |
#include <errno.h> | |
#include <string.h> | |
#define MAX_DATA 512 | |
#define MAX_ROWS 100 | |
struct Address { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(process_exc). | |
-export([start/1, proc/1]). | |
start(M) -> | |
N1 = spawn(process_exc, proc, [M]), | |
N2 = spawn(process_exc, proc, [M]), | |
N1 ! {N2, ping}. | |
proc(M) -> | |
proc(M, 0). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(ring). | |
-export([start/2, forward_to/1]). | |
start(Number, Iterations) -> | |
Pid = create_processes(Number-1), | |
Pid ! msg, | |
forward_to(Pid, Iterations, 0). | |
create_processes(Number) -> | |
io:format("spawning ~p processes...~n", [Number]), |
NewerOlder