Skip to content

Instantly share code, notes, and snippets.

View samgaw's full-sized avatar
🇪🇺
¯\_(ツ)_/¯

Sam Gaw samgaw

🇪🇺
¯\_(ツ)_/¯
View GitHub Profile
@samgaw
samgaw / meraki-init.sh
Created June 29, 2020 15:19 — forked from lukas2511/meraki-init.sh
Meraki MS220-8P config without cloud bullshit
#!/bin/sh
# This script configures a meraki ms220-8p switch completely from scratch
# See https://leo.leung.xyz/wiki/Meraki_MS220-8P for rooting instructions
# You can keep config and config.local completely empty, but i'd recommend to add a configuration
# which isolates all ports from each other.
# Without that you might have switching loops on bootup (unlikely since STP keeps longer to initialize
# than it takes this script to take over, but it just feels cleaner).
@samgaw
samgaw / lua.md
Created January 31, 2018 23:50 — forked from ahupowerdns/lua.md
The LUA record type for Lua-powered DNS records

LUA Record Type for Lua-powered DNS records for standards based fail-over and geographical load balancing

GitHub branch -> https://github.com/ahupowerdns/pdns/tree/luarec

Recently, many zone owners could not migrate away from Dyn since they were benefiting from non-standardised DNS-based failover and geographical loadbalancing features. What you see below is an attempt to get standards based but flexible equivalents of these currently proprietary features. Here is a zone:

$TTL 60
lua.br. IN      SOA     a.lua.br. nstld.verisign-grs.com. (
        2016032300      ; Serial
        14400           ; Refresh
@samgaw
samgaw / postgrest-single_table_selects.md
Created October 17, 2017 21:44
Postgrest Multi-Version Latency Testing (20 concurrent requests)

Postgrest 0.3.2: -H "Prefer: plurality=singular" "http://127.0.0.1:3000/numbers?telephone_number=eq.%2B442099123456"

Summary:
  Total:        6.6562 secs
  Slowest:      0.1074 secs
  Fastest:      0.0021 secs
  Average:      0.0265 secs
  Requests/sec: 751.1826

Response time histogram:
@samgaw
samgaw / postsql.sql
Created August 23, 2012 01:38 — forked from tobyhede/postsql.sql
PostgreSQL as JSON Document Store
-- PostgreSQL 9.2 beta (for the new JSON datatype)
-- You can actually use an earlier version and a TEXT type too
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8
-- Inspired by
-- http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html
-- http://ssql-pgaustin.herokuapp.com/#1
-- JSON Types need to be mapped into corresponding PG types
--
import re
# http://atomboy.isa-geek.com/plone/Members/acoil/programing/double-metaphone
from metaphone import dm as double_metaphone
# get the Redis connection
from jellybean.core import redis
import models
# Words which should not be indexed
@samgaw
samgaw / gist:990778
Created May 25, 2011 10:54
sed One Liners
-------------------------------------------------------------------------
HANDY ONE-LINERS FOR SED (Unix stream editor) Apr. 26, 2004
compiled by Eric Pement - pemente[at]northpark[dot]edu version 5.4
FILE SPACING:
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
sudo apt-get update
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:pitti/postgresql
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install -y postgresql-9.0 postgresql-server-dev-9.0 postgresql-contrib-9.0 proj libgeos-3.2.2 libgeos-c1 libgeos-dev libgdal1-1.7.0 libgdal1-dev build-essential libxml2 libxml2-dev checkinstall
psql --version
@samgaw
samgaw / ovsKernPanic
Created May 6, 2011 11:44
Recreate OVZ panic with OVS-trunk on Debian 6 (Squeeze) 2.6.32-5-openvz-amd64
## System Config
uname -a
Linux ovz04 2.6.32-5-openvz-amd64 #1 SMP Mon Mar 7 22:25:57 UTC 2011 x86_64 GNU/Linux
cat /etc/network/interfaces
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet static