Skip to content

Instantly share code, notes, and snippets.

View quiver's full-sized avatar

George Yoshida quiver

View GitHub Profile
@quiver
quiver / lambda.py
Created December 15, 2015 17:16
Store SORACOM Air traffic to Elasticsearch Raw
# API https://dev.soracom.io/jp/docs/api/#!/Stats/get_stats_air_subscriber
"""
AWS Lambda function to retrieve traffic data from SORACOM and store them to Elasticsearch
"""
import datetime
import json
import requests
SORACOM_EMAIL="dummy@example.com"
@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",
@quiver
quiver / create-stack.dot
Created August 17, 2015 15:30
AWS cloudformation StackStatus
/*
* http://www.graphviz.org/
* $ dot -Tpng test.dot -o test.png
* rollback can be disabled
*/
digraph create_stack {
CreateStack_API [shape=box];
DeleteStack_API[shape=box];
CREATE_COMPLETE [style=filled,color=blue]; // OK
CREATE_FAILED [style=filled,color=red]; // NG
@quiver
quiver / waiters-2.json
Created June 1, 2015 01:44
aws cli machinelearning waiter
{
"version": 2,
"waiters": {
"DataSourceAvailable": {
"delay": 30,
"operation": "GetDataSource",
"maxAttempts": 60,
"acceptors": [
{
"expected": "COMPLETED",
@quiver
quiver / .screenrc
Created July 5, 2014 02:33
screen conf
escape ^Z^\
vbell off
# don't show startup messages
startup_message off
# detach on hangup - if my dial-up session fails, screen will simply
# detach and let me re re-attach later.
autodetach on
@quiver
quiver / copy.sql
Created April 19, 2014 09:45
redshift_cstore_fdw
copy users from '/tmp/s3/allusers_pipe.txt' with null as '' delimiter '|';
copy venue from '/tmp/s3/venue_pipe.txt' delimiter '|';
copy category from '/tmp/s3/category_pipe.txt' with null as '' delimiter '|';
copy date from '/tmp/s3/date2008_pipe.txt' with null as '' delimiter '|';
copy event from '/tmp/s3/allevents_pipe.txt' with null as '' delimiter '|';
copy listing from '/tmp/s3/listings_pipe.txt' with null as '' delimiter '|';
copy sales from '/tmp/s3/sales_tab.txt' with null as '' delimiter '\t';
copy users from '/tmp/s3/allusers_pipe.txt' with null as '' delimiter '|';
copy venue from '/tmp/s3/venue_pipe.txt' delimiter '|';
copy category from '/tmp/s3/category_pipe.txt' with null as '' delimiter '|';
copy date from '/tmp/s3/date2008_pipe.txt' with null as '' delimiter '|';
copy event from '/tmp/s3/allevents_pipe.txt' with null as '' delimiter '|';
copy listing from '/tmp/s3/listings_pipe.txt' with null as '' delimiter '|';
copy sales from '/tmp/s3/sales_tab.txt' with null as '' delimiter '\t';
create table users(
userid integer not null,
username char(8),
firstname varchar(30),
lastname varchar(30),
city varchar(30),
state char(2),
email varchar(100),
phone char(14),
likesports boolean,
CREATE EXTENSION cstore_fdw;
CREATE SERVER cstore_server FOREIGN DATA WRAPPER cstore_fdw;
create foreign table users(
userid integer not null,
username char(8),
firstname varchar(30),
lastname varchar(30),
city varchar(30),
@quiver
quiver / create_dlq.py
Last active September 10, 2018 23:41
aws sqs dead letter queue sample(w/ boto)
# vim: set fileencoding=utf8
# http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/SQSDeadLetterQueue.html
# http://aws.typepad.com/aws/2014/01/amazon-sqs-new-dead-letter-queue.html
import json
import boto
from pprint import pprint
conn = boto.connect_sqs()
q1 = conn.create_queue('test_q1')