Skip to content

Instantly share code, notes, and snippets.

@quiver
quiver / retrieve-EC2-region-information-from-metadata.md
Last active March 14, 2024 16:42
retrieve EC2's region from instance metadata

Sometimes you want to retrieve EC2 insntances' region information.

You can query that information through instance metadata(169.254.169.254).

$ curl --silent http://169.254.169.254/latest/dynamic/instance-identity/document
{
  "privateIp" : "172.31.2.15",
  "instanceId" : "i-12341ee8",
  "billingProducts" : null,
 "instanceType" : "t2.small",
@thomasst
thomasst / migrate-redis.py
Created May 14, 2015 18:26
Migrate Redis data on Amazon ElastiCache
"""
Copies all keys from the source Redis host to the destination Redis host.
Useful to migrate Redis instances where commands like SLAVEOF and MIGRATE are
restricted (e.g. on Amazon ElastiCache).
The script scans through the keyspace of the given database number and uses
a pipeline of DUMP and RESTORE commands to migrate the keys.
Requires Redis 2.8.0 or higher.
@polastre
polastre / spawn-sails.js
Created August 20, 2013 23:49
A test snipped of launching sails using spawn, then killing it and waiting for the 'exit event.
var spawn = require('child_process').spawn;
var wrench = require('wrench');
var sailsBin = './node_modules/sails/bin/sails.js';
var _kill = function(sailsServer, cb) {
sailsServer.on('exit', function(code, signal){
cb();
});
sailsServer.kill('SIGINT');
};