Skip to content

Instantly share code, notes, and snippets.

View filipeandre's full-sized avatar

Filipe Ferreira filipeandre

View GitHub Profile
@filipeandre
filipeandre / bash_aliases
Last active May 13, 2018 23:11
Some aliases
alias @alias='nano ~/.bash_aliases && source ~/.bash_aliases'
alias @wget='wget --no-check-certificate -c -P ~/Transferências/'
alias @aria2c='aria2c --check-certificate=false -x5 -d ~/Transferências/'
alias @somealias='ssh -i ~/.ssh/my_ssh_key -L 3306:127.0.0.1:3306 debian@myremoteip'
@filipeandre
filipeandre / find_unused_ppa.sh
Created May 13, 2018 23:43
Bash file to find how many packages are installed from custom ppas
#!/usr/bin/env bash
for f in /etc/apt/sources.list.d/*.list; do
grep -Po "(?<=^deb\s).*?(?=#|$)" "$f" | while read -r ENTRY ; do
echo "ENTRY: $ENTRY"
HOST=$(cut -d/ -f3 <<< "$ENTRY")
if [ "ppa.launchpad.net" = "$HOST" ]; then
USER=$(cut -d/ -f4 <<< "$ENTRY")
PPA=$(cut -d/ -f5 <<< "$ENTRY")
packageCount=$(awk '$1=="Package:" {if (a[$2]++ == 0) {system("dpkg -l "$2)}}' /var/lib/apt/lists/*"$USER"*"$PPA"*Packages 2>/dev/null | awk '/^ii/' | wc -l)
@filipeandre
filipeandre / restore_home_permissions.sh
Created May 13, 2018 23:44
Restore home directory permissions
#!/bin/bash
usage(){
echo "Usage: $0 username"
exit 1
}
restore(){
getent passwd $1
if [ $? -eq 0 ]; then
#!/bin/bash
echo "removing evaluation key"
rm ~/.IntelliJIdea*/config/eval/*.evaluation.key
echo "resetting evalsprt in options.xml"
sed -i '/evlsprt/d' ~/.IntelliJIdea*/config/options/options.xml
echo "resetting evalsprt in prefs.xml"
sed -i '/evlsprt/d' ~/.java/.userPrefs/prefs.xml
@filipeandre
filipeandre / generate_clone_all_git_repos.sh
Created May 24, 2018 11:57
Generate a file to clone all repos from bitbucket server
# this script uses syntax for bitbucket server.
# For bitbucket cloud see https://confluence.atlassian.com/bitbucket/use-the-bitbucket-cloud-rest-apis-222724129.html
#
# Note: replace your_server_url, your_username with your values
SERVER=your_server_url
USERNAME=your_username
echo "Whats your password?"
read -s PASSWORD
# https://stackoverflow.com/questions/46923816/how-to-retrieve-the-list-of-repos-using-a-particular-plugin-using-bitbucket-api
@filipeandre
filipeandre / upload.sh
Created June 20, 2018 08:48
Upload folder ssh
scp -r /path/to/local/source [email protected]:/path/to/remote/destination
@filipeandre
filipeandre / download.sh
Created June 20, 2018 08:49
Download folder ssh
scp -r [email protected]:/path/to/remote/source /path/to/local/destination
@filipeandre
filipeandre / setup2.iss
Created June 20, 2018 14:41
Inno Setup Compiller Example
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "Smartdigit sage api configurator"
#define MyAppVersion "1.0.2.3-2017.02.005"
#define MyAppPublisher "SmartDigit – Unipessoal, Lda"
#define MyAppURL "http://smartdigit.pt"
#define MyAppExeName "Api.Sage.Configurator.exe"
[Setup]
@filipeandre
filipeandre / git-pull-all
Created June 21, 2018 11:03 — forked from grimzy/git-pull-all
Git pull all remote branches
#!/usr/bin/env bash
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
@filipeandre
filipeandre / delete_all_object_versions.sh
Created July 3, 2018 07:06 — forked from weavenet/delete_all_object_versions.sh
Delete all versions of all files in s3 versioned bucket using AWS CLI and jq.
#!/bin/bash
bucket=$1
set -e
echo "Removing all versions from $bucket"
versions=`aws s3api list-object-versions --bucket $bucket |jq '.Versions'`
markers=`aws s3api list-object-versions --bucket $bucket |jq '.DeleteMarkers'`