Skip to content

Instantly share code, notes, and snippets.

View jiamaozheng's full-sized avatar

Jiamao Zheng jiamaozheng

View GitHub Profile
@steinsag
steinsag / s3BucketPolicyEncryptionSSL.json
Created June 11, 2014 12:03
S3 bucket policy to enforce encryption and https:// access
{
"Version": "2008-10-17",
"Id": "Policy-GENERATED-ID",
"Statement": [
{
"Sid": "DenyUnSecureCommunications",
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
@djhocking
djhocking / dplyr-select-names.R
Last active February 28, 2022 19:08
Select columns by vector of names using dplyr
one <- seq(1:10)
two <- rnorm(10)
three <- runif(10, 1, 2)
four <- -10:-1
df <- data.frame(one, two, three)
df2 <- data.frame(one, two, three, four)
str(df)
@dcloud9
dcloud9 / EC2-StackPolicy-for-Updates
Last active June 6, 2018 19:08
Secure your stack from accidental deletion of resources like EC2 instance. Enable and Disable stack policy during updates.
#! /bin/bash -e
#-----
# Pre-reqs: AWSCLI tool (python, pip) installed and configured. -DC 28.1.15
# v1.1: Added parameter/value checks. -DC 23.2.15
#-----
StackName=$1
Profile=$3
Creds=$HOME/.aws/credentials
[ $# -lt 3 ] && (echo "Usage: $0 <stack-name> {on|off} <profile>"; exit 1)
@colinvh
colinvh / aws.md
Last active July 1, 2025 13:43
AWS Region Names

Alternative naming schemes for AWS regions

Purpose

The intent is to define terse, standards-supported names for AWS regions.

Schemes

@nbremer
nbremer / .block
Last active July 10, 2025 15:06
Radar Chart Redesign
height: 600
license: mit
acknowledgement: Please add "Nadieh Bremer | Visual Cinnamon" to your credit when re-using this code, thank you!
@mlapida
mlapida / EC2-Stopped-Tagged-Lambda.py
Last active May 29, 2024 06:00
Using a lambda function, stop all instances that are tagged appropriately.
import boto3
import logging
#setup simple logging for INFO
logger = logging.getLogger()
logger.setLevel(logging.INFO)
#define the connection
ec2 = boto3.resource('ec2')
@iconara
iconara / queries.sql
Last active November 13, 2023 22:26
Low level Redshift cheat sheet
-- Table information like sortkeys, unsorted percentage
-- see http://docs.aws.amazon.com/redshift/latest/dg/r_SVV_TABLE_INFO.html
SELECT * FROM svv_table_info;
-- Table sizes in GB
SELECT t.name, COUNT(tbl) / 1000.0 AS gb
FROM (
SELECT DISTINCT datname, id, name
FROM stv_tbl_perm
JOIN pg_database ON pg_database.oid = db_id
@JCotton1123
JCotton1123 / fetchenv.sh
Created June 9, 2016 20:38
Export env variables for each AWS CloudFormation stack output
#!/bin/bash
# This script will find all AWS CloudFormation stacks matching the supplied filter
# and export the outputs into environment variables.
#
# This script is assumed to be run on a host with an IAM profile matching the following:
#
# {
# "Version": "2012-10-17",
# "Statement": [
@so0k
so0k / kubectl.md
Last active February 4, 2025 17:16
Playing with kubectl output

Kubectl output options

Let's look at some basic kubectl output options.

Our intention is to list nodes (with their AWS InstanceId) and Pods (sorted by node).

We can start with:

kubectl get no