Skip to content

Instantly share code, notes, and snippets.

@moki9
moki9 / psql-with-gzip-cheatsheet.sh
Created March 17, 2021 07:56 — forked from brock/psql-with-gzip-cheatsheet.sh
Exporting and Importing Postgres Databases using gzip
# This is just a cheat sheet:
# On production
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz
# On local
scp -C production:~/database.sql.gz
dropdb database && createdb database
gunzip < database.sql.gz | psql database
@moki9
moki9 / gcrgc.sh
Created January 18, 2021 06:48 — forked from ahmetb/gcrgc.sh
Script to clean up Google Container Registry images pushed before a particular date
#!/bin/bash
# Copyright © 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@moki9
moki9 / cors-nginx.conf
Created September 12, 2019 12:59 — forked from michiel/cors-nginx.conf
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@moki9
moki9 / dump-restore.sh
Created September 11, 2019 13:13
Dump/Restore from Postgres in Docker with gzip
# Dump
#!/usr/bin/env bash
container=`docker ps | awk '/database/ { print $1 }'`
echo "Dumping data from ${container}"
sudo docker exec -t -u postgres "${container}" pg_dumpall -c -U postgres -l databasename | gzip > dump_`date +%d-%m-%Y"_"%H_%M_%S`.tar.gz
echo "Done!"
# Restore
#!/usr/bin/env bash

Download Audio from YouTube

-i - ignore errors

-c - continue

-t - use video title as file name

--extract-audio - extract audio track

@moki9
moki9 / dump-restore
Created August 7, 2019 04:12 — forked from ricjcosme/dump-restore
DUMP / RESTORE PostgreSQL Kubernetes
DUMP
// pod-name name of the postgres pod
// postgres-user database user that is able to access the database
// database-name name of the database
kubectl exec [pod-name] -- bash -c "pg_dump -U [postgres-user] [database-name]" > database.sql
RESTORE
// pod-name name of the postgres pod
// postgres-user database user that is able to access the database
// database-name name of the database
@moki9
moki9 / ffmpeg.md
Created March 16, 2019 14:00 — forked from dvlden/ffmpeg.md
Convert video files to MP4 through FFMPEG

This is my personal list of functions that I wrote for converting mov files to mp4!

Command Flags

Flag Options Description
-codec:a libfaac, libfdk_aac, libvorbis Audio Codec
-quality best, good, realtime Video Quality
-b:a 128k, 192k, 256k, 320k Audio Bitrate
-codec:v mpeg4, libx264, libvpx-vp9 Video Codec
@moki9
moki9 / gist:b28b4f21436e840100f9ca8c379d7e66
Created January 6, 2019 05:03 — forked from anildigital/gist:862675ec1b7bccabc311
Remove dangling docker images
docker rmi $(docker images -q -f dangling=true)
@moki9
moki9 / pg_load_table_data.sql
Created December 3, 2018 03:22
postgres table data
psql -U user -d database_name -f sql_dump.sql
@moki9
moki9 / pg_dump__table_data_only.sql
Last active December 3, 2018 03:01
postgres - dump table data - insert only
pg_dump -U user --column-inserts --data-only --table=table_name > table_name.sql