Skip to content

Instantly share code, notes, and snippets.

View RohitRox's full-sized avatar
🎯
Focusing

Rohit Joshi RohitRox

🎯
Focusing
View GitHub Profile
@RohitRox
RohitRox / find-ecr-image.sh
Created February 19, 2019 10:27 — forked from outofcoffee/find-ecr-image.sh
Check if Docker image exists with tag in AWS ECR
#!/usr/bin/env bash
# Example:
# ./find-ecr-image.sh foo/bar mytag
if [[ $# -lt 2 ]]; then
echo "Usage: $( basename $0 ) <repository-name> <image-tag>"
exit 1
fi
IMAGE_META="$( aws ecr describe-images --repository-name=$1 --image-ids=imageTag=$2 2> /dev/null )"
@RohitRox
RohitRox / withRegex.go
Last active January 18, 2019 07:57
Golang Templating
package main
import (
"encoding/json"
"fmt"
"regexp"
"strconv"
)
func main() {
@RohitRox
RohitRox / new-relic-go.go
Last active December 20, 2018 15:01
New Relic Go Sample
package main
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
@RohitRox
RohitRox / clean-docker.sh
Created November 25, 2018 19:55 — forked from apmiller108/clean-docker.sh
Bash script to clean up docker
#!/bin/bash
GREEN='\x1B[32m'
RED='\x1B[31m'
NOCOL='\x1B[39m'
echo "${GREEN}Removing exited containers${NOCOL}"
docker rm -v $(docker ps --filter status=dead --filter status=exited -aq)
echo "${GREEN}Removing dangling images${NOCOL}"
docker rmi $(docker images -f "dangling=true" -q)
@RohitRox
RohitRox / iaas.config.md
Last active November 21, 2018 14:11
IaaC code organization
Infrastructure-base
  |- foundation-roles/
  |- resources/
  | |- cloudtrail.yaml
  | |- s3.yaml
  |- vpc/
  | |- vpc-complete.yaml
  |- logging/
 | |- functions
@RohitRox
RohitRox / lambda-in-vpc.yaml
Created October 9, 2018 09:36
AWS Lambda in VPC with NAT
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Sample SAM Template for AWS lambda in vpc
Resources:
NatEIP:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
@RohitRox
RohitRox / attached_validator.rb
Created September 23, 2018 23:24 — forked from carlosramireziii/attached_validator.rb
A validator and RSpec matcher for requiring an attachment using Active Storage
class AttachedValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, :attached, options) unless value.attached?
end
end
@RohitRox
RohitRox / hello_cloudformation.yml
Last active September 20, 2018 14:32
Hello World Cloudformation Template
AWSTemplateFormatVersion: 2010-09-09
Description: Deploys a basic httpd hello world app in an EC2 instance, create and attach a security group for the instance
Mappings:
Infra:
Vpcs:
Main: vpc-xxxx
Subnets:
Public:
@RohitRox
RohitRox / newrelic.config
Created June 27, 2017 17:07
NewRelic for Server ebextension config with instance environment and id
packages:
yum:
newrelic-sysmond: []
rpm:
newrelic: http://yum.newrelic.com/pub/newrelic/el5/x86_64/newrelic-repo-5-3.noarch.rpm
commands:
"01":
command: nrsysmond-config --set license_key=LICENSE_KEY
"02":
command: echo hostname=`aws ec2 describe-tags --filters "Name=resource-id,Values=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)" "Name=key,Values=elasticbeanstalk:environment-name" --region=$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r .region) --output=json | jq -r '.Tags[0].Value +"-"+ .Tags[0].ResourceId'` >> /etc/newrelic/nrsysmond.cfg
@RohitRox
RohitRox / webp.modernizr.js
Created June 12, 2017 21:25
Minimal webp support check addition to Modernizr
(function (document) {
'use strict';
var webpImg = new Image();
webpImg.onerror = function() {
setModernizr(false);
}
webpImg.onload = function(){
var root = document.getElementsByTagName('html')[0];
if (root.classList) {