Understand Python unit tests in 5 minutes
In this video I show you an overview of unit tests in Python: what they are, how they work and how to write effective ones by looking at real world examples.
Links:
- Python 3 documentation for unit tests: https://docs.python.org/3/library/unittest.html
- md-toc: https://github.com/frnmst/md-toc/
CHAPTERS
0:00 Intro
0:08 Brief explanation
0:51 Steps to setup unit tests
1:12 Directory structure
1:22 tests.py file structure: unittest module, inherited classes, test_ methods
2:27 The strcmp_a function example
2:46 strcmp_a unit tests explained in detail
3:25 Running the tests
3:30 Setting a wrong value in a unit test on purpose to see what happens
3:40 The _replace_string function in md-toc
4:09 _replace_string unit tests
4:33 Running all tests in md-toc
4:53 Lines of code of unit tests compared to the rest of the code in md-toc
5:07 Outtro
#unittests #python #mdtoc
4
views
Sandboxed Firefox profiles
In this video I show you how to setup sandboxed and isolated Firefox profiles and an easy GUI interface to lauch them.
The software used is, of course, Firefox, Firejail for the sandbox and YAD for the GUI menus.
Links:
- script: https://codeberg.org/frnmst/ftutorials/src/branch/master/docs/content/desktop/browser/includes/home/jobs/scripts/myuser/firefox_profile_runner.py
- configuration: https://codeberg.org/frnmst/ftutorials/src/branch/master/docs/content/desktop/browser/includes/home/jobs/scripts/myuser/firefox_profile_runner.yaml
CHAPTERS
0:00 Intro
0:16 Launching the script and the profile window opens
0:57 Changing Firefox theme to distinguish it from other profiles
1:16 Disabling verbose message windows
1:31 Explaining Firejail related to this script
2:20 Types of list for profile displaying
3:36 Creating a hotkey to show the list
4:00 Showing how a file download works in an isolated home directory
4:35 Detailed explanation of the YAML configuration file
5:57 Installing the required dependencies
6:22 Outtro
#firefox #firejail #sandbox
16
views
Old microserver as CCTV computer?
Is an old microserver good as a video surveillance computer? In this video you'll find out if an HP ProLiant MicroServer with an N54L processor is able to handle multiple capture cards and to record the video footage.
Links:
- HP Proliant G7 specsheet: https://support.hpe.com/hpesc/public/docDisplay?docId=c02503511&docLocale=en_US&page=GUID-560AA969-7049-46FE-8D64-04B1F80FBCB9.html
- Debian: https://www.debian.org
- Motion: https://motion-project.github.io/
- FFmpeg: https://ffmpeg.org/
CHAPTERS
0:00 Intro
0:37 Hardware considerations: USB capture cards and ports
1:16 More ports are needed: PCIe USB cards
1:44 Extracting the motherboard from the case
2:01 Low profile brackets for the PCIe cards
2:21 Cards installed in the system
2:31 HDD screws and screwdrivers (T9H)
3:01 Minimal Debian setup as OS (netinstall and no proprietary firmware)
3:42 Use motion to capture the video feeds and ffmpeg to record them
3:58 All capture cards are plugged
4:03 Fan, heat and noise considerations
4:30 CPU usage considerations
4:51 Power consumption
5:00 Alternatives
5:23 To reduce CPU load use VA-API with ffmpeg (on supported CPUs)
5:41 Test the HP ProLiant as a desktop PC by viewing YouTube
6:09 Outtro
#hpproliant #microserver #n54l #debian #motion #ffmpeg
10
views
How to run a self hosted AI
An overview of an open source, self hosted A.I. system. We'll see how to set it up, how to run it (with the CPU only), and an example interaction.
We'll also see how Python scripts that interface with these systems look like.
For this video we'll look at text generative A.I. models only.
A.I.:
- FastChat: https://github.com/lm-sys/FastChat
A.I. Models:
- FastChat-T5: https://huggingface.co/lmsys/fastchat-t5-3b-v1.0
- RedPajama-INCITE-Chat-3B-v1: https://huggingface.co/togethercomputer/RedPajama-INCITE-Chat-3B-v1
O.S.:
- Debian: https://www.debian.org/download
CHAPTERS
0:00 Intro
0:59 Virtual machine settings
1:29 Debian as OS of choice
1:48 PIP installation
2:00 FastChat installation through PIP
2:12 The FastChat-T5 model
2:26 First part of interaction with FastChat-T5
4:41 Real speed, processor and memory usage
6:12 Clone GIT repositories of the models and datasets
6:26 Second part of interaction with FastChat-T5
9:06 Bonus coding question
9:19 Testing another model using a Python script instead of interacting with the CLI directly
10:22 Outtro
#ai #generativeai #selfhostedai #fastchat #debian
8
views
Upgrade your Debian server to Bookworm without breaking the OS
In this video I show you some of the most important things to do when upgrading your server from Debian 11 to 12.
We'll see that you can't simply change the APT sources files and upgrade, hoping for the best, but there are a few steps to clean up your system before actually upgrading.
Links:
- Debian upgrade guide: https://www.debian.org/releases/stable/amd64/release-notes/ch-upgrading.en.html
- Issues to be aware of for bookworm: https://www.debian.org/releases/stable/amd64/release-notes/ch-information.en.html
- Debian: https://www.debian.org
CHAPTERS
0:00 Intro
0:37 Overview of the main document
1:02 Do a normal upgrade first
1:32 Some important software updates in Bookworm
2:42 Remove backports packages and their sources
3:20 Remove obsolete and non-Debian packages
3:39 Modify the APT sources list
3:50 Do the partial upgrade first then the full upgrade
4:26 Post upgrade cleanup
4:35 Outtro
#debian #bookworm #upgrade
8
views
Disable IT-alert messages
The IT-alert public warning message system is being tested in Italy.
UPDATE: this method worked for me: no message the day of the test!
In this short video I show you two ways to disable the receptions of these messages. Hopefully, by combining these two methods no broadcast message should be received. Once you disable the services the "Public warnings" settings disappears.
Note: this video does not suggest conspiracy theories, etc... I just present you two possible ways to disable these messages if you think are annoying.
Links:
- IT-alert: https://www.it-alert.it/en/
- Netguard: https://netguard.me/
- ADB: https://developer.android.com/tools/adb
Timings:
0:00 Intro
0:30 Other countries and disclamer
0:54 Disabling cell broadcast from the "Public warnings" settings in Android
1:15 Not so easy to disable
1:40 The ADB method
2:21 Checking if the "Public warnings" setting is still present (it's not)
2:29 Notes and questions
2:44 Outtro
#italert #cellbroadcast #android #lineageos #adb #noitalert #noalert
5
views
They are back!
They are back! On June 5th 2023, the W.H.O issued a press release explaining that it will adopt the EU Digital Green Certificate system as a base by adapting it and using it in the W.H.O member countries (practically the whole world population). This will happen in the near future.
In this video I show you an overview of the technical aspects of the QR codes used to represents these certificates: how to decode them, how to interpret their fields and the amount of data stored in these documents.
Just as a reminder, here is a table of what was possible to do in Italy with
and without these certificates when they were still actively used: https://www.asaps.it/downloads/files/4_5791646919142935668.pdf
Press release:
- https://www.who.int/news/item/05-06-2023-the-european-commission-and-who-launch-landmark-digital-health-initiative-to-strengthen-global-health-security
- https://www.who.int/director-general/speeches/detail/who-director-general-s-opening-remarks-at-the-signing-ceremony-of-the-who-eu-global-digital-health-certification-network--5-june-2023
Digital Health Certificate technical documents:
- EU Digital Covid Certificate GitHub organization: https://github.com/ehn-dcc-development
- eu-digital-green-certificates GitHub organization: https://github.com/eu-digital-green-certificates
- Test data: https://github.com/eu-digital-green-certificates/dgc-testdata.git
- Guidelines on Value Sets for Digital Green Certificates: https://health.ec.europa.eu/system/files/2021-04/digital-green-certificates_dt-specifications_en_0.pdf
Green Pass FAQ:
- https://www.dgc.gov.it/web/faq.html#faq-card-16
Green pass revocations:
- EU Digital COVID Certificate: EU launches new revocation feature: https://digital-strategy.ec.europa.eu/en/news/eu-digital-covid-certificate-eu-launches-new-revocation-feature
- DGC Revocation List documentation: https://github.com/ministero-salute/it-dgc-documentation/blob/master/DRL.md
- Go to index 36 of this JSON file: https://get.dgc.gov.it/v1/dgc/settings
Some specs:
- CBOR: https://cbor.io/
- COSE: https://datatracker.ietf.org/doc/html/rfc8152
0:00 Intro
1:08 Documents concerning the implementation of the DGCs
1:23 QR code structure introduction
2:08 JSON payload example
3:10 QR code decoding steps
3:42 Python script explanation: various steps, function and values
5:10 The script in action
5:57 Revocation function
6:17 Digital Green Certificates in the wild
6:32 Outtro
#DGC #greenpass #QRcode
39
views
Computer recreations: core wars
In this video I show you a Python implementation of a 1984 article by A. K. Dewdney from the "Scientific American" magazine called "In the game called Core War hostile programs engage in a battle of bits".
Using a circular list and implementing at least two of the proposed operations, it's possible to execute basic programs in the Redcode programming language.
The user codes the language mnemonics in the main function of the program which are then translated into "machine code" and stored into the "core memory", i.e.: circular list. The simulator will then execute these instructions.
Links to the article:
- https://www.scientificamerican.com/article/computer-recreations-1984-05/
- https://people.scs.carleton.ca/~soma/biosec/readings/akdewdney/First.htm
Source code:
- https://codeberg.org/frnmst/solve-computer-science-extras/src/branch/master/computer-recreations/computer-recreations-core-wars
Wikipedia:
- https://en.wikipedia.org/wiki/Core_War
CHAPTERS
0:00 Intro
0:22 General overview of the article: history, programming language, operations
1:37 Circular array
2:00 Circular list in Python
2:10 Instruction pointer: keeps track of the execution
2:44 The Simulator class
3:11 Structure of the machine code
4:18 Addressing types
5:12 A 3-instruction program replicated from the article
5:55 Check the expected result of the program
6:16 The "Imp" program
6:57 Important methods of the Simulator class: transform human mnemonics to machine code and vice-versa, store and execute operations
8:17 The MOV operation
8:27 Script execution
9:32 Outtro
#computerrecreations #corewars #python
15
views
Palindrome algorithm in C
A 5 minute video about a palindrome algorithm in the C programming language.
You will see an overview of the algorithm and the C implementation itself.
0:00 Intro
0:29 Base case: string of length 1
0:45 Algorithm: setting the indices to do a character by character comparison
1:20 Algorithm: move the indices and repeat comparison
1:41 Algorithm must end when indices have certain values
1:57 Algorithm: string of odd length
2:20 Non-palindrome string
2:49 Naive algorithm
3:10 C implementation of the algorithm
4:31 Running the program
4:38 Generating a palindrome string in Python (bonus)
5:02 Outtro
#palindrome #algorithm #programming #cprogramming
27
views
Probability-based random text generation
In this video I show you a Python implementation of a 1983 article by Brian Hayes from the "Scientific American" magazine called "A progress report on the fine art of turning literature into drivel".
Using weighed probabilities and random number selections, it is possible to generate a mashed up version of an input text.
The simplest data structure to use in this case is a matrix, however, as you'll find out in the video, there are certain limitations.
Links to the article:
- https://www.semanticscholar.org/paper/A-progress-report-on-the-fine-art-of-turning-into-Hayes/066a55a3ca5fa9b38106bb29bcb5c4dd2b30d9e7
- http://bit-player.org/wp-content/extras/bph-publications/SciAm-1983-11-Hayes-drivel.pdf
- https://www.scientificamerican.com/article/computer-recreations-1983-11/
Source code:
- https://codeberg.org/frnmst/solve-computer-science-extras/src/branch/master/computer-recreations/probability-based-random-text-generation
Example using "The Complete Works of William Shakespeare" by Project Gutenberg, on 32GB RAM:
```
order: 7
length: 512
seed: 'FAST E'
---
fast eyes into his grave died for a scottish spring my lord are in the banquo o banquo lennox no indeed and he so thou meets and clarence warwick out ripe in my heels for this shall did makes me it sufficient kneels caesars prevent my lips have our dancer speaking forth the word edward of my noble duke's best save my lord a black neer lusts were buried away confidence with the glass yet he hath he bids the marketplace have been is stopp'd protest in thy affairs fram'd and they're welcome my name of hogs antonio y
```
Another example using "Alice's Adventures in Wonderland" by Lewis Carroll
```
time ./generative_web.py 7 256 "https://raw.githubusercontent.com/ElizaLo/Machine-Learning/master/Text%20Generator/alice_in_wonderland.txt"
order: 7
length: 256
seed: 'ACK TO'
---
ack to the thought alice's right eagerly that she was at the fifth bend about like' said the considered audibly what would do to be treacle from the three or might as usual come back at last word two as there's an atom of a tremble all moved on the trial' stupid
---
real 0m1.858s
user 0m1.486s
sys 0m0.220s
```
CHAPTERS
0:00 Intro
0:35 Alphabet selection
1:00 Frequency counting
1:16 Random number selection based on weighed probability (1st order)
1:31 2nd order
1:58 nth order and memory problems
2:43 Sparse matrix as a possible solution to the memory problem
2:58 generative.py script explanation5:08 generative.py script execution
5:31 generative_web.py script explanation
6:24 generative_web.py script execution
6:34 Outtro
#textgeneration #python #matrix
36
views
Smart way to create matrix in Python
This video shows you how to create square matrices in Python using normal lists and NumPy.
Using NumPy has the advantage to reduce the amount of code when working with matrices.
Matrices are called multidimensional arrays in NumPy.
0:00 Intro
0:34 Recap: list data structure
1:12 Nested lists
1:31 Limitations of lists
1:45 NumPy
2:00 Python script: main function
4:04 The `gen_matrix` function
4:59 The `matrix_set` function
5:16 the `tolist` method
5:45 Outtro
#python #matrix #numpy #functions #programming
20
views
Simple sound dampening improvement for a door
In this short video I show you a cheap and simple way to improve sound dampening of a door.
This will not solve the problem completely but it is certainly an improvement.
0:00 Intro
0:15 Solution
1:32 Extra improvement and outtro
#sounddampening #soundisolation #door #woodendoor #seals
6
views
Full text search in Nextcloud
This video shows you how to set up full text search in a Nextcloud instance.
When I did the setup myself, I found it being not as easy as I thought, so I decided to share the steps and caveats.
In this video, Nextcloud and Elasticsearch are set up using docker-compose.
Apps to install from the Nextcloud admin:
- Full text search: https://apps.nextcloud.com/apps/fulltextsearch
- Full text search - Elasticsearch Platform: https://apps.nextcloud.com/apps/fulltextsearch_elasticsearch
- Full text search - Files: https://apps.nextcloud.com/apps/files_fulltextsearch
0:00 Intro
0:35 Install the apps from the admin
0:56 Admin search setup
1:47 Preliminary testing
2:07 docker-compose file setup
3:29 Install ingest-attachment plugin
3:44 Create the Elasticsearch data directory and enable its volume
4:20 Testing if Elasticsearch works with Nextcloud
4:44 Run a full indexing
4:53 Search using the web UI
5:24 Updating Elasticsearch correctly
5:53 Outtro
#nextcloud #nextcloudfulltextsearch #nextcloudsearch #elasticsearch #search #docker #dockercompose
43
views
Export Nextcloud calendars, contacts and news
This video shows you how to export Nextcloud calendars, contacts and news sources
with the help of my Python script.
Once you setup this script with cron or a Systemd timer, all these exportings
can be automated to run once a day, for example.
If the database of your Nextcloud instance corrupts for some reason, you can
retrieve this data from the backups.
Once you have the exported files, you can import them in programs such as
Thunderbird, Evolution, QuiteRSS or another Nextcloud instance.
#nextcloud #nextcloudcalendars #nextcloudcontacts #nextcloudexport #thunderbird #python #http #api
12
views
Learn C pointers in 5 minutes
A 5 minute video about pointers in the C programming languages.
You will see a brief explanation and the most common use cases for pointers such as:
- passing values by reference to functions
- arrays
- pointer arithmetics
- data structures
6
views
Do THIS to improve your server uptime
Welcome to this new video about servers where I show you different tips, that, if combined together, will surely increase your server uptime.
I'll talk about UPSes, dust filters, managing important OS updates and other things.
4
views
Will digital euro be really like cash?
In this video I show you some important documents about the upcoming digital euro, what it will probably be like and how it differs from cash.
Direct links to documents and pages in the video:
- Digital euro homepage:
https://www.ecb.europa.eu/paym/digital_euro/html/index.en.html
- Digital euro FAQs:
https://www.ecb.europa.eu/paym/digital_euro/faqs/html/ecb.faq_digital_euro.en.html
- Digital euro written feedback:
https://www.ecb.europa.eu/paym/digital_euro/investigation/governance/shared/files/ecb.degov221205_writtenfeedback.en.pdf?afaf269b059998f3a7d8a00d8a780909
- Digital euro user interface prototyping news:
https://www.ecb.europa.eu/paym/intro/news/html/ecb.mipnews220916.en.html
- "Front-end prototype providers technical onboarding package":
https://www.ecb.europa.eu/paym/digital_euro/investigation/profuse/shared/files/dedocs/ecb.dedocs221207_cover_note_digital_euro_front_end_prototyping_publication_of_technical_onboarding_package.en.pdf?8bccc21f8546c450e8da0eb59732d0a8
9
views
Find smallest element in array
In this video I show you how to find the minimum and maximum elements in an array.
I also show you how to find the second minimum and maximum.
At the end of the video you will also find an implementation in Python.
4
views
Nextcloud's Recognize app: purpose, setup and optimal settings
In this video I show you how to setup the Recognize app in Nextcloud and what values to use to avoid eating up all the CPU.
Recognize is used to automatically tag files based on content using A.I. models. The A.I. works totally offline once the models have been downloaded.
- Nextcloud: https://nextcloud.com/
- Recognize app: https://github.com/nextcloud/recognize
25
views
Interesting ChatGPT prompts and answers
In this video I show you some interesting prompt sent to ChatGPT and its responses.
We'll have a look at how ChatGPT answers to:
- simple arithmetics
- string inversions
- coding exercises (asking the language model to provide non-functional code)
- controversial questions
3
views
Change Gitea mirror interval for all repositories
In this video I present you a solution to change the Gitea mirror interval for all repositories in your instance.
By acting directly on the database you can easily make other bulk changes like this one.
Gitea: https://gitea.io
Adminer: https://adminer.org
4
views
De-duplicate an array in C
In this video I present you three ways to de-duplicate an array in using the C programming language.
The three methods have different space and time complexities.
You will also find a simple solution in Python near the end of the video.
2
views
Find differing elements between two arrays in C
In this video I guide you through an exercise about finding differing elements between two arrays. The presented solution is written in the C programming language.
1
view
Tree near-hits car during storm
Unedited video of a camera during a storm.
The sky becomes dark in a few minutes. Strong winds make temporary road signals and a tree fall. The tree nearly hits a moving car.
The timelapse effect is part of the original video.
Filter array elements in C
In this video I guide you through an exercise about filtering elements in an integer array.
After filtering some of the elements, you can do some operations on them, such as summing a constant value.
The presented solution is written in the C programming language.
2
views