Skip to content

Instantly share code, notes, and snippets.

@amackiewicz
amackiewicz / gist:4be0792c927f60af4aaf196e4341ceeb
Created June 16, 2023 11:45
gitlab pipeline for (un)deployment of gcp cloud functions using monorepo. integrated with vault
# Pipeline allows to manage gcp cloud functions deployment and undeployments via git repository
# Required gcp permissions:
# * cloudfunctions.functions.create
# * cloudfunctions.functions.delete
# * cloudfunctions.functions.get
# * cloudfunctions.functions.sourceCodeSet
# * cloudfunctions.functions.update
# * cloudfunctions.operations.get
image: "xxx"
@amackiewicz
amackiewicz / rsa keys
Created May 31, 2021 12:33
Generate rsa keys without track of password in terminal history
openssl genrsa -aes128 -passout stdin -out test.key 4096
openssl rsa -in test.key -pubout -out test.key.pub
@amackiewicz
amackiewicz / gist:585b9154cc397df2707f9b7e05d87af5
Created April 13, 2021 03:54
Move committed (but not pushed) changes to new branch (master branch direct push protection)
git checkout -b mybranch
git push origin mybranch
git checkout master
git reset --hard origin/master
@amackiewicz
amackiewicz / sqlite3-import-to-pgsql.sh
Created October 21, 2020 14:58
export data from sqlite3 database file and import to remote pgsql
SOURCE_SQLITE_PATH=$(pwd)/db.sqlite SOURCE_TABLE_NAME=? PSQL_TARGET_HOST=? PSQL_TARGET_DB=? PSQL_TARGET_USER=? PSQL_TARGET_PASS=? docker run --rm -v ${SOURCE_SQLITE_PATH}:/root/db/db.sqlite -v $(pwd)/output.sql:/root/db/output.sql --name sqlite3-export nouchka/sqlite3:latest db\.sqlite .mode\ insert select\ *\ from\ ${SOURCE_TABLE_NAME} > output.sql && docker run --rm -v $(pwd)/output.sql:/dev/shm/inserts.sql -env PGPASSWORD=${PSQL_TARGET_PASS} --name pgsql-import postgres:12.1-alpine psql -h ${PSQL_TARGET_HOST} -U ${PSQL_TARGET_USER} ${PSQL_TARGET_DB} < /dev/shm/inserts.sql && rm output.sql
@amackiewicz
amackiewicz / gist:50367386cc6b2f30ec3b7414690a6e83
Created September 25, 2019 03:51
Linux service systemctl
# /etc/systemd/system/drone.service
[Unit]
Description=Drone server
After=docker.service nginx.service
[Service]
Restart=always
ExecStart=/usr/local/bin/docker-compose -f /etc/drone/docker-compose.yml up
ExecStop=/usr/local/bin/docker-compose -f /etc/drone/docker-compose.yml stop
UPDATE
media
SET
"index" = s.ordering::INT
, "updated_at" = CURRENT_TIMESTAMP
FROM (
SELECT
"unnest"
, "ordinality"
FROM