Skip to content

Instantly share code, notes, and snippets.

View kgriffs's full-sized avatar

Kurt Griffiths kgriffs

View GitHub Profile
@kgriffs
kgriffs / nginx.conf
Created March 11, 2020 17:23
NGINX Dynamic Proxy Example (Kik)
# Credit: https://www.kik.com/blog/using-lua-to-extend-nginx-configuration/
worker_processes auto; # process per cpu
worker_rlimit_nofile 8192;
events {
worker_connections 65536;
}
http {
# https://t37.net/nginx-optimization-understanding-sendfile-tcp_nodelay-and-tcp_nopush.html
@kgriffs
kgriffs / falcon-asgi-ws-interface.py
Last active April 30, 2023 11:20
Falcon ASGI+WebSocket Interface Proposal (By Example)
# See also:
#
# * https://asgi.readthedocs.io/en/latest/specs/www.html#websocket
# * https://developer.mozilla.org/en-US/docs/Web/API/Websockets_API
#
import falcon.asgi
import falcon.media
@kgriffs
kgriffs / unused.py
Created January 20, 2020 22:47 — forked from jmvrbanac/unused.py
Get Unused Port
def get_unused_port():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('localhost', 0))
_, port = sock.getsockname()
sock.close()
return port
@kgriffs
kgriffs / _ssl_util.py
Last active April 8, 2021 01:18
Validate a server's certificate in Python 3 using only the standard library + certifi
import datetime
from enum import Enum
import socket
import ssl
import certifi
class CertificateStatus(Enum):
UNKNOWN = -1
@kgriffs
kgriffs / scroll.js
Last active November 5, 2019 19:14
Scroll to bottom of page using vanilla JS to trigger lazy loading
const scrollingElement = document.scrollingElement
const viewport_height = scrollingElement.clientHeight
for (let pos = 0; pos < scrollingElement.scrollHeight; pos += viewport_height) {
scrollBy(0, viewport_height)
}
@kgriffs
kgriffs / gcp_ips.sh
Last active October 15, 2019 17:17 — forked from vulkoingim/gcp_ips.sh
Get GCP Public IP Ranges
#!/usr/bin/env bash
# This script lists all ip ranges currently used by
# the google cloud platform, according to ns-lookup / dig
# TXT _cloud-netblocks.googleusercontent.com
#
# https://cloud.google.com/compute/docs/faq#find_ip_range
errcho() {
>&2 echo "$@"
@kgriffs
kgriffs / falcon-3.0-roadmap.md
Last active May 10, 2021 22:23
Falcon 3.0 Roadmap

Falcon 3.0 Roadmap

3.0.0a1

  • Review/Merge the ASGI implementation - PR #1573
  • Review/Merge native form parsing (WSGI only) - PR #1549
  • Fix doc formatting issue (see also comment on PR #1566)
  • Get tests to pass on Windows
  • Add windows gate to Travis CI
@kgriffs
kgriffs / falcon_parse_multipart_example.py
Created July 24, 2019 19:14
Falcon: Multipart form parsing example
import cgi
# NOTE: This does not handle file uploads
def parse_form(req):
# NOTE: See also the docs for cgi.FieldStorage
form = cgi.FieldStorage(fp=req.stream, environ=req.env,
keep_blank_values=1)
if not form.list:
return {}
@kgriffs
kgriffs / upgrade-kernel.yml
Created July 23, 2019 19:57
Ansible - Upgrade CentOS 7 Kernel
- name: Add ELRepo
yum:
name: https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
state: latest
- name: Install latest mainline kernel
yum:
name: kernel-ml
state: latest
enablerepo: elrepo-kernel
- name: Remake grub config to pick up new kernel
@kgriffs
kgriffs / restart.yml
Created July 23, 2019 19:53
Ansible - Restart Server and Wait
- name: Restart server to ensure configuration changes take hold
shell: 'sleep 2 && shutdown -r now "Reboot triggered by Ansible" && sleep 5'
async: 1
poll: 0
become: true
- name: Wait for the server to restart
local_action:
module: wait_for
host={{ inventory_hostname }}
port=22