Skip to content

Instantly share code, notes, and snippets.

View billyteves's full-sized avatar
💭
I may be slow to respond.

Billy Teves billyteves

💭
I may be slow to respond.
View GitHub Profile
<?php
/**
* Assumes https://github.com/Spomky-Labs/jose library is installed and autoloading is set up
* Decode and verify token guide: https://github.com/Spomky-Labs/jose/blob/master/doc/operation/Verify.md
*/
use Jose\Factory\JWKFactory;
use Jose\Loader;
// We load the key set from a URL
// JSON Key URL (JKU) - https://cognito-idp.{region}.amazonaws.com/{userPoolId}/.well-known/jwks.json.
@billyteves
billyteves / policy.json
Created August 13, 2018 05:48 — forked from koladilip/policy.json
Cognito Identity Pool Authenticated Role Policy to Upload to S3 bucket
{
"Version": "2012–10–17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::<bucket-name>",
"Condition": {
"StringLike": {
<!DOCTYPE html>
<html>
<head>
<title>AWS Cognito + Facebook Login JavaScript Example</title>
<meta charset="UTF-8">
</head>
<body>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.1.41.min.js"></script>
<script>
@billyteves
billyteves / get_s3_file.sh
Created August 3, 2018 03:27 — forked from davidejones/get_s3_file.sh
curl get file from private s3 with iam role
#!/bin/bash
instance_profile=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/`
aws_access_key_id=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep AccessKeyId | cut -d':' -f2 | sed 's/[^0-9A-Z]*//g'`
aws_secret_access_key=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep SecretAccessKey | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'`
token=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | sed -n '/Token/{p;}' | cut -f4 -d'"'`
file="somefile.deb"
bucket="some-bucket-of-mine"
date="`date +'%a, %d %b %Y %H:%M:%S %z'`"
@billyteves
billyteves / aws.conf
Created July 28, 2018 06:14
How to install AWS CloudWatch Logs Agent to send logs from a docker container to AWS Cloudwatch, without using a linked container for logging.
[plugins]
cwlogs = cwlogs
[default]
region = ap-southeast-2
input {
file {
#if you are reading files that syslog-ng has written to.
path => ["/var/log/syslog-ng.log"]
type => "syslog"
tags => [ "network" ]
}
tcp {
#if syslog-ng is relaying to logstash on TCP/514
port => 514
@billyteves
billyteves / config.yml
Created July 23, 2018 01:22 — forked from valdemon/config.yml
Enable ECR (AWS) registries for Spinnaker with Kubernetes provider
# A part of the Halyard config file declaring the ECR registries.
# There can be multiple registries, each in different AWS account.
# In this example there are 3 "stages" accounts - dev, stage & live.
# NOTE: The declared password files must exist and provide valid base64 encoded values,
# otherwise Halayrd will endup with an exception during deployment.
# The values can be fake, they will be updated later by the Kubernetes Job (see 2-nd attached file).
# NOTE: replace ${YOUR_DEV_AWS_ACCOUNT_ID} ${YOUR_DEV_AWS_REGION}
# with appropriate values (same for STAGE & LIVE).
dockerRegistry:

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@billyteves
billyteves / mongodb-s3-backup.sh
Created July 5, 2018 02:57 — forked from eladnava/mongodb-s3-backup.sh
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
@billyteves
billyteves / RELK.sh
Created June 1, 2018 13:55 — forked from adionditsak/RELK.sh
Install the ELK stack (with Redis) with one script for the central log server (CentOS 6.5).
#/bin/bash
##########################################################
### INTRODUCTION
##########################################################
: '
Install and configure R (Redis) + ELK server from scratch on CentOS 6.5.
* Logstash version 1.4.2
* Elasticsearch version 1.3.2