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 / docker_functions
Last active April 16, 2020 14:20
Useful Docker Functions
# Docker Functions
# A small collection of commands that can be quite useful when
# working with Docker.
# Stop all containers on the system.
stop_all_containers() {
docker stop $(docker ps -aq)
}
# Stop all containers on the system and remove them.
@JonasAlfredsson
JonasAlfredsson / GitHub_Authentication_Token.md
Last active October 18, 2019 11:34
Guide on how to create an authentication token to be used with HTTPS instead of SSH when it is blocked by a proxy.

GitHub Authentication Token Behind Corporate Proxy

When your are behind a corporate proxy it might be difficult to use SSH to communicate with [github.com][3], since this type of traffic may be blocked. A way to get around this is to authenticate over HTTPS instead, and supplying a username and password.

However, if two factor authentication is enabled, as it should be, this method will fail since the current interface does not support this. The solution is to create an authentication token to use for this specific machine.

@JonasAlfredsson
JonasAlfredsson / Fix_Firefox.md
Last active August 16, 2019 20:56
Some modifications to make Firefox behave more consistent with the Widows version, while also tweaking some security settings.

Firefox Custom Fixes

Firefox on Linux does some things different compared to the Windows counterpart. I generally prefer the Windows way these settings are configred, and the following settings are therefore made to improve the overall experience on Linux.

Open the Configuration Menu

All of these settings are accessed by typing

about:config
@JonasAlfredsson
JonasAlfredsson / Install_WSL_on_Windows_Server.md
Last active April 15, 2019 23:05
Guide on how to install and uninstall Windows Subsystem for Linux on Windows 10 Server (i.e. without Microsoft Store).

Windows Subsystem for Linux on Windows 10 Server

Microsoft seems to prefer you installed WSL through their Windows Store, but the problem is that this Store does not exist on the server versions of Windows 10. This gist is therefore my notes on how to install it manually, using PowerShell.

[The official guide][1] is already quite short and informative, so this will basically just be a recap with some informative notes throughout.

Enable WSL

@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

@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 / 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
# 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 / 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
@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] ]