Skip to content

Instantly share code, notes, and snippets.

View ryan0x44's full-sized avatar

Ryan D ryan0x44

View GitHub Profile
@ryan0x44
ryan0x44 / node-via-docker-run.md
Created July 9, 2018 02:43
Node/NPM/Yarn via Docker Run

To start a bash prompt with only Docker installed on your host OS, run the following command:

docker run --rm -v $PWD:/src -w /src -u node -it node /bin/bash

Here's what each parameter does:

  • --rm removes the container once you exit
  • -v $PWD:/src will mount your current host working directory into /src inside the container
@ryan0x44
ryan0x44 / get-docker-image-cmd.sh
Created March 20, 2018 20:19
Get Docker Image CMD
#!/bin/bash -e
# Using the "hello-world" image as an example
# https://github.com/docker-library/hello-world/blob/c83a065a24e94e635ddd518c2a3cffc91accf30d/amd64/hello-world/Dockerfile#L3
# `CMD ["/hello"]`
docker pull hello-world
docker inspect -f "{{.Config.Cmd}}" hello-world | cut -f2 -d "[" | cut -f1 -d "]"
# produces: `/hello`
@ryan0x44
ryan0x44 / markdown-chrome-preview.sh
Created February 27, 2018 22:14
Preview Markdown in Chrome
MD_FILE="README.md"
TMP_FILE=$(mktemp); pandoc $MD_FILE > $TMP_FILE; open -a "Google Chrome" $TMP_FILE && rm $TMP_FILE
@ryan0x44
ryan0x44 / pwnedpasswordcount.sh
Created February 24, 2018 05:47
Find out how many times your password has been pwned
#!/bin/bash
# set pw to the password you want to lookup (of course, be careful with writing this to your shell history or unencrypted disk!)
pw="insecure"
# this will output the number of times it has been pwned
s=$(echo -n $pw | openssl sha1 | tr '[a-z]' '[A-Z]'); curl -s "https://api.pwnedpasswords.com/range/${s:0:5}" | grep "${s:5}" | cut -d ":" -f 2
@ryan0x44
ryan0x44 / sentry_event.sh
Created November 28, 2017 07:34
Send events to Sentry from bash
#!/bin/bash -e
# sentry_event params: [event_id] [culprit] [message] [optional:extra]
sentry_event() {
# Get current unix timestamp
TIMESTAMP=`date +%s`
# Parse DSN
TEMP=`echo $SENTRY_DSN | cut -d '/' -f3`
@ryan0x44
ryan0x44 / Example1.java
Last active April 5, 2023 12:43
Java Checkstyle Cyclomatic Complexity Example
public class Example1 {
public static void main(String[] args) {
int a = 0;
if (a >= 0) {
System.out.println(">= 0");
if (a != 0) {
System.out.println("!= 0");
}
} else {
System.out.println("< 0");

Keybase proof

I hereby claim:

  • I am ryan0x44 on github.
  • I am ryan0x44 (https://keybase.io/ryan0x44) on keybase.
  • I have a public key ASCsZYdRwGWRK1gYhgSx3v1G8iOsgDazCUh6pM8ePLDifwo

To claim this, I am signing this object:

@ryan0x44
ryan0x44 / Terraform-Blue-Green-AWS.md
Created November 19, 2015 21:57
Blue-Green AWS Auto Scaling Deployments with Terraform

A quick note on how I'm currently handling Blue/Green or A/B deployments with Terraform and AWS EC2 Auto Scaling.

In my particular use case, I want to be able to inspect an AMI deployment manually before disabling the previous deployment.

Hopefully someone finds this useful, and if you have and feedback please leave a comment or email me.

Overview

I build my AMI's using Packer and Ansible.