Skip to content

Instantly share code, notes, and snippets.

View davidalger's full-sized avatar

David Alger davidalger

View GitHub Profile
@davidalger
davidalger / postgres-cheatsheet.md
Created May 14, 2021 20:53 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@davidalger
davidalger / 00-iframe-communication.md
Created April 4, 2020 02:25 — forked from pbojinov/README.md
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

-- Query the database to calculate a recommended innodb_buffer_pool_size
-- and get the currently configured value
-- The rollup as the bottom row gives the total for all DBs on the server, where each other row is recommendations per DB.
SELECT
TABLE_SCHEMA,
CONCAT(CEILING(RIBPS/POWER(1024,pw)),SUBSTR(' KMGT',pw+1,1))
Recommended_InnoDB_Buffer_Pool_Size,
(
SELECT CONCAT(CEILING(variable_value/POWER(1024,FLOOR(LOG(variable_value)/LOG(1024)))),SUBSTR(' KMGT',FLOOR(LOG(variable_value)/LOG(1024))+1,1))
@davidalger
davidalger / nsq_compare.sh
Created July 8, 2019 20:41 — forked from mttjohnson/nsq_compare.sh
dns name sever query comparison
#!/usr/bin/env bash
nameserver_source="a.iana-servers.net"
nameserver_comparison="b.iana-servers.net"
dns_records="
example.com a
ftp.example.com a
mail.example.com a
ns1.example.com a
# Consider filtering the varnishlog output
# https://feryn.eu/blog/varnishlog-measure-varnish-cache-performance/
varnishlog -i "RespHeader,Req*" -X "RespHeader:(x|X)-" -I "timestamp:Resp" -x reqprotocol,reqacct -g request
# Capture the log output from varnishlog and look for BereqHeader
# -n name is how you can specify a specific named instance of varnish
# remove -n if you just want to access the default instance
varnishlog -n stage
@davidalger
davidalger / README.md
Created December 4, 2018 04:22 — forked from erikhansen/README.md
Example README.md file for Magento 2 project

Title of Site

Developer Setup

Run through the following steps to setup this project on your local environment. These instructions assume you're using the standard Classy Llama devenv.

Server Access

Use the following to connect to stage.

@davidalger
davidalger / composer_private_repos.sh
Created November 24, 2018 23:49 — forked from mttjohnson/composer_private_repos.sh
Composer Notes and Private Repositories
# List the composer home directory
# Typically /Users/<user>/.composer or /home/<user>/.composer or C:\Users\<user>\AppData\Roaming\Composer
echo $COMPOSER_HOME
# List files in the composer home
ls -la $COMPOSER_HOME
# View auth.json in composer home used when no local ./auth.json exists in the directory executed from
cat $COMPOSER_HOME/auth.json
@davidalger
davidalger / 1_kubernetes_on_macOS.md
Created September 18, 2018 17:59 — forked from kevin-smets/1_kubernetes_on_macOS.md
Local Kubernetes setup on macOS with minikube on VirtualBox and local Docker registry

Requirements

Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check that this is enabled on OSX / macOS run:

sysctl -a | grep machdep.cpu.features | grep VMX

If there's output, you're good!

Prerequisites

FROM debian:jessie
ENV BUILD_PKG "automake bzip2 cmake make g++ gcc git-core libssl-dev patch binutils"
RUN apt-get update && apt-get install -y \
libssl1.0.0 openssl ssl-cert $BUILD_PKG \
vim mysql-client && \
cd /usr/local/src && \
git clone -b 2018-04-01 --depth 1 --single-branch https://github.com/google/re2.git && \
git clone -b v1.4.8 --depth 1 --single-branch https://github.com/sysown/proxysql.git && \
#file proxysql.cfg
# This config file is parsed using libconfig , and its grammar is described in:
# http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-File-Grammar
# Grammar is also copied at the end of this file
datadir="/var/lib/proxysql"
admin_variables=
{