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 / pandoc-podman.md
Created January 27, 2023 21:05
Pandoc MD to PDF/DOCX docker oneliner

podman run --rm --volume "$(pwd):/data" --userns keep-id --user $(id -u):$(id -g) pandoc/latex readme.md -o outfile.pdf

--volume "$(pwd):/data" maps the current directory $(pwd) to the /data volume in the running container.

--userns keep-id --user $(id -u):$(id -g)is a rootless Podman specific user namespace mapping fix, so the output file can be written to the primary filesystem.

pandoc/latex is the dockerhub image of pandoc with the pdf2latex toolset installed.

@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'
@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

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 / 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
@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 / 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 / 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;
#!/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