Skip to content

Instantly share code, notes, and snippets.

@mkornatz
mkornatz / cf-worker.js
Last active May 4, 2024 04:07
Cloudflare Workers CORS Proxy (supports websockets)
// We support the GET, POST, HEAD, and OPTIONS methods from any origin,
// and allow any header on requests. These headers must be present
// on all responses to all CORS preflight requests. In practice, this means
// all responses to OPTIONS requests.
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,HEAD,POST,OPTIONS",
"Access-Control-Max-Age": "86400",
}
@mkornatz
mkornatz / datahub-nginx-proxy.conf
Last active February 2, 2022 16:57
DataHub nginx proxy configuration (supports websockets)
# This configuration can be used to create a reverse proxy for use with Figment's DataHub service
#
# This file can be included by placing it into /etc/nginx/sites-enabled/ (Debian based distros)
# or /etc/nginx/conf.d/ (Red Hat based distros)
server {
# The proxy will listen on port 80 (SSL is not enabled)
listen 80;
# Replace EXAMPLE with the DataHub service name
@mkornatz
mkornatz / ec2.md
Last active July 23, 2020 13:46
Addressing "Unknown" AWS Resources

EC2

Discover

These steps are for a Linux instance. Similar operations can be peformed on Windows, but I haven't administered Windows machines for about 10 years. So, some research is required for that.

  1. Examine the processes running on the instance
ps aux
@mkornatz
mkornatz / ip-to-slack.js
Created December 4, 2017 15:21
Retrieves IP of server and sends it to user via Slack. Used when a server boots up.
<?php
$slackWebhookUrl = "https://hooks.slack.com/services/this/comes/from/slack/after/setting/up/a/webhook";
$slackChannel = 'molly';
// Keeps trying to get the IP address for 20 times
$retries = 0;
$ipAddress = null;
while(empty($ipAddress) && $retries < 20) {
$ipAddress = exec("ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'");
@mkornatz
mkornatz / update-emails.js
Created December 4, 2017 15:05
Update Email Signatures in Gmail Account
/**
* Set email signature on provided email addresses
* To ensure signatures have been successfully updated, follow the steps below:
*
* 1. Add comma-separated email addresses (example: 'one@domain.com', 'two@domain.com', 'three@domain.com')
* 2. Navigate to Run > setAllSignatures
* 3. Navigate to View > Logs
* 4. View log output "Signature successfully updated for [email address]"
*/
function setAllSignatures() {

Keybase proof

I hereby claim:

  • I am mkornatz on github.
  • I am mkornatz (https://keybase.io/mkornatz) on keybase.
  • I have a public key ASDlb2g8L-k2SBSk849l_9bKCFdlrUS7RidKo1qLWeRXbgo

To claim this, I am signing this object:

@mkornatz
mkornatz / list_column_size.sql
Last active April 20, 2017 14:07
Largest tables and columns in a MySQL database
SELECT CONCAT(ROUND(sum(length(column_name)) / ( 1024 * 1024 ), 2), 'M')
FROM table_name;
@mkornatz
mkornatz / digg.sh
Last active June 6, 2022 18:23
A simple script to lookup DNS records, whois, and arin-whois info in one command.
#!/bin/bash
# digg.sh
# Usage: digg [domain|ip|url]
# Examples:
# digg https://google.com/
# digg 67.1.1.1
# digg www.example.com
@mkornatz
mkornatz / buddy-craft-atomic-deploy.php
Last active December 4, 2017 19:22
A simple script for atomic deployments within Buddy CI.
<?php
/*
*/
process(is_array($argv) ? $argv : array());
/**
* processes the installer
*/
@mkornatz
mkornatz / crontab
Created December 14, 2016 20:49
AWS HA Proxy failover script. Uses two nodes with autofailover by assuming a "VIP."
@reboot /path/to/ha_monitor.sh >> /var/log/ha_monitor.log 2>&1