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
@chrisguitarguy
chrisguitarguy / upgrade_migrations
Created Oct 9, 2019
Upgrade doctrine/migrations from 1.X to 2.X
View upgrade_migrations
#!/usr/bin/env bash
if [ "$#" != 1 ]; then
echo "Usage: $0 {migrationsDirectory}" >&2
exit 1
fi
find "$1" -type f -name '*.php' -exec sed -i '' 's/Doctrine\\DBAL\\Migrations\\AbstractMigration/Doctrine\\Migrations\\AbstractMigration/' {} \;
find "$1" -type f -name '*.php' -exec sed -i '' 's/function up(Schema \$schema)$/function up(Schema $schema) : void/' {} \;
find "$1" -type f -name '*.php' -exec sed -i '' 's/function down(Schema \$schema)$/function down(Schema $schema) : void/' {} \;
View client_dto_1.php
<?php
class ClientDto
{
public $id;
public $name;
public $site_url;
}
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.
*/
You can’t perform that action at this time.