Skip to content

Instantly share code, notes, and snippets.

@leafnode
leafnode / script.sh
Created Jul 9, 2019
Export deployed YAMLs from kubernetes back to files
View script.sh
#!/bin/sh
kubectl get deploy --namespace metrics prom-prometheus-server -o yaml --export > deploy.yml
kubectl get configmaps --namespace metrics prom-prometheus-server -o yaml --export > prom-prometheus-server-config-map.yml
@leafnode
leafnode / script.sh
Created Jul 9, 2019
Edit deployed configmap
View script.sh
#!/bin/sh
kubectl edit configmaps --namespace metrics prom-prometheus-server
@leafnode
leafnode / script.sh
Created Jul 4, 2019
Extract the default Prometheus config from the Docker image
View script.sh
#!/bin/bash
docker run --entrypoint='' -ti quay.io/prometheus/prometheus:latest /bin/cat /etc/prometheus/prometheus.yml > prometheus.yml
@leafnode
leafnode / script.sh
Created Jun 22, 2019
Tar files with given extension
View script.sh
#!/bin/bash
find ./someDir -name "*.php" -o -name "*.html" | tar -cf my_archive -T -
# or
tar -cf my_archive.tar $( find -name "*.php" -or -name "*.html" )
@leafnode
leafnode / template.go
Created Jun 18, 2019
Template helper function for Go #go #golang
View template.go
func executeTemplate(tmpls *template.Template, tmplName string, w io.Writer, data interface{}) error {
var err error
layout := tmpls.Lookup("layout.html")
if layout == nil {
return errNoLayout
}
layout, err = layout.Clone()
if err != nil {
return err
View script.sh
#!/bin/bash
gcloud spanner instances create test-instance --config=regional-us-central1 \
--description="Test Instance" --nodes=1
gcloud iam service-accounts create [NAME]
gcloud projects add-iam-policy-binding [PROJECT_ID] --member "serviceAccount:[NAME]@[PROJECT_ID].iam.gserviceaccount.com" --role "roles/owner"
gcloud iam service-accounts keys create [FILE_NAME].json --iam-account [NAME]@[PROJECT_ID].iam.gserviceaccount.com
@leafnode
leafnode / init-postgis.sql
Created Oct 5, 2016
Ansible template to prepare dataspace for PostGIS
View init-postgis.sql
-- Enable PostGIS (includes raster)
CREATE EXTENSION postgis;
-- Enable Topology
CREATE EXTENSION postgis_topology;
-- Enable PostGIS Advanced 3D
-- and other geoprocessing algorithms
-- CREATE EXTENSION postgis_sfcgal;
-- fuzzy matching needed for Tiger
CREATE EXTENSION fuzzystrmatch;
-- rule based standardizer
@leafnode
leafnode / iterm2-solarized.md
Created Mar 27, 2019 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)
View iterm2-solarized.md

Default

Default

Powerlevel9k

Powerlevel9k

@leafnode
leafnode / table-stats.sql
Created Jan 30, 2019
[PostgreSQL] show table size stats #postgresql
View table-stats.sql
SELECT *, pg_size_pretty(total_bytes) AS total
, pg_size_pretty(index_bytes) AS INDEX
, pg_size_pretty(toast_bytes) AS toast
, pg_size_pretty(table_bytes) AS TABLE
FROM (
SELECT *, total_bytes-index_bytes-COALESCE(toast_bytes,0) AS table_bytes FROM (
SELECT c.oid,nspname AS table_schema, relname AS TABLE_NAME
, c.reltuples AS row_estimate
, pg_total_relation_size(c.oid) AS total_bytes
, pg_indexes_size(c.oid) AS index_bytes
@leafnode
leafnode / azure-accelerated-networking.psh
Created Jan 30, 2019
Enable Accelerated Networking on Azure net interface
View azure-accelerated-networking.psh
Select-AzSubscription "SubscriptionName"
$nic = Get-AzureRmNetworkInterface -ResourceGroupName "ResourceGroupName" -Name "networkInterfaceName"
$nic.EnableAcceleratedNetworking = $true
$nic | Set-AzureRmNetworkInterface