Skip to content

Instantly share code, notes, and snippets.

View JoeShi's full-sized avatar
:octocat:
Build On

Joe Shi JoeShi

:octocat:
Build On
  • Amazon Web Services
  • Shanghai
View GitHub Profile
@JoeShi
JoeShi / setup.sh
Created October 30, 2017 06:07
Create a strong-pm server with one script
#! /bin/bash
# update the yum package
yum update -y
# Install the docker CE on CentOS via the repo
# setup the repo
yum install -y yum-utils device-mapper-persistent-data lvm2
# use the stable version of docker CE
@JoeShi
JoeShi / kms-demo.js
Created October 30, 2018 16:04
KMS demo using node.js
/**
* This is a demo of KMS.
*
* This demo includes the following two features:
* 1. encrypt and decrypt using CMK (Customer Master Key)
* 2. encrypt and decrypt using data key (Envelope encryption using AWS KMS)
*
*/
'use strict';
@JoeShi
JoeShi / sm.js
Created October 30, 2018 16:29
AWS SecretsManager Demo
// Use this code snippet in your app.
// If you need more information about configurations or implementing the sample code, visit the AWS docs:
// https://aws.amazon.com/developers/getting-started/nodejs/
// Load the AWS SDK
var AWS = require('aws-sdk'),
region = "us-west-2",
secretName = "aurora",
secret,
decodedBinarySecret;
#!/bin/bash
# update & install compiler
apt-get update -y
apt-get install gcc -y
apt-get install build-essential -y
# pcre
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.42.tar.gz
tar -zxf pcre-8.42.tar.gz
@JoeShi
JoeShi / ecs-log-to-es.js
Created March 6, 2019 09:32
ECS awslogs to Elasticsearch Lambda
// v1.1.2
var https = require('https');
var zlib = require('zlib');
var crypto = require('crypto');
var endpoint = '<elasticsearch-endpoint-in-your-vpc>'; // use elasticsearch in VPC
// Set this to true if you want to debug why data isn't making it to
// your Elasticsearch cluster. This will enable logging of failed items
// to CloudWatch Logs.
@JoeShi
JoeShi / dynamodb-design-issue.sql
Created April 9, 2019 05:49
dynamodb-design-issue
```SQL
CREATE OR REPLACE STREAM "DESTINATION_SQL_STREAM" ("id" VARCHAR(4), "cp" VARCHAR(64), "ssp" VARCHAR(64), "pub" VARCHAR(64),
"total" INTEGER, "success" INTEGER, "conv" INTEGER,
"error_200" INTEGER, "error_300_ip" INTEGER, "error_300_la" INTEGER, "error_300_rf" INTEGER, "error_300_ua" INTEGER, "error_300_dm" INTEGER, "error_300_wd" INTEGER,
"error_400" INTEGER, "error_600" INTEGER);
CREATE OR REPLACE PUMP "STREAM_PUMP" AS INSERT INTO "DESTINATION_SQL_STREAM"
SELECT STREAM
"id",

创建 HIVE 表

CREATE EXTERNAL TABLE IF NOT EXISTS cloudfront_logs (
  DateObject Date,
  Time STRING,
  Location STRING,
  Bytes INT,
  RequestIP STRING,
  Method STRING,
 Host STRING,
@JoeShi
JoeShi / java-iot-client.md
Created July 19, 2019 09:52
AWS IoT Client JAVA example

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.example.basicapp</groupId>
  <artifactId>myapp</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>