Skip to content

Instantly share code, notes, and snippets.

View uilian's full-sized avatar
🏠
Working from home

Uilian Souza uilian

🏠
Working from home
View GitHub Profile
@uilian
uilian / git stash commands
Last active December 9, 2019 12:16
Git Stash
# list stash content without applying
git stash show -p stash@{1}
git stash show -p stash@{0} --name-only
# apply specific file
git checkout stash@{2} -- FILE_PATH/FILE_NAME
@uilian
uilian / sample-imagemagick-base64.sh
Created August 8, 2019 12:56
Imagemagick manipulation with base64 images
# create a new image
$ convert -size 10x10 xc:red sample.jpg
# convert to a base64 string
$ base64 sample.jpg
# output to a file:
$ convert 'inline:data:image/jpeg;base64,[BASE64-DATA]' output.jpg
# or, output to a base64 string:
@uilian
uilian / acrnms.txt
Last active June 18, 2019 18:54
Acronyms
AFAIK =» As Far As I Know
AFK =» Away From Keyboard
ASAP =» As Soon As Possible
BAS =» Big A$$ Smile
BBL =» Be Back Later
@uilian
uilian / replace-text-in-files.sh
Created May 15, 2019 13:50
Find all files containing some text, then replace by something else
ag -l "TEXT_TO_FIND" . | xargs sed -i.bak 's/TEXT_TO_FIND/NEW_TEXT_TO_REPLACE/g'
@uilian
uilian / rename.sh
Created April 15, 2019 16:02
Multi-rename files
# Assembles the old and new names, in the following example the name has 3 parts
# The NR adds a linenumber to the new name.
s ls pattern_file_name* | awk '{print "mv " $1"\\ "$2"\\ "$3" " $1 NR $3 }' | bash $1
@uilian
uilian / find-process.sh
Created March 26, 2019 17:46
Find process occupying port
## this
netstat -vanp tcp|grep PORT
## or this, if -p is not supported
lsof -i tcp:PORT
@uilian
uilian / docker-commands.md
Last active January 16, 2019 11:12
More docker commands

Removes all containers returned by condition

docker container rm $(docker container ps -qa --filter "name=example1" --filter "name=example2")

Removes images older than specified 'ImageID' and not tagged

docker image rm $(docker images -q --filter "dangling=true" --filter "before=ImageID")
@uilian
uilian / diff-dirs.sh
Created August 7, 2018 11:23
Diff between two directories
diff -r ~/projects/sim-api/ ~/projects/onboarding/sim-api/ | grep ~/projects/sim-api/ | awk '{print $4}' > difference.txt
////// was8 file on /etc/init.d
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: was8
# Required-Start:
# Should-Start: $ALL
# Required-Stop:
# Should-Stop:
@uilian
uilian / oracle-schema-objects-size.sql
Created April 26, 2018 16:39
Tamanho dos objetos em um schema oracle
-- Todos os objetos do schema
select
owner,
sum(bytes)/1024/1024/1024 schema_size_gig
from
dba_segments
group by
owner;
-- Tamanho por tipo de objeto