Skip to content

Instantly share code, notes, and snippets.

View gvko's full-sized avatar

Galin gvko

View GitHub Profile
@gvko
gvko / aliases.sh
Created July 17, 2019 14:13
aliases
## set Nano as default editor
export EDITOR=nano
## DOCKER
# Stop/kill all running containers.
alias dockerkillall='docker kill $(docker ps -q)'
# Delete stopped containers.
alias dockercleanc='printf "\n===> Deleting stopped containers\n\n" && docker rm $(docker ps -a -q)'
# Delete untagged images.
alias dockercleanimages='printf "\n===> Deleting untagged images\n\n" && docker rmi $(docker images --filter "dangling=true" -q --no-trunc)'
@gvko
gvko / git-clean-old-branches.sh
Created May 6, 2019 17:17
Pass an X number of branches as arguments to the script to delete them locally and remotely
#!/bin/bash
for gitBranch in "$@"
do
git branch -d "$gitBranch"
git push origin :"$gitBranch"
done
@gvko
gvko / dump-db.sh
Created April 24, 2019 13:25
Script for dumping a Postgres DB, in a format that can re-create an identical copy into an empty DB.
#!/bin/bash
# Terminate script on first error
#set -e
while getopts ":d:h:p:u:P:" opt; do
case $opt in
d) DB_NAME="$OPTARG"
;;
h) HOST="$OPTARG"

Keybase proof

I hereby claim:

  • I am gvko on github.
  • I am gako (https://keybase.io/gako) on keybase.
  • I have a public key ASAUc6usW8PqmyY0IRkAHxEeHH19s4UdI5KQcN69qWsFpwo

To claim this, I am signing this object:

@gvko
gvko / enumerate-dates-by-period.js
Last active December 23, 2021 15:41
Enumerate days, weeks, months or years
'use strict';
const moment = require('moment');
/**
* Returns a {key: value} object where the key is a start date and the value is the date + 1 of the type of interval
* to the start date. When for weeks or months, it shows just the first date of the week/month.
*
** For days (start: '2017-12-25', end: '2018-01-02', interval: 'day'):
{ '2017-12-25': '2017-12-26',