Skip to content

Instantly share code, notes, and snippets.

View edonosotti's full-sized avatar
😼
Writing

Edoardo Nosotti edonosotti

😼
Writing
View GitHub Profile
@edonosotti
edonosotti / dump_logins.sh
Created May 26, 2019 21:11
Dump logins on CentOS
#!/bin/bash
utmpdump /var/log/wtmp* | awk '$4~"root" {print}'
@edonosotti
edonosotti / kubernetes_pgclient.sh
Last active June 9, 2020 17:17
Quick PostgreSQL Maintenance Access in Kubernetes
#!/bin/bash
# Scenario: the database server is running outside of Kubernetes
# and it is in a private network.
# The database connection string is stored into a ConfigMap named:
# `MY_CONFIG_MAP` and its variable name is: `DATABASE_CONNECTION_STRING`.
# We don't want to copy & paste the connection string into the
# command line, we want it to be automatically pulled from the config and
# piped into the command.
@edonosotti
edonosotti / config
Created November 6, 2020 12:04 — forked from justinpawela/config
AWS CodeCommit Multiple Account Config
# This file is: ~/.ssh/config
# You may have other (non-CodeCommit) SSH credentials stored in this
# config file – in addition to the CodeCommit settings shown below.
# NOTE: Make sure to run [ chmod 600 ~/.ssh/config ] after creating this file!
# Credentials for Account1
Host awscc-account1 # 'awscc-account1' is a name you pick
Hostname git-codecommit.us-east-1.amazonaws.com # This points to CodeCommit in the 'US East' region
@edonosotti
edonosotti / zsh_git_k8s_py_node_prompt.sh
Last active February 5, 2021 11:36
Custom ZSH prompt for Git, Kubernetes, Python (conda, miniconda) and Node.JS (nvm)
alias ls='ls -G'
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/enosotti/Tools/google-cloud-sdk/path.zsh.inc' ]; then . '/Users/enosotti/Tools/google-cloud-sdk/path.zsh.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/Users/enosotti/Tools/google-cloud-sdk/completion.zsh.inc' ]; then . '/Users/enosotti/Tools/google-cloud-sdk/completion.zsh.inc'; fi
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
@edonosotti
edonosotti / bigquery_us_reverse_geocoding_cities.sql
Last active June 1, 2021 21:09
Reverse US GeoCoding in BigQuery using public datasets - cities
# -------------------------------------------------------------------
# Reverse US GeoCoding in BigQuery using public datasets - cities
#
# WARNING: This query uses the OLD public datasets.
# Find the NEW version at:
# https://gist.github.com/edonosotti/10b9e642f3cc74e9dd2d026dd556486f
# -------------------------------------------------------------------
# Create a temporary, in memory table
WITH IconicUSLocations AS (
@edonosotti
edonosotti / bigquery_us_reverse_geocoding_counties.sql
Last active June 1, 2021 21:10
Reverse US GeoCoding in BigQuery using public datasets - counties
# -------------------------------------------------------------------
# Reverse US GeoCoding in BigQuery using public datasets - counties
#
# WARNING: This query uses the OLD public datasets.
# Find the NEW version at:
# https://gist.github.com/edonosotti/f842c0868e663f3beb85133a75bdecca
# -------------------------------------------------------------------
# Create a temporary, in memory table
WITH IconicUSLocations AS (
@edonosotti
edonosotti / bigquery_us_reverse_geocoding_states.sql
Last active June 1, 2021 21:11
Reverse US GeoCoding in BigQuery using public datasets - states
# -------------------------------------------------------------------
# Reverse US GeoCoding in BigQuery using public datasets - states
#
# WARNING: This query uses the OLD public datasets.
# Find the NEW version at:
# https://gist.github.com/edonosotti/f998aea189ad6f68c44e8a92387bcebf
# -------------------------------------------------------------------
# Create a temporary, in memory table
WITH IconicUSLocations AS (
@edonosotti
edonosotti / bigquery_us_reverse_geocoding_zipcodes.sql
Last active June 1, 2021 21:13
Reverse US GeoCoding in BigQuery using public datasets - zipcodes
# -------------------------------------------------------------------
# Reverse US GeoCoding in BigQuery using public datasets - zipcodes
#
# WARNING: This query uses the OLD public datasets.
# Find the NEW version at:
# https://gist.github.com/edonosotti/faa1c9dc0ffd402bff6df50ff56cfa50
#
# The NEW version also fixed the `zipcode_geom` column in the
# `zipcode_area` table, incorrectly stored as a STRING type.
# It does not require to be casted to GEOMETRY on-the-fly with the
@edonosotti
edonosotti / bigquery_us_reverse_geocoding_cities_NEW.sql
Created June 1, 2021 20:59
Reverse US GeoCoding in BigQuery using NEW public datasets - cities
# ---------------------------------------------------------------
# Reverse US GeoCoding in BigQuery using public datasets - cities
# ---------------------------------------------------------------
# Create a temporary, in memory table
WITH IconicUSLocations AS (
SELECT 1 AS id, 'Empire State Building' AS name, 40.748170 AS lat, -73.985000 AS lon UNION ALL
SELECT 2, 'Golden Gate Bridge', 37.810181, -122.477318 UNION ALL
SELECT 3, 'Yosemite National Park', 37.8532261, -119.6911924 UNION ALL
SELECT 4, 'Grand Canyon', 36.0997623, -112.1212394 UNION ALL
@edonosotti
edonosotti / bigquery_us_reverse_geocoding_counties_NEW.sql
Created June 1, 2021 21:01
Reverse US GeoCoding in BigQuery using NEW public datasets - counties
# -----------------------------------------------------------------
# Reverse US GeoCoding in BigQuery using public datasets - counties
# -----------------------------------------------------------------
# Create a temporary, in memory table
WITH IconicUSLocations AS (
SELECT 1 AS id, 'Empire State Building' AS name, 40.748170 AS lat, -73.985000 AS lon UNION ALL
SELECT 2, 'Golden Gate Bridge', 37.810181, -122.477318 UNION ALL
SELECT 3, 'Yosemite National Park', 37.8532261, -119.6911924 UNION ALL
SELECT 4, 'Grand Canyon', 36.0997623, -112.1212394 UNION ALL