Skip to content

Instantly share code, notes, and snippets.

@jaumef
jaumef / clean_local_branches.sh
Last active May 31, 2021 06:58
Clean local branches with PR status via github client
#!/bin/bash
for branch in $(git branch | grep -v master | grep -v '*')
do
branch_pr_status=$(gh pr view $branch | grep 'state:' | awk '{print $2}')
if [[ $branch_pr_status ]]
then
echo "$branch is $branch_pr_status"
if [[ "$branch_pr_status" == "MERGED" ]]
then
@jaumef
jaumef / status.sh
Last active May 17, 2021 07:37
Check status of repo and reformat + check typing
#!/bin/bash
# Link/copy this file to your bin folder so you can run this easily
#
# ln -s $PWD/status.sh ~/.local/bin/status
pyfiles=$(git status -s | grep -vE '^ ?[DR] ' | awk {'print $2'} | grep '.py')
if [[ $pyfiles ]]
then
@jaumef
jaumef / Ainstall_wkhtmltopdf.sh
Last active April 13, 2020 14:28
Webkit Header HTML to PDF binaries for linux on version 0.12.2.1
# Get files from this gist (wkhtmltoimage is optional)
wget https://gist.github.com/jaumef/9eb558ac976b2a80269cc51ca8c97087/raw/8d5ceafea1dd387a83eb7eaa699354819b6910d7/wkhtmltopdf
# Set permissions
chmod +x wkhtmltopdf
# Move/copy the files to local binaries (/usr/local/bin)
sudo mv wkhtmltopdf /usr/local/bin/
@jaumef
jaumef / generate_base64_encoded_sample.py
Last active March 2, 2018 14:20
Generate a sample of Base64 encoded string
# -*- encoding: utf-8 -*-
import base64
x = '123456789'*30
# x = '123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789'
base64.encodestring(x)
# 'MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIz\nNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2\nNzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5\nMTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIz\nNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5\n'
print (base64.encodestring(x))
output = """
MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIzNDU2Nzg5MTIz

UNDO COMMITS

BEFORE PUSH

Push backwards current HEAD, uncommitting last commit but keeping files

git reset HEAD^ 

Reset to a past HEAD, removing unpushed changes (hard) or keeping modified files (soft)