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 / 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_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 / 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 / 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 / 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 / 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 / simulate_load_linux.sh
Created May 25, 2019 13:06
Simulate CPU load on a linux box
#!/bin/bash
dd if=/dev/urandom | gzip -9 >> /dev/null &
@edonosotti
edonosotti / terraform_aws_api_gateway_account_cloudwatch.tf
Created May 10, 2019 17:16
Terraform plan to grant API Gateway permissions to write logs to CloudWatch in AWS
# NOT MY CODE! TAKEN FROM THE OFFICIAL DOCS:
# https://www.terraform.io/docs/providers/aws/r/api_gateway_account.html
# and saved here as a backup.
resource "aws_api_gateway_account" "demo" {
cloudwatch_role_arn = "${aws_iam_role.cloudwatch.arn}"
}
resource "aws_iam_role" "cloudwatch" {
name = "api_gateway_cloudwatch_global"
@edonosotti
edonosotti / enable_ssh_raspberry.md
Last active January 22, 2019 17:25
Enable SSH at boot on Raspberry Pi, Raspbian

Enable SSH at boot on Raspberry Pi, Raspbian

Description

SSH is not enabled by default on Raspbian at the time of writing.

Tested on:

  • Version:November 2018
  • Release date: 2018-11-13
@edonosotti
edonosotti / cleanup_docker_cache_on_mac.sh
Created November 13, 2018 17:15
Cleanup Docker cache on MacOSX
#!/bin/bash
docker rm $(docker ps -a -q) && \
docker rmi $(docker images -q) && \
docker volume rm $(docker volume ls |awk '{print $2}') && \
rm -rf ~/Library/Containers/com.docker.docker/Data/*