Creează un cont pentru a te abona la acest blog și a-i urmări articolele pe pagina Lectură.
-
Patch private methods in python
I’ve encountered this rather profane yet tricky problem while testing a method: class MyClass: def __method(self) -> str: pass def test() with patch.object(MyClass,"__method") as _: pass pytest E AttributeError: <class 'My…
-
Display the wireless status on the emacs mode-line
I found this code1 to display the wireless status in the modeline.
-
Stop google chromium from hijacking MIMEs on arch linux
In addition to this blogpost – whom focuses on chrome but on chromium, I had to run the following command to get rid of the chromium tick: sudo sed -i 's/chromium.desktop;//' /usr/share/applications/mimeinfo.cache
-
Writing in ancient greek with Emacs and Linux
For starters, you want to write brother in ancient greek.
-
Understanding yield in python
I’m testing a script against a live database.
-
Beware of emacs pytest runner defaults
Emacs provides an incredible python developer experience.
-
A minimal example of using namedtuples in pytest parameterized tests
What means - in the test parameters below?
-
Patch the async json response of a mocked aiohttp clientsession in pytest
Haven’t found a short concise example covering pytest whilst focussing the patched json method of a mocked async session, hence this snippet.
-
Django python IDE autocompletion in emacs
Presuming a working python layer, following settings will provide autocompletion. e.g. typing Mymodel.ob will suggest Mymodel.objects for completion. yay basedpyright ~/.spacemacs.d/init.el (defun dotspacemacs/user-config () (use-package lsp-pyright :en…
-
Play a video from emacs org mode using lisp
Links in Emacs org mode allow arbitrary emacs-lisp execution.
-
Ignore regions when formatting buffers with three keys
I’m quite fond of keeping my code formatted.
-
Get an email upon failed systemd services
Only by chance, I noticed a failed systemd service.
-
Labeling code blocks in ox-hugo
Table of Contents Problems Solution What happens How it works By chance, I stumbled over an excellent article1 about labeling code blocks in hugo.
-
Mark tagged files partially in image-dired
Given your image-dired tags have similar beginnings e.g 0.jpg;foo 1.jpg;foo: Now all you enter – in order to mark – images tagged with foo but not foo:, is this: M-x image-dired-mark-tagged-files foo$ Note the dollar sign suffix Why is such profane regex…
-
Create a public S3 bucket using the aws cli
Table of Contents Create an arbitrary bucket name Create the bucket Delete public access block Create a policy to allow public read access on the bucket Apply the policy to the bucket Create an example file Upload the example file to our bucket [Assert] D…
-
Call a bash script with arguments in python
/tmp/foo.py arguments=" ".join(["foo", "bar"]) cmd="foo.sh" subprocess.run(['/bin/env', cmd]+arguments) /tmp/foo.sh #!
-
Fix treemacs-add-project wrong type argument hash table p nil
After a recent cleanup of treemacs projects, I wanted to add again a known project: ~/src/django Yet M-x treemacs-add-project returned (wrong-type-argument hash-table-p nil) Debugging with M-x debug-on-error gave away a suspicious gethash call: Debugger e…
-
Set up to share ox-hugo blog posts on social media
While preparing to share this post on LinkedIn, I noticed something’s missing.
-
Font awesome icons in hugo footer
Table of Contents Directory path and completeness config.toml Usage of the icons with ox-hugo shortcodes in content Conclusion 👋 I followed this concise blog post1 about embedding font awesome in hugo.
-
Python project packaging with pipenv pytest and cli
Table of Contents A minimal python project Installing the package in a virtual environment using pipenv with python 3.8 Review the installation in perspective of pipenv and python 3.8 Run something from the cli Review our current (cli) project’s state How…
-
How to pipenv install a git pull request from github
Given is this pullrequest https://github.com/joeyespo/pytest-watch/pull/108 pipenv install -d \ git+https://github.com/joeyespo/pytest-watch.git@refs/pull/108/head#egg=pytest-watch The -d flag installs the package in the Pipfile’s [dev-packages] section T…
-
Automating Image Manipulation in Emacs Dired Mode
I manage my images using emacs dired, specifically image-dired.
-
Blender python development workflow
Edit the python script Keep a terminal open running the watch script e.g. $ sh watch.sh See the rendered result Each time you save the python script, the watch script gets notified and re-executes.
-
Ignore transactions in ledger-cli
Given is a ledger file containing imported bank transactions we want to ignore.
-
Shark in a flower at sunrise in Venice
-
Get latest ledger transaction's date only
#Content of ~/tmp/file.dat 2099/02/07 * acme Expenses:Groceries $ 1 Assets:Cash 2089/11/07 * foobar Expenses:Groceries $ 4 Assets:Cash I want – from the account Assets:Cash a…
-
Parse contacts from email in python
Process all your email contacts using mu and python. mu-cfind returns all contacts: mu cfind Excerpt from the returned results ...
-
Update your financial ledger by email in python
Table of Contents Abstract Goal Manual process briefly explained Script - Step by step Complete script Abstract Each time I buy something and pay it later, my expenses and liabilities increase.
-
Parse ledger-cli using python
#Content of file.dat 2099/02/07 * foo ; MD5Sum: 4d2965fa2879f3c528006f2e9c3bca8d Expenses:Groceries CHF 10 Assets:Cash 2099/11/07 * bar ; MD5Sum: 4d2965fa2879f3c528006f2e9c3bca8e Expenses:Groceries
-
Extract and convert vcf contacts from emails in python
I wasn’t able to export my contacts from my iphone (iOS 11).
-
Python unit testing in emacs org mode
Using emacs org and babel1, I want to quickly note ideas in python.
-
Create diagrams in emacs org mode
Table of Contents Mermaid-cli Mermaid for org mode Usage Problem solving Being able to explain something with your words only prevails.
-
Create a blender scene in python
Using blender, I need to test multiple settings for my painting references e.g. lighting, material or the complete location.
-
Test automation using GNU Make in ox-hugo
Amongst others, I run this script as part of my tests after a system update.
-
Annotate pictures non-invasively in latex/pdf using org mode
Goal of this method is the non-invasive annotation of pictures in LaTeX/pdf.
-
Code expansion in org mode prose text
Say I want to write about the count of my system’s processors at the time of my writing.
-
Fix [Pyright] Import could not be resolved in emacs
Say you open any python file containing an import.
-
Why do I need unit tests?
So I want to compare if two dates are equal.
-
How to use the ox-hugo Makefile
Amongst others, I run this script as part of my tests after a system update. cd /tmp #Cleanup rm -r ox-hugo #Clone latest repository git clone git@github.com:kaushalmodi/ox-hugo.git cd ox-hugo #Make change in org file sed -i "s/\(Kaushal\)/The awesome \1/"
-
Scraping Migros M-Budget with python
Table of Contents Motivation How to understand this post Script ingredients Modules Urls Process overview Visit the ISP’s login page Login Get the consumption values Logout Complete script Usage Conclusion Motivation I recently caught myself repeatedly ch…
-
Testing APIs offline and fast with vcrpy
Table of Contents Motivation Requirements Create the test Run the test Check folders and files Go offline Run the test again - offline Go back online Conclusion Motivation While testing code against online sources like websites or APIs I often find myself…
-
Take website screenshots with headless Firefox
This script takes a screenshot of a website.
-
Mount a USB drive persistently for all users
Table of Contents Create a mount point List devices Backup & print current fstab Add the device to fstab Change device’s permission Test Cleanup Troubleshooting I need to persistently permit all users read/write access to a USB drive Create a mount point…
-
Backup an iPhone with Linux
Table of Contents Install the necessary packages Find the event iPhone connected Catch the event iPhone connected Create the trigger iPhone connected Create the action Backup iPhone Restart and reload all actors (not the iPhone though) Monitor the backup…
-
Change Firefox's zoom by script
Each time I change the monitor I have to zoom in or out firefox.
-
Connect an iPhone to a Raspi
Table of Contents Unlock your iPhone Connect and login into your raspi Update - Retrieve new lists of packages Upgrade - Perform an upgrade Install the necessary packages Connect the iPhone with the raspi via USB Accept the trust dialog on the iPhone Pair…
-
Setup a Fujitsu ix500 scanner on Linux
Table of Contents Install package Approve the connection Get a list of devices: Get a list of all device specific options: Scan a test file Scan productively Skipping empty pages Alias the command Install package sudo apt install sane-utils -y Approve the…
-
Take screenshots in emacs org mode with flameshot
Figure 1: Screencast showing flameshot in action Setup Enable the org layer in your .spacemacs dotspacemacs-configuration-layers dotspacemacs-configuration-layers '(org) Install flameshot sudo pacman -S flameshot Add the line below to your .space…
-
Write a letter in org mode
Table of Contents Goals Setup Workflow (Spacemacs) Goals Figure 1: Printed sample.pdf In order to get the same printout as in figure 1 above, both includepdf lines starting at line 37 here must be uncommented.
-
Blog in org mode with ox-hugo and github pages
Table of Contents Setup ox-hugo Create a new github repo via web front-end Clone the new repository Setup Hugo in our new repository Create the new hugo site Download a theme and add it as git sub-module Create the org content folder Create a minimal org…