Skip to content

Instantly share code, notes, and snippets.

@hendrixcosta
hendrixcosta / use_pfx_with_requests.py
Created May 1, 2024 11:45 — forked from erikbern/use_pfx_with_requests.py
How to use a .pfx file with Python requests – also works with .p12 files
import contextlib
import OpenSSL.crypto
import os
import requests
import ssl
import tempfile
@contextlib.contextmanager
def pfx_to_pem(pfx_path, pfx_password):
''' Decrypts the .pfx file to be used with requests. '''
@hendrixcosta
hendrixcosta / git-branches-by-commit-date.sh
Created September 16, 2022 20:33 — forked from jasonrudolph/git-branches-by-commit-date.sh
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@hendrixcosta
hendrixcosta / pyremovepasspdf.py
Created August 29, 2022 14:52 — forked from drmcarvalho/pyremovepasspdf.py
Script para remover senha de arquivo PDF
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
import Tkinter as tk
import tkFileDialog
import os
import pipes
def unix():
@hendrixcosta
hendrixcosta / delete_git_submodule.md
Created January 4, 2022 18:01 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@hendrixcosta
hendrixcosta / git-mv-with-history
Created March 2, 2021 00:36 — forked from emiller/git-mv-with-history
git utility to move/rename file or folder and retain history with it.
#!/bin/bash
#
# git-mv-with-history -- move/rename file or folder, with history.
#
# Moving a file in git doesn't track history, so the purpose of this
# utility is best explained from the kernel wiki:
#
# Git has a rename command git mv, but that is just for convenience.
# The effect is indistinguishable from removing the file and adding another
# with different name and the same content.
git clone [email protected]:OCA/repo.git -b 8.0 # (target OCA branch)
cd repo
git checkout -b 7.0 origin/7.0
git checkout -b 8.0-module
git filter-branch --subdirectory-filter module # (This last step keeps and rewrites the history only for the selected addon.)
git filter-branch -f --tree-filter 'mkdir -v module; git mv -k * module' HEAD
git rebase 8.0
git remote add myrepo [email protected]:user/repo.git
git push myrepo 8.0-module
@hendrixcosta
hendrixcosta / bitcoin.py
Created October 20, 2020 11:38 — forked from marcoscastro/bitcoin.py
Python - Obtendo o preço do bitcoin
from urllib.request import Request, urlopen
import json, time
def obter_valor():
url = "http://api.coindesk.com/v1/bpi/currentprice.json"
req = Request(url, headers={'User-Agent': 'Mozilla/5.0'})
response = urlopen(req).read()
data = json.loads(response.decode('utf-8'))
valor = float(data['bpi']['USD']['rate'].replace(',', ''))
return valor