Skip to content

Instantly share code, notes, and snippets.

Christopher Davis chrisguitarguy

Block or report user

Report or block chrisguitarguy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View parser.php
#!/usr/bin/env php
<?php
class Token
{
const T_OPEN_PAREN = 1;
const T_CLOSE_PAREN = 2;
const T_IF = 3;
const T_EQ = 4;
const T_PLUS = 5;
View generate_aws_ses_password.php
<?php
$key = getenv('AWS_SECRET_ACCESS_KEY');
if (!$key) {
throw new \LogicException('Missing AWS_SECRET_ACCESS_KEY');
}
$sig = hash_hmac('sha256', 'SendRawEmail', $key, true);
echo base64_encode(pack('C', 0x02) . $sig), PHP_EOL;
@chrisguitarguy
chrisguitarguy / nginx.conf
Created Feb 22, 2018
How to proxy requests from nginx to an upstream backend. Could be use for Python or JavaScript (express) apps.
View nginx.conf
http {
# other stuff here
# The upstream backend server this can be named whatever you desire
# See http://nginx.org/en/docs/http/ngx_http_upstream_module.html
upstream backend {
# this is the actual hostname + port of the backend server
server backend:8080;
# how many keep alive connections to allow, only set this if you're going
# to specify the `Connection` header in the proxy below, nginx sets the
View Dockerfile
FROM openjdk:9-jre AS build
## Deps to install DynamoDB
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
coreutils \
ca-certificates \
&& mkdir -p /dynamodb/data
WORKDIR /dynamodb
@chrisguitarguy
chrisguitarguy / all_account_policy.json
Last active Jan 17, 2019
Cross Account Redshift UNLOAD/COPY
View all_account_policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowS3",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::{REDSHIFT_ACCOUNT_ID}:root"
},
"Action": [
View example.php
<?php
namespace Some\Library;
interface LibraryException { }
class InvalidArgumentException extends \InvalidArgumentException implements LibraryException
{
// ...
}
View client.dock
FROM ubuntu:16.04
RUN apt-get update -y && apt-get -y install openssh-client
View Json.php
<?php declare(strict_types=1);
/*
* This file is part of pmg/core
*
* Copyright (c) PMG <https://www.pmg.com>.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
View update_dns.py
#!/usr/bin/env python3
import argparse
import http.client as http
import os
import boto3 as aws
def _parse_args(args=None):
p = argparse.ArgumentParser(description='Update a hostname record in route53 with the current IP address')
p.add_argument('zone_id', help='The DNS zone id to update')
@chrisguitarguy
chrisguitarguy / policy.json
Created Aug 18, 2017
deny `PutObject` calls without KMS-based server side encryption.
View policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyUnEncryptedOPutObject",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::BUCKET_NAME/*",
"Condition": {
You can’t perform that action at this time.