Skip to content

Instantly share code, notes, and snippets.

View RichardSilveira's full-sized avatar
🚀

Richard Silveira RichardSilveira

🚀
View GitHub Profile
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using static System.Console;
namespace ThreadPlayground
{
class ReaderWriterLockSlimSample
{
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using static System.Console;
namespace ThreadPlayground
{
class NonExclusiveLockSemaphore
{
#!/bin/bash -xe
## Code Deploy Agent Bootstrap Script##
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
function installdep(){
yum install -y ruby jq
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Resource": "*",
"Action": [
"ec2:RunInstances",
"ec2:CreateTags"
]
@RichardSilveira
RichardSilveira / DeliverVPCFlowLogsPolicy.json
Last active July 2, 2020 10:26
Policy to be attached to a DeliverVPCFlowLogsRole with a Trusted relationship with "vpc-flow-logs.amazonaws.com"
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ec2:DeleteFlowLogs",
"ec2:CreateFlowLogs",
"ec2:DescribeFlowLogs",
"logs:CreateLogGroup",
"logs:CreateLogStream",
CREATE EXTERNAL TABLE IF NOT EXISTS default.vpc_flow_logs (
version int,
account string,
interfaceid string,
sourceaddress string,
destinationaddress string,
sourceport int,
destinationport int,
protocol int,
numpackets int,
ALTER TABLE default.vpc_flow_logs
ADD PARTITION (dt='{Year}-{Month}-{Day}')
location 's3://<vpc-flow-logs-bucket>/AWSLogs/<account_id>/vpcflowlogs/<region>/<Year>/<Month>/<Day>';
SELECT day_of_week(from_iso8601_timestamp(dt)) AS
day,
dt,
interfaceid,
sourceaddress,
destinationport,
action,
protocol
FROM vpc_flow_logs
WHERE action = 'REJECT' AND protocol = 6
@RichardSilveira
RichardSilveira / mariabdbserver-dev.cfn.yaml
Created August 21, 2020 20:32
Easy way to deploy a MariaDB Server based on AWS Marketplace AMI "MariaDB Server 10.3 on AmazonLinux" for DEVELOPMENT ONLY
AWSTemplateFormatVersion: 2010-09-09
Description: |
Deploy a MariaDB Server based on AWS Marketplace AMI "MariaDB Server 10.3 on AmazonLinux" for DEVELOPMENT ONLY
Parameters:
ServerKeyPair:
Type: AWS::EC2::KeyPair::KeyName
Description: Your Amazon EC2 Key Pair.
VPCId:
Type: AWS::EC2::VPC::Id
@RichardSilveira
RichardSilveira / hyperlinkresponse.sample.json
Created September 23, 2020 17:48
Sample response from a random RESTful API with hyperlink
{
"departmentId": 10,
"departmentName": "Administration",
"locationId": 1700,
"managerId": 200,
"links": [
{
"href": "10/employees",
"rel": "employees",
"type" : "GET"