Skip to content

Instantly share code, notes, and snippets.

View adamcrosby's full-sized avatar
💭
alert();

Adam Crosby adamcrosby

💭
alert();
View GitHub Profile
@adamcrosby
adamcrosby / vip_mon.sh
Created September 20, 2014 22:37
AWS VIP Monitor/takeover script
#!/bin/sh
# This script will monitor another HA node and take over a Virtual IP (VIP)
# if communication with the other node fails
# High Availability IP variables
# Other node's IP to ping and VIP to swap if other node goes down
HA_Node_IP=
VIP=
# Specify the EC2 region that this will be running in
#!/usr/bin/env python
def ip2int(ip):
(f,s,t,l)=ip.split('.')
return (int(f)*16777216)+(int(s)*65536)+(int(t)*256)+int(l)
def ipInNet(ip, network, masklength):
mask = 0xFFFFFFFF << (32 - int(masklength))
if (ip2int(ip) & mask) == (ip2int(network) & mask):
return True
@adamcrosby
adamcrosby / nginx.conf
Last active November 17, 2016 13:31 — forked from hewittc/elektronring.conf
NGinx Config to Make TLS Great Again
server {
listen [::]:80 ipv6only=off;
server_name domain.com www.domain.com;
rewrite ^ https://$host$request_uri permanent;
}
server {
listen [::]:443 ipv6only=off default_server ssl;
server_name domain.com www.domain.com;
@adamcrosby
adamcrosby / markdown_to_pdf.sh
Created November 8, 2020 22:16
use Eisvogel Pandoc Latex template and TexLive to create good looking PDF from Markdown source
tlmgr init-usertree
tlmgr install adjustbox
tlmgr update —self
sudo tlmgr option repository ftp://tug.org/historic/systems/texlive/2018/tlnet-final
tlmgr option repository ftp://tug.org/historic/systems/texlive/2018/tlnet-final
tlmgr install adjustbox
git clone https://github.com/Wandmalfarbe/pandoc-latex-template.git
pandoc lol.md -o adam.pdf —from markdown —template eisvogel —highlight-style pygments —toc
@adamcrosby
adamcrosby / Yubikey setup for macos notes.md
Created November 8, 2020 22:22
Yubikey setup quick guide

yubikey setup

gpg --card-status

gpg --card-edit

admin key-attr Set to RSA 4096 for all 3 keys

@adamcrosby
adamcrosby / names.py
Last active December 17, 2020 20:19
Common first/last names
#!/usr/bin/env python
import random
NUMBER_OF_USERS = 25
PASSWORD_LENGTH = 18
first_names=["James","Mary","John","Patricia","Robert","Jennifer","Michael","Linda","William","Elizabeth","David","Barbara","Richard","Susan","Joseph","Jessica","Thomas","Sarah","Charles","Karen","Christopher","Nancy","Daniel","Lisa","Matthew","Margaret","Anthony","Betty","Donald","Sandra","Mark","Ashley","Paul","Dorothy","Steven","Kimberly","Andrew","Emily","Kenneth","Donna","Joshua","Michelle","Kevin","Carol","Brian","Amanda","George","Melissa","Edward","Deborah","Ronald","Stephanie","Timothy","Rebecca","Jason","Laura","Jeffrey","Sharon","Ryan","Cynthia","Jacob","Kathleen","Gary","Amy","Nicholas","Shirley","Eric","Angela","Jonathan","Helen","Stephen","Anna","Larry","Brenda","Justin","Pamela","Scott","Nicole","Brandon","Samantha","Benjamin","Katherine","Samuel","Emma","Frank","Ruth","Gregory","Christine","Raymond","Catherine","Alexander","Debra","Patrick","Rachel","Jack","Carolyn","Dennis","Janet","Jerry","Virginia","Tyler","Maria

Getting linux up with vnc from macOS:

Launch a Ubuntu 20.04 LTS Server as an EC2 instance, and ensure you have a security group that allows you to access it via SSH (and SSH only, you'll be using SSH to port tunnel VNC).

Once you've got the instance up, and have ssh'd in, run the following to install the packages necessary for a basic desktop environment (not included by default in the Ubuntu server install on AWS).

sudo update
sudo apt install ubuntu-desktop
sudo apt install tightvncserver
@adamcrosby
adamcrosby / speedtest.sh
Created June 5, 2022 01:40
Curl Speedtest
#!/bin/bash
curl -w @- -o /dev/null -s "$@" <<'EOF'
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
@adamcrosby
adamcrosby / ec2_config_id_from_name_tag.sql
Created July 14, 2022 16:46
Get EC2 instance ID from a 'Name' tag
SELECT
resourceId,
resourceName,
resourceType,
configuration.instanceType,
tags,
availabilityZone,
configuration.state.name
WHERE
resourceType = 'AWS::EC2::Instance'