Skip to content

Instantly share code, notes, and snippets.

View clohr's full-sized avatar

Christian Lohr clohr

View GitHub Profile
@clohr
clohr / main.tf
Created February 7, 2022 18:37
Basic Terraform AWS VPC
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "3.7"
}
}
}
provider "aws" {
@clohr
clohr / pycharm-features-for-mac.txt
Created August 30, 2021 13:00
PyCharm Features for Mac
Search
SHIFT+COMMAND+F
Multi-Select
CTRL+G
Navigate Imports
Hold down COMMAND key while hovering over import reference
Show file in Project Tree
@clohr
clohr / find-port.sh
Created January 3, 2020 21:44
Find port in use on mac
sudo lsof -i -n -P | grep $PORT_NUMBER
@clohr
clohr / handle-promise-all.js
Created February 28, 2019 20:37
Guarantee that all responses are returned from Promise.all regardless of error status
const queues = [...LIST_OF_PROMISES]
// this maps over all the queued responses to guarantee that all responses are returned regardless of error status
return Promise.all(queues.map(q => {
return q.catch(err => ({status: err.status}))
}))
@clohr
clohr / capture-events-iframe.html
Created September 15, 2017 16:01
Capture events on an iframe
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style>
* {
box-sizing: border-box;
}
@clohr
clohr / at-mention.js
Last active August 7, 2017 19:35
@ mention pattern matching
const mentions = [
'Al Dufresne',
'Vella Trent',  
'Yolande Casimir',
'Shavonda Hilgendorf',  
'Jamaal Sumner',  
'Alex Tetterton',  
'Adria Shedd',  
'Lindsay Legree',  
'Karey Hedgepeth',  
@clohr
clohr / password-regex.js
Last active May 11, 2017 18:45
Password Regex: at least 1 lowercase letter, 1 uppercase letter, 1 number, 1 symbol, and 8-16 characters in length
const regex = /(?=^.{8,16}$)(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\W])(?!.*\s).*$/g
const str = 'abcDeF#1'
const numMatches = str.match(regex).length
console.log('numMatches', numMatches)
@clohr
clohr / menu-caret.html
Created April 19, 2017 15:16
CSS Menu Carets
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style>
.arrow {
top: 50px;
display: block;
@clohr
clohr / .editorconfig
Created March 11, 2017 19:05
Preferred Editor Config Setup
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
@clohr
clohr / doubly-linked-list.js
Created March 7, 2017 01:05
ES6 Doubly Linked List
class Node {
constructor (value) {
this.data = value
this.previous = null
this.next = null
}
}
class DoublyList {
constructor() {