Edit remote files in Emacs with Tramp mode

https://www.gnu.org/software/tramp/ TRAMP stands for “Transparent Remote (file) Access, Multiple Protocol”. A remote file name always looks like /method:user@host:/path/to/file. Examples: Opening a remote file via ssh C-x C-f /ssh:user@host:/path/to/file Use sudo to open a file with root permissions C-x C-f /sudo:root:/path/to/file sudo uses root as the default user name, therefore it can also be opened as /sudo::/path/to/file Access a remote file using the SMB protocol C-x C-f /smb:user%domain@host:/path/to/file

June 3, 2024 · Fernando Costa Bertoldi

Reusing custom form templates site-wide in Django

https://docs.djangoproject.com/en/4.2/topics/forms/#reusable-form-templates https://docs.djangoproject.com/en/4.2/ref/forms/renderers/#templatessetting To set a custom template file for all forms in a Django project: add "django.forms" in INSTALLED_APPS. set APP_DIRS=True in the TEMPLATES setting. define a custom FORM_RENDERER class to use the form_template_name site-wide. class CustomFormRenderer(TemplatesSetting): form_template_name = "new_form.html" FORM_RENDERER = "<project_root>.settings.CustomFormRenderer"

April 28, 2024 · Fernando Costa Bertoldi

Create reverse-patch file

From StackOverflow: You may have a .patch that you would like it to be reverted - not apply reverted, but to create a new patch with the reverted diff. The interdiff shows differences between two diff files. From the docs: To reverse a patch, use /dev/null for diff2. interdiff -q file.patch /dev/null > reversed.patch

March 13, 2024 · Fernando Costa Bertoldi

Live-reloading CSS on static sites

Option 1: live-server https://github.com/tapio/live-server Run live-server, which runs a NodeJS web server with load-reload capabalities via websockets. npm install -g live-server cd <website-dir> live-server Option 2, for Hugo sites: fingerprint the CSS files https://discourse.gohugo.io/t/live-reloading-during-development/37132 Add the content’s hash to the CSS filename to work around the browser cache. {{ $style := resources.Get "css/style.css" | minify | fingerprint }} <link rel="stylesheet" type="text/css" href="{{ $style.Permalink }}" integrity="{{ $style.Data.Integrity }}" media='all' /> Option 3, when using VSCode: install the Live Preview extension https://marketplace....

January 19, 2024 · Fernando Costa Bertoldi

Work with multiple emails in git

To work with multiple emails, use conditional includes. https://stackoverflow.com/questions/4220416/can-i-specify-multiple-users-for-myself-in-gitconfig https://git-scm.com/docs/git-config#_conditional_includes Uncomment the following section, and substitute “work” for whatever the name of company’s work folder you want. [user] name = Fernando Costa Bertoldi email = [email protected] [includeIf "gitdir:~/work/"] path = config-work In the file ~/.config/git/config-work, add the work specific config: [user] email = [email protected]

January 12, 2024 · Fernando Costa Bertoldi

Define default applications on the command-line

The xdg-mime command, which is part of the xdg-utils package, can be used to define default application associations via the XDG MIME Applications specification. https://wiki.archlinux.org/title/Default_applications https://wiki.archlinux.org/title/XDG_MIME_Applications Query the MIME type of a file: xdg-mime query filetype <path-to-file> Display the default application for PDFs: xdg-mime query default application/pdf Find the desktop entry name of Firefox: ls -l /usr/share/applications | grep -i firefox Set Firefox as the default application for html files: xdg-mime default firefox....

January 1, 2024 · Fernando Costa Bertoldi

Download whole website: httrack

When you launch httrack from the termial, it starts a wizard for configuring the mirroring options

November 29, 2023 · Fernando Costa Bertoldi

PDF utilities based on libpoppler

Poppler is a PDF rendering library based on the xpdf-3.0 code base. The package poppler-utils contains pdf utilities based on Poppler. pdfunite: concatenate documents pdfunite file1.pdf file2.pdf out.pdf pdfseparate: page extraction tool extract from sample.pdf pages 3 to 5, generating sample-page-3.pdf, sample-page-4.pdf, sample-page-5.pdf pdfseparate -f 3 -l 5 sample.pdf sample-page-%d.pdf pdftotext: text extraction pdftoppm: convert to image formats pdftoppm -png file.pdf > file.png pdfinfo: document information pdfsig: verify digital signatures

November 9, 2023 · Fernando Costa Bertoldi

Browsing context

A browsing context is an environment in which a browser displays a Document. In modern browsers, it usually is a tab, but can be a window or even only parts of a page, like a frame or an iframe. Each browsing context has an origin (that of the active document) and an ordered history of previously displayed documents. https://developer.mozilla.org/en-US/docs/Glossary/Browsing_context

May 2, 2023 · Fernando Costa Bertoldi

GitHub auto-refresh PRs

GitHub uses websocket connections to auto-refresh changes on pull requests, but the sockets are not created in the PR’s browsing context, but in shared web workers. https://stackoverflow.com/questions/64665510/how-does-github-instantly-update-its-web-interface https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker

May 2, 2023 · Fernando Costa Bertoldi