Skip to content

Instantly share code, notes, and snippets.

View skylock's full-sized avatar

Emanuil Copil skylock

  • Cluj-Napoca, Romania
View GitHub Profile
#!/usr/bin/env bash
#
# Copyright (c) .NET Foundation and contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
current_userid=$(id -u)
if [ $current_userid -ne 0 ]; then
@skylock
skylock / OSX-commands.md
Last active May 13, 2021 08:28
OSX commands

Search and delete file by type recursively

find /path . -name '*.js' -type f -delete

Reset Open With context menu database

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user killall Finder

@skylock
skylock / create_new_ssh_key.md
Created April 23, 2018 06:01 — forked from JoaquimLey/create_new_ssh_key.md
Generating a new SSH key and adding it to the ssh-agent

##Generating a new ssh-key

Open Terminal. Paste the text below, substituting in your GitHub email address.

ssh-keygen -t rsa -b 4096 -C "[email protected]"

This creates a new ssh key, using the provided email as a label

Generating public/private rsa key pair.

@skylock
skylock / install.sh
Created April 20, 2018 14:26 — forked from wdullaer/install.sh
Install Latest Docker and Docker-compose on Ubuntu
# Ask for the user password
# Script only works if sudo caches the password for a few minutes
sudo true
# Install kernel extra's to enable docker aufs support
# sudo apt-get -y install linux-image-extra-$(uname -r)
# Add Docker PPA and install latest version
# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
# sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
@skylock
skylock / docker-cleanup
Created April 20, 2018 14:25 — forked from wdullaer/docker-cleanup
Cleanup unused Docker images and containers
#!/bin/sh
# Cleanup docker files: untagged containers and images.
#
# Use `docker-cleanup -n` for a dry run to see what would be deleted.
untagged_containers() {
# Print containers using untagged images: $1 is used with awk's print: 0=line, 1=column 1.
# NOTE: "[0-9a-f]{12}" does not work with GNU Awk 3.1.7 (RHEL6).
# Ref: https://github.com/blueyed/dotfiles/commit/a14f0b4b#commitcomment-6736470
docker ps -a | tail -n +2 | awk '$2 ~ "^[0-9a-f]+$" {print $'$1'}'
@skylock
skylock / AWS-Wiki.md
Last active January 15, 2020 07:35
AWS Wiki

AWS guides

Login a AMI

  • Download your-ssh-key.pem
  • mv your-ssh-key.pem to ~/.ssh/your-ssh-key.pem
  • ssh -i your-ssh-key.pem [email protected]

#Use this command to remove entries from known_hosts: ssh-keygen -R hostname

git rm -r --cached .
git add .
git commit -m "fixing .gitignore"
#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
# remove unused volumes:
find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
Backup:
docker exec -t -u postgres your-db-container pg_dumpall -c > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
Restore:
cat your_dump.sql | docker exec -i your-db-container psql -Upostgres
@skylock
skylock / docker-rm-images.md
Created January 30, 2018 12:06 — forked from alferov/docker-rm-images.md
Remove all (untagged) images and containers from Docker
# Delete all containers
docker rm $(docker ps -aq)
# Delete all images
docker rmi $(docker images -q)
# Delete all untagged images
docker rmi $(docker images -q --filter "dangling=true")

References: