Skip to content

Instantly share code, notes, and snippets.

Sators sators

View GitHub Profile
@sators
sators / connect.php
Last active Jul 2, 2020
PHP MySQLi Amazon Aurora RDS EC2 IAM Role Based Authentication
View connect.php
<?php
/********* CONFIG ********/
$clusterEndpoint = "";
$clusterPort = 3306;
$clusterRegion = "us-east-1";
$dbUsername = "";
$dbDatabase = "";
/*************************/
@sators
sators / arrayToCsv.js
Last active Jun 22, 2020
Convert Array of Objects to CSV with Javascript
View arrayToCsv.js
/**
* Take an array of objects of similar structure and convert it to a CSV.
* @source https://halistechnology.com/2015/05/28/use-javascript-to-export-your-data-as-csv/
* @modifiedBy sators
* @param {Array} options.data Array of data
* @param {String} options.columnDelimiter Column separator, defaults to ","
* @param {String} options.lineDelimiter Line break, defaults to "\n"
* @return {String} CSV
*/
export default ({data = null, columnDelimiter = ",", lineDelimiter = "\n"}) => {
@sators
sators / Lambda Execution IAM Policy.json
Last active May 17, 2020
Set all App Sync API Key Expiration Dates to 365 Days from <Today> to support Public / Guest APIs
View Lambda Execution IAM Policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"appsync:ListGraphqlApis",
"appsync:ListApiKeys",
"appsync:UpdateApiKey"
],
@sators
sators / join_rabbitmq_cluster.sh
Last active Oct 13, 2018
Bash script to join a rabbitmq cluster of the same AWS autoscaling group
View join_rabbitmq_cluster.sh
#!/bin/bash
wget --quiet http://s3.amazonaws.com/ec2metadata/ec2-metadata
sudo chmod u+x ec2-metadata
INSTANCE_ID=$(./ec2-metadata | grep instance-id | awk 'NR==1{print $2}')
AG_NAME=$(aws autoscaling describe-auto-scaling-instances --instance-ids ${INSTANCE_ID} --query AutoScalingInstances[].AutoScalingGroupName --output text)
echo ===================================
echo Searching for cluster in ${AG_NAME}
echo ===================================
echo Local Instance ID: ${INSTANCE_ID}
for ID in $(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names ${AG_NAME} --query AutoScalingGroups[].Instances[].InstanceId --output text);
@sators
sators / json.php
Created Apr 24, 2015
Output JSON from PHP with proper Content -ype Header
View json.php
<?PHP
$data = /** whatever you're serializing **/;
header('Content-Type: application/json');
echo json_encode($data);
You can’t perform that action at this time.