Skip to content

Instantly share code, notes, and snippets.

View LefterisJP's full-sized avatar

Lefteris Karapetsas LefterisJP

View GitHub Profile
@konradkonrad
konradkonrad / doof.sh
Last active February 28, 2018 09:26
[D]ocker [O]ne [OF]f script (run a container inside the current working directory)
#!/usr/bin/env sh
## Features:
## - host's working directory is mounted to random location as the container's working directory
## - uid/gid of the current user are preserved inside the container
## - a host tmp dir will be mounted as /home/user and published as HOME environment variable inside the container
## - all EXPOSED ports will be published (check `docker port $(docker ps -q|head -n1)`).
## - container will be removed on exit
##
## Examples:
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@LefterisJP
LefterisJP / read_tags.sh
Created September 12, 2013 14:41
Gource caption file from mercurial tags
#!/usr/bin/env bash
CAPTION_FILE=tags.caption
function extract_tags()
{
hg tags | while read x; do
tag=$(echo $x | awk '{print $1}');
rev=$(echo $x | awk '{print $2}' | awk -F: '{print $2}');
rev_date=$(hg log -r $rev --template 'date: {date}\n' | awk -F. '{print $1}' | awk '{print $2}');
@antonio
antonio / delete_rebased_and_merged_branches.sh
Created January 21, 2013 14:58
Delete branches that were rebased (reference never updated) and merged into master
#!/bin/sh
for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'master$'); do
last_commit_msg="$(git log --oneline --format=%f -1 $branch)"
if [[ "$(git log --oneline --format=%f | grep $last_commit_msg | wc -l)" -eq 1 ]]; then
if [[ "$branch" =~ "origin/" ]]; then
local_branch_name=$(echo "$branch" | sed 's/^origin\///')
if [[ -n "$EXEC" ]]; then
git push origin :$local_branch_name
else