Skip to content

Instantly share code, notes, and snippets.

View serrasqueiro's full-sized avatar
🎯
Focusing

Henrique serrasqueiro

🎯
Focusing
View GitHub Profile
@serrasqueiro
serrasqueiro / reindent.py
Last active March 26, 2023 10:58 — forked from akanakia/reindentv2.py
A slightly more versatile reindent.py
# reindent.py -- Tim Peters, and H.Moreira
# pylint: disable=missing-function-docstring, trailing-whitespace, line-too-long, invalid-name, unused-argument
# Re-named to reindent.py and enhanced by Henrique Moreira, 01 Dec 2019.
# Released to the public domain, by Anshul Kanakia, 22 May 2019 as reindentv2.py
# Original code reindent.py released to the public domain, by Tim Peters, 03 October 2000.
# This version is modified to allow custom indent space values (not just 4 spaces).
"""reindent [-d][-r][-v] [ path ... ]
@serrasqueiro
serrasqueiro / perforce.md
Created December 4, 2019 10:55 — forked from martynjarvis/perforce.md
Perforce Cheatsheet

Perforce Cheatsheet

Useful Commands:

Check I have no changes:

p4 opened

Sync to head:

@serrasqueiro
serrasqueiro / delete_git_submodule.md
Last active July 23, 2023 12:03 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  1. Delete the relevant section from the .gitmodules file.
  2. Stage the .gitmodules changes: git add .gitmodules
  3. Delete the relevant section from .git/config
  4. Run git rm --cached path_to_submodule (no trailing slash)
  5. Run rm -rf .git/modules/path_to_submodule (no trailing slash)
  6. Commit: git commit -m "Removed submodule <name>"
  7. Delete the now untracked submodule files: rm -rf path_to_submodule
@serrasqueiro
serrasqueiro / learningpie.py
Last active February 17, 2020 01:35
learningpie
""" learningpie.py -- Henrique Moreira
Simple python tweaks and slips!
"""
# pylint: disable=missing-docstring
import os
""" Euro pattern
"""
import re
EURO_NUMBER_PATTERN = re.compile(r"^\d{1,3}(?:\.\d{3})*,\d{2}$")
def normalize_number(value: str):
""" Normalize European-formatted numbers like '36.423,19' into '36423.19'.
Only applies the transformation if the string matches the expected pattern.
@serrasqueiro
serrasqueiro / gitremote.sh
Last active June 14, 2020 12:02
Show remote gits
#!/bin/sh
#
# gitremote.sh -- show remote
usage ()
{
echo "$0 [options] path
Options are:
@serrasqueiro
serrasqueiro / read_pdf.py
Last active June 7, 2020 12:12
read_pdf
# -*- coding: utf-8 -*-
# (c)2020 Henrique Moreira
""" read_pdf.py, a simple PDF reader
"""
import sys
import os.path
from sys import stdout, stderr
import PyPDF2
@serrasqueiro
serrasqueiro / grelha_meo.txt
Last active December 18, 2021 20:08
Canais de operadores em portugal
# channel number <tab> description
1 RTP1
2 RTP2
3 SIC
4 TVI
5 SIC Noticias
6 RTP 3 (H)
7 CNN Portugal
8 CMTV
9 SIC Mulher
@serrasqueiro
serrasqueiro / README.md
Last active June 27, 2020 18:01
htm_ascii_table.md

htm_ascii_table

GIST repo: serrasqueiro/appf

Files:

  • htm_ascii_table.md, markdown help
  • appf_01.htm, original file
@serrasqueiro
serrasqueiro / snippet_submodule_url.md
Last active May 11, 2026 14:16
Change URL in a git submodule

How to change a submodule URL

I wanted to change the name of a repository, from https to ssh. Repo was from github, well known:

Edit the corresponding url...