Skip to content

Instantly share code, notes, and snippets.

View JonasAlfredsson's full-sized avatar
💭
youtu.be/ykuNZKOGPig

Jonas Alfredsson JonasAlfredsson

💭
youtu.be/ykuNZKOGPig
View GitHub Profile
@JonasAlfredsson
JonasAlfredsson / install_python_debian.md
Last active August 25, 2023 13:52
Install custom version of Python on a Debian system.

A good guide on how to install whatever version of Python you want, on Debian, can be found in [this post][1] on StackExchange and on [sobyte][4]. However, the compact version of it is to move into your Downloads folder and run the following commands.

Side note: to be able to build all optional modules you will need to install [the following][3] dependencies:

sudo apt install \
@JonasAlfredsson
JonasAlfredsson / raspberry-install.md
Last active September 8, 2022 20:25
A short guide on how I installed my Raspberry Pi with a RTC (Real Time Clock).

raspberry-install

This is a short guide on how I installed my Raspberry Pi with a RTC (Real Time Clock) module so it can act as an NTP server as well.

Preparations

Before doing anything software related we need to obtain all the hardware

@JonasAlfredsson
JonasAlfredsson / respect_xorg_conf.md
Last active November 21, 2023 16:28
Make Cinnamon/Gnome respect the /etc/X11/xorg.conf file instead of ~/.config/displays.xml

Make Cinnamon/Gnome/Mate Respect xorg.conf

By default the Cinnamon/Gnome/Mate desktop environment loads its own display configuration from the file ~/.config/monitors.xml instead of using the settings defined in /etc/X11/xorg.conf. This can be a little bit annoying if you are using the nvidia-settings program to configure your displays (which will use xorg.conf), since anything entered there will be overridden by monitors.xml every reboot.

By doing the following changes we will disable the "Display Manager" in

@JonasAlfredsson
JonasAlfredsson / conf_grep.sh
Created February 21, 2020 13:13
Print all lines in a config file which are _not_ commented out (i.e. lines using #)
# Place this function inside your `.bashrc` or `.zshrc` file, source it, and use
# it by calling on it from your terminal like this:
#
# $ conf_grep settings-file.conf
#
# This will find and print a sorted list of all the lines which do _not_ have a
# pound/hashtag (#) sign at the beginning (leading spaces are ignored), i.e.
# print all lines which are not comments.
conf_grep ()
{
@JonasAlfredsson
JonasAlfredsson / split_list.py
Created November 19, 2019 12:08
Split a Python list into N parts.
def split_list(l: list, parts: int) -> list:
"""Takes a list as input, and splits it into "parts" number of sub-lists,
which are then inserted as elements in the returned meta-list.
The function will try to make the sub-lists as equal in length as
possible, so running
split_list( [1, 2, 3, 4, 5, 6], 4 )
will return
[ [1, 2], [3, 4], [5], [6] ]
@JonasAlfredsson
JonasAlfredsson / youtube_regex.sh
Created August 15, 2019 21:23
YouTube URL regex for bash.
if [[ $URL =~ ^(https?://)?(www.)?(youtu.be/|youtube.com/(embed/|v/|watch\?v=|watch\?.+&v=|playlist\?list=))([[:alnum:]|_|-]{11})($|&(.+)?) ]]; then
# This seems to be a link from YouTube with some video ID attached.
else
# This was not recognized as a YouTube link.
fi
# A few different ways you can mount a Samba share on your Linux computer.
# First of all you need the `cifs-utils`.
sudo apt-get install cifs-utils
# Then you can mount the following ways.
- Guest account without password.
sudo mount -t cifs -o vers=3.0,username=guest,password= //192.168.1.2/Music /home/$USER/Music
@JonasAlfredsson
JonasAlfredsson / find_pass.sh
Created August 15, 2019 07:56
Have I Been Pwned
#!/bin/bash
# A small script for querying the https://haveibeenpwned.com/ API to see if your
# password has been leaked, and how many have the same passphrase.
# It is only the first 5 characters of the hash of your password that is sent to
# the server, and what will be printed is something like this:
# 018E42F7FF3A3AD8DFD5A4EB6C78AFFA87C:16173
# which is the whole hash of the password, and how many occurences that was found.
while true; do
read -s -p "enter password> " N
@JonasAlfredsson
JonasAlfredsson / turnOffScreen.sh
Created August 14, 2019 18:10
Small script used for shutting off the computer screen.
#!/bin/bash
# The short sleep is needed so that the release of the keys
# do not trigger a wakeup event.
sleep 1; xset dpms force off
@JonasAlfredsson
JonasAlfredsson / tisdagsklubben_rules.md
Last active February 10, 2024 19:32
Regler för Tisdagsklubben

Tisdagskluben

§1 - Kallelse

  • Värden måste meddela sällskapet om tid och plats minst fyrtioåtta (48) timmar innan sammanträdet ska ske.
  • Samtliga medlemmar skall infinna sig i den lokal dit värden bjudit in, vid den tidpunkt värden har meddelat sällskapet om.
  • Riktlinjen är att försöka hålla ett (1) sammanträde i månaden.
    • Det måste vara så att minst tre (3) medlemmar har möjlighet att delta det föreslagna datumet.

§2 - Försening och Frånvaro