keinerweiss.de
2022/04/09

Heureka - Blog

The small success stories are the ones that count.

Python slow when concatenating strings

I was concatenating translation file contents to one string and observed rather long runtimes.

Turns out Python is not very efficient in this regard. So I reworked it to use a list.

strings_test.py
import time
 
start = time.time()
str1 = ""
for i in range(1,10000000):
    str1 += "A"*1000
print("Concat took: " + str(time.time() - start))
 
start = time.time()
str1 = ""
str2 = []
for i in range(1,10000000):
    str2.append("B"*1000)
print("List collection took: " + str(time.time() - start))
 
start = time.time()
str1 = "\n".join(str2)
print("Final join took: " + str(time.time() - start))
Concat took: 4.820241689682007
List collection took: 0.9731082916259766
Final join took: 2.7453043460845947

Solved: Chrome does not store passwords anymore

For some reason my Chrome did not autofill stored passwords anymore.
The list of stored passwords was empty and even when I saved a new password, the next time it would not be autofilled.

Problem: maybe the local database broke.

Solution: Force to reload the list from the Cloud by removing the local database.

Under Linux that is:

cd ~/.config/google-chrome/Default
mv ./Login\ Data-journal ./Login\ Data-journal.bak
mv ./Login\ Data ./Login\ Data.bak

Credits: https://unix.stackexchange.com/questions/538482/chrome-does-not-save-my-passwords

i3: Disable all shortcuts when gaming

I was playing Biomutant and accidentally made it close several times because of the key bindings the game used in busy fight situations.

The use of Q W A S D E, Alt and Shift made me slip to the super key quite often. Super+Shift+Q in my case kills an application. Not so good while fighting.

Solution: modes.

When in a mode, new key bindings apply, which basically disables all usual bindings for the time being.

So I added a mode "play_game" with no bindings except the one to exit the mode (which is the same as how to enter).

I used the Scroll-Lock key which is very far from any key I might press.

bindsym Scroll_Lock mode "play_game"

mode "play_game" {
        bindsym Scroll_Lock mode "default"
}

You are here: start » keinerweiss.de » Heureka - Blog