Skip to content

Instantly share code, notes, and snippets.

View rasgo-cc's full-sized avatar
🎯
Focusing

Mario Ribeiro rasgo-cc

🎯
Focusing
View GitHub Profile
@rasgo-cc
rasgo-cc / killport.bat
Created January 9, 2020 17:32
Windows killport (kill a process running on a specific port)
REM usage: killport.bat <port>
@echo off
setlocal
echo Killing port %1
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":%1"') do taskkill /f /pid %%a
@rasgo-cc
rasgo-cc / docker_snippets.md
Created September 11, 2019 01:09
Snippets and utilities for Docker

Find where container's logs are:

docker inspect --format='{{.LogPath}}' <container_name>
@rasgo-cc
rasgo-cc / dotenv.sh
Created May 10, 2019 10:00
Export variables in a dotenv file (bash)
function dotenv() {
file=${1-".env"}
set -a; source $file; set +a
}
@rasgo-cc
rasgo-cc / .vscode
Created May 9, 2019 10:07
VSCode Settings
{
"window.zoomLevel": 0,
"editor.tabSize": 2,
"editor.detectIndentation": false,
"editor.insertSpaces": true,
"editor.renderWhitespace": "boundary",
"workbench.panel.defaultLocation": "bottom",
"editor.fontFamily": "'Fira Code', Menlo, Monaco, 'Courier New', monospace",
"editor.fontLigatures": true,
// "editor.formatOnSave": true,
@rasgo-cc
rasgo-cc / list_last_commits.bat
Created May 1, 2019 12:41
List last Git commits (windows)
@echo off
for /f "delims=" %%a in ('git describe --tags --abbrev^=0') do @set latesttag=%%a
git log %latesttag%..HEAD --graph --oneline
@rasgo-cc
rasgo-cc / gitlog.sh
Created March 18, 2019 11:07
Pretty print Git logs
git log --pretty=format:'%C(yellow)%h %Cred%ad %Cblue%an%Cgreen%d %Creset%s'
@rasgo-cc
rasgo-cc / lip.sh
Last active March 18, 2019 11:08
Get local network IP address
route -n get default | grep interface | awk '{ print $2 }' | xargs ipconfig getifaddr
@rasgo-cc
rasgo-cc / docker-ip.sh
Last active March 18, 2019 02:46
IP address of Docker container
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $1
@rasgo-cc
rasgo-cc / heroku_dotenv.sh
Last active March 18, 2019 01:53
Fetch Heroku config vars and save them into a dotenv file
#!/bin/bash
# Usage: heroku_dotenv.sh <heroku_app_name> <dotenv_file>
# Default dotenv_file: .env
dotenv=${2-".env"}
heroku config -a $1 |
sed -n '1!p' |
awk '{ gsub(/:/,"", $1); f=$1; $1=""; print f"="substr($0,2) }' > $dotenv
cat $dotenv
echo "File written: $dotenv"
@rasgo-cc
rasgo-cc / killport.sh
Last active February 25, 2019 16:49
Kill all processes running on port passed to killport (e.g. 'killport 8080')
# Add this to your .zshrc file (or equivalent)
# Kills all processes running on a given port
# Usage: killport <port>
function killport() {
lsof -i:$1 | grep LISTEN | awk '{print $2}' | xargs kill -9
}