Skip to content

Instantly share code, notes, and snippets.

View kouk's full-sized avatar

Konstantinos Koukopoulos kouk

View GitHub Profile
#!/usr/bin/env bash
# Inspired by: https://github.com/kayrus/kuttle
# Usage:
#
# sshuttle -v -r 'none' -e /path/to/this_script 172.20.0.0/16
#
set -e
VERSION=0.1
SET @COLS = '';
SELECT GROUP_CONCAT( COLUMN_NAME SEPARATOR ',')
INTO @COLS
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_KEY != 'PRI'
AND TABLE_NAME='mytable'
AND TABLE_SCHEMA = 'mydatabase';
SET @SQL = CONCAT('SELECT ', @COLS, ' FROM mytable');
PREPARE stmt FROM @SQL;
EXECUTE stmt;
@kouk
kouk / group-by-ip.sql
Last active November 17, 2020 07:53 — forked from bennadel/group-by-ip.sql
Grouping The MySQL PROCESSLIST By IP Address To View Connection Counts
SELECT
tmp.ipAddress,
-- Calculate how many connections are being held by this IP address.
COUNT( * ) AS ipAddressCount,
-- For each connection, the TIME column represent how many SECONDS it has been in
-- its current state. Running some aggregates will give us a fuzzy picture of what
-- the connections from this IP address is doing.
FLOOR( AVG( tmp.time ) ) AS timeAVG,
@kouk
kouk / Dockerfile
Created March 17, 2021 14:06
Build mozilla/sops@develop with docker
FROM golang:1.15 AS build
WORKDIR /build
RUN go mod init example.com/sops-build \
&& go get -u go.mozilla.org/sops/v3/cmd/sops@develop
RUN go get -u filippo.io/age/cmd/...
FROM scratch AS bin
COPY --from=build /go/bin/sops /
import airflow
import getpass
import logging
from airflow import models, settings
from airflow.contrib.auth.backends.password_auth import PasswordUser
def set_password(name, password):
session = settings.Session()
u = session.query(PasswordUser).filter_by(username=name).first()
import sys
import os
import gspread
from google.oauth2 import service_account
def get_gspread_client() -> gspread.Client:
scope = ["https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/spreadsheets"]
# see https://docs.gspread.org/en/latest/oauth2.html
credentials_path = os.environ.get('GOOGLE_SERVICE_ACCOUNT_CREDENTIALS', None)