Skip to content

Instantly share code, notes, and snippets.

@sgs00
sgs00 / how-to-integrate-wsl-with-windows-10.md
Created February 29, 2024 00:03 — forked from shakahl/how-to-integrate-wsl-with-windows-10.md
How to seamlessly integrate Windows Subsystem for Linux (WSL) with Windows

How to seamlessly integrate Windows Subsystem for Linux (WSL) with Windows

Installation

Install an Ubuntu version from Microsoft Store.

Please check out the Windows 10 Installation Guide written by Microsoft itself.

# https://stackoverflow.com/questions/53472429/how-to-get-a-gcp-bearer-token-programmatically-with-python
def get_access_token():
creds, _project = google.auth.default()
# creds.valid is False, and creds.token is None
# Need to refresh credentials to populate those
auth_req = google.auth.transport.requests.Request()
creds.refresh(auth_req)
return creds.token

Demistifichiamo i service account di Google Cloud Platform.

Tutte le chiamate alle API di Google necessitano di autenticazione OAuth2.

Se la mia applicazione usa queste API ed è eseguita in un ambiente diverso dal mio PC (dove in genere sono autenticato con la mia utenza personale), allora è necessario un service account.

Il service account è di fatto un'identità (authentication).

L'accesso a specifiche API da parte del service account dipende dai permessi che gli verranno assegnati (authorization).

SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'YOURDATABASE' -- change this to your DB
AND pid <> pg_backend_pid();
-- DROP DATABASE "YOURDATABASE" ;
@sgs00
sgs00 / create-gke-kubeconfig.sh
Last active November 8, 2020 18:50
Create a git-friendly kubeconfig for GKE
# this creates a git-friendly kubeconfig for GKE
# kudos: https://ahmet.im/blog/authenticating-to-gke-without-gcloud/
# please note GOOGLE_APPLICATION_CREDENTIALS is required where you will run kubectl
PROJECT=
CLUSTER=
REGION=europe-west1
SERVER=`gcloud container clusters describe ${CLUSTER} --region ${REGION} --project ${PROJECT} --format='value(endpoint)'`
CERT=`gcloud container clusters describe ${CLUSTER} --region ${REGION} --project ${PROJECT} --format='value(masterAuth.clusterCaCertificate)'`
## https://github.com/istio/istio/issues/19263
## https://github.com/istio/operator/pull/713/files#diff-f08ee0447ca8f6e9c8edf9f0551023e7R6
## https://www.learncloudnative.com/blog/2020-01-09-deploying_multiple_gateways_with_istio/
## https://istio.io/latest/docs/setup/install/istioctl/#patching-the-output-manifest
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
addonComponents:
@sgs00
sgs00 / xpath_find_class.txt
Created May 19, 2019 15:23
XPath find tag by class name
# https://stackoverflow.com/questions/1390568/how-can-i-match-on-an-attribute-that-contains-a-certain-string
//TAG_NAME[contains(concat(' ', normalize-space(@class), ' '), ' CLASS_VALUE ')]
@sgs00
sgs00 / centos7_ps_install.sh
Last active April 7, 2019 19:13 — forked from hpandelo/centos7_ps_install.sh
CentOS 7: PrestaShop 1.7.5.1 installer
#!/bin/bash
PS_VERSON=1.7.5.1
prompt_confirm() {
while true; do
read -r -n 1 -p "${1:-Continue?} [y/n]: " REPLY
case $REPLY in
[yY]) echo ; return 0 ;;
[nN]) echo ; return 1 ;;
# https://curl.haxx.se/docs/install.html
wget https://curl.haxx.se/download/curl-7.61.1.tar.gz
tar xzvf curl-7.61.1.tar.gz
cd curl-7.61.1
./configure --prefix=/opt/curl-7.61.1
make
make install
/opt/curl-7.61.1/bin/curl -V
ln -s /opt/curl-7.61.1/bin/curl /usr/local/bin/curl