Posts

    Day 455

    Qutebrowser edit url in editor

    config.bind('E', 'set-cmd-text -s :edit-url') added to config.py allows me to press E and the command will be prefilled.

    Interesting arguments 1:

    -b, --bg: Open in a new background tab.
    -t, --tab: Open in a new tab.
    -w, --window: Open in a new window.
    -p, --private: Open a new window in private browsing mode.
    

    Keyboard layout changes

    Made the following changes and bumped the version to v5:

    // Changing aoeu for umlauted letters
    
        key <AC01> { [	    a,	A, adiaeresis,	s]	};
        key <AC02> { [	    o,	O, odiaeresis,	n]	};
        key <AC03> { [	    e,	E, ediaeresis,	t]	};
        key <AC04> { [	    u,	U, udiaeresis,	u]	};
    
    // Adding ~` to the better key for this
    
        key <AD01> { [  apostrophe,	quotedbl,	grave,	asciitilde] };
        key <AD02> { [	comma,	less,   r, asciitilde] };
    // Adding parentheses in a better place
    
        key <AD08> { [	    c,	C,	Up,	 parenleft	]	};
        key <AD09> { [	    r,	R,	BackSpace,	parenright		]	};
    
        key <AD07> { [	    g,	G,	bracketleft,	braceleft		]	};
        key <AD10> { [	    l,	L,	bracketright,	braceright]	};
    
    // Numbers!
    
        key <AB01> { [   semicolon,	colon,1,	exclam] };
        key <AB02> { [	    q,	Q,	2,	at		]	};
        key <AB03> { [	    j,	J,	3,	numbersign		]	};
        key <AB04> { [	    k,	K,	4,	dollar		]	};
        key <AB05> { [	    x,	X,	5,	percent		]	};
        key <AB06> { [	    b,	B,	6,	asciicircum]	};
        key <AB07> { [	    m,	M,	7,	ampersand]	};
        key <AB08> { [	    w,	W,	8,	asterisk]	};
        key <AB09> { [	    v,	V,	9,	asterisk]	};
        key <AB10> { [	    z,	Z,	0,	asterisk]	};
    
    // A new delete key
        key <AC06> { [	    d,	D,	KP_Delete,	asterisk]	};
    

    Now I have brackets on my right hand letters :) I’ll think later what other symbols I still have not learned by heart and move the below. (Numbers, maybe?)

    Fiamma userscript update

    Updated the userscript to the following, now it removes stuff Mediawiki doesn’t like from the name of the page (but not from the Title, which is not part of the URL!)

    #!/usr/bin/python3
    import os
    from urllib.parse import quote_plus
    
    def urlencode(string):
      return quote_plus(string)
    
    def replace(original):
        new = original.replace("|", "-")
        return new
    
    def replace_name(original):
        new = original.replace("|", "-")
        new = new.replace("[", "(")
        new = new.replace("]", ")")
        new = new.replace("#", "(hash)")
        new = new.replace("{", "(")
        new = new.replace("}", ")")
        new = new.replace("_", " ") # TODO test
        return new
    
    title = os.environ['QUTE_TITLE']
    url = os.environ['QUTE_URL']
    selected_text = os.environ['QUTE_SELECTED_TEXT']
    
    newTitle = replace(title)
    newArticleName = replace_name(title)
    newUrl = replace(url)
    newText = replace(selected_text)
    print(newTitle)
    
    article_title = urlencode(newTitle)
    article_name = urlencode(newArticleName)
    page_url = urlencode(newUrl)
    selected_text = urlencode(newText)
    
    fiammaUrl = 'https://pchr8.net/f/index.php'
    url = fiammaUrl+'?title='+article_name+'&action=edit&preload=Template:NewLink&preloadparams[]='+page_url+'&preloadparams[]='+article_title+'&preloadparams[]='+selected_text
    
    with open(os.environ['QUTE_FIFO'], 'w') as f:
        f.write("open -w {}".format(url))
    

    Random / Interesting

    This is a nice wikipedia page that starts with “Q.” and not with “Q:”, because “Q:” is forbidden as start of page name: Q. Are We Not Men? A: We Are Devo! - Wikipedia

    Pizza dough

    I’ll try to do this tomorrow: The Best Pizza Dough Recipe - Sugar Spun Run

    Mattermost and Python

    For when I get to this, it’s easy, after I install matterhook:

    >>> mwh = Webhook('https://chat.mycompany.de', 'myAPIhook')
    >>> mwh.send('test',channel='notif')
    

    Very nice explanation here: GitHub - numberly/matterhook: Interact with Mattermost incoming webhooks easily.

    Python run from command line / shell with all the imports and stuff

    Say I’m in folder2 and want to run folder2/folder/main.py

    python3 -m folder.main adds folder2 to $PATH, while python3 folder/main.py adds folder to $PATH. The first option makes all imports much much easier.


    Day 453

    Giving names to screen sessions

    To set a name to a screen session to make attaching it easier, you either set it as parameter during screen creation (screen -S screenname) or set it from inside an attached screen by typing <C-a> :sessionname screenname. It will look like that:

    There are several suitable screens on:
    	74720.trying_to_run_GPU	(03/28/20 00:33:28)	(Attached)
    	70666.whatisthis	(03/28/20 00:20:53)	(Detached)
    

    (Setting a name for a screen session - Unix & Linux Stack Exchange)

    To attach it I can use only its name: screen -raAd whatisthis

    TODO actually read the man pages and have a better understanding of these flags instead of treating them like incantations.

    watch command set interval and highlight changes

    This is nice! To watch a file grow in size, except watch ls -lar you can do watch -d -n 1 ls -lar. -d makes it highlight the differences, and -n for some reason is the interval. (-i was taken I guess).

    Use only one GPU for training in Tensorflow

    I keep googling this, so: export CUDA_VISIBLE_DEVICES=2

    And to set an environment variable before running the script (in bash at least) it’s TEST=foo; echo $TEST (shell - How do I set an environment variable on the command line and have it appear in commands? - Unix & Linux Stack Exchange). export is just to make it available for other commands.

    Random

    It’s quite cute how google interprets me looking for kitty paths linux as cat paths linux, as in I believe that they are kinda similar in many contexts.

    That said, it’s very refreshing to see a program where reading the config file documentation on its official website doubles as basic tutorial for the program, since all the keyboard shortcuts used in the example config are the real ones.

    Tensorboard & SSH tunnelling

    Not sure why this surprises me, but I can first start a SSH shell that does a tunnel (.. and opens a SSH shell), then from it start the thing on the port that I am tunnelling. This almost looks like something I could automate if I do it often enough.

    English

    ferine - Wiktionary - “pertaining to wild, menacing animals” - same in Italian. First seen here: Ninco Nanco - Wikipedia.

    German

    speiseöl | Übersetzung Englisch-Deutsch is basically any cooking oil.

    Book about baking bread

    If you want to learn more about the process and jump off the deep end, Peter Reinhart’s book “The Bread Baker’s Apprentice” is a great place to start. It is detailed without being pedantic, simple without being over-simplified, and oriented for the home baker without forgetting the reasons that professionals do things the way they do.

    Why do you need to refrigerate bread dough overnight? - Seasoned Advice


    Day 452

    German

    • papierdeutsch – Wiktionary - in trockener, komplizierter deutscher Sprache; im Papierdeutsch. Found when looking for a synonim for ‘baldigst’
    • abwertend – Wiktionary - opposite of ‘lobend’/’positiv’. Found it as description of ‘papierdeutsch’ :)

    Day 451

    History is happening

    Hilariously aggressive Covid-19 propaganda banners in China - SupChina

    Not gathering for a feast is so you can eat in the future, Not visiting others is so you still have relatives in the future

    Everyone you encounter on the streets now is a wild ghost seeking to take your life

    Stay in and don’t wander around, You have AC, television, and wifi as your friends

    Kitty zoom (=change font size)

    To zoom in/out in Kitty:

    map ctrl+shift+equal change_font_size all +1.0
    map ctrl+shift+minus change_font_size all -1.0
    

    Fiamma qutebrowser userscript

    Edited the userscript to pass selected text as a third parameter to the NewLink template, to which I added the third parameter, and removed the automatic closing of the window from the vim macro.

    i3 keybindings to move to / select a screen / output

    # focus outputs
    bindsym $ms+o focus output DP-1-1
    bindsym $ms+e focus output HDMI-2
    bindsym $ms+u focus output eDP-1
    

    Disable GPU in Tensorflow via environment variable

    How to disable GPU with TensorFlow? - Data Science Stack Exchange

    import os
    os.environ["CUDA_VISIBLE_DEVICES"] = "-1"

    .. or set it from outside the script.

    tf.shape(x) vs x.shape

    ..is 1 hour 58 minutes of debugging if it’s inside of a dataset.map(). It seems to return None inside .map(), and None==1 is False instead of an exception.


    Day 450

    Kitty - the terminal emulator

    Added bindsym $ms+Return exec ~/.local/kitty.app/bin/kitty to ~/.config/i3/config kitty - the fast, featureful, GPU based terminal emulator — kitty 0.17.1 documentation is really awesome actually, and noticeably faster than any other terminals I’ve used.

    TODO - read through the documentation linked above, esp wrt zooming and config.

    <Ctrl+Shift+F2> opens the config file. In general I love everything about Kitti for now, in all the tiny little details.

    Changes:

    font_family      FiraCode-Bold
    font_size 10.0
    cursor_blink_interval 0.5
    scrollback_lines 5000
    strip_trailing_spaces smart
    
    background_image ~/test.png
    background_image_layout tiled
    background_tint 0.7
    

    Random / interesting

    Waffle House Index - Wikipedia

    If you get there and the Waffle House is closed? That’s really bad… — Craig Fugate, Former Head of the Federal Emergency Management Agency

    Qutebrowser writing python userscripts

    Just wrote this and put it into ~/.local/share/qutebrowser/userscripts/yank.py.

    This is an userscript that allows me to escape my only problematic markdown character (|) when copying with ym:

    #!/usr/bin/python3
    import os
    
    title = os.environ['QUTE_TITLE']
    title = title.replace("|", "\\|")
    
    url = os.environ['QUTE_URL']
    
    with open(os.environ['QUTE_FIFO'], 'w') as f:
        f.write("yank inline \"[{}]({})\"".format(title, url))

    Added config.bind('ym', 'spawn --userscript yank.py') to config.py

    Python set environment variables

    Why did I need to use with open(..) as f: in the above script and couldn’t just do os.environ['sth']='sth else'?

    Taskwarrior task annotation

    It took seeing qutebrowser/taskadd at master · qutebrowser/qutebrowser to learn that you can annotate tasks in taskwarrior! task 123 annotate my annotation that can be long adds a visible line with the annotation under the task that is shown whenever the task is shown. This is awesome and I should read manpages sometimes.

    Keyboard layout

    I should finally put it in order, especially given that I mostly don’t use the left-hand part of the left-hand typing layout, I started today by putting my ` and ~ no LALT+SHIFT+apostrophe by adding this:

    key <AD01> { [ apostrophe,!quotedbl, grave, asciitilde] };

    to /usr/share/X11/xkb/symbols/v4

    Making Fiamma / Semantic Mediawiki alive again

    {{=}} template

    Using Template:= - Wikipedia as an example, I created a page located at = - Fiamma which I can include as {{=}} to replace URIs in parameters in my Template:B - Fiamma template. I’m not sure how would I edit all pages containing equal signs in parameters but this is a nice start. My source is Help:Template - Wikipedia, first bullet point.

    Same works for |, for which there’s already the default template {{!}}.

    New javascript bookmarklets qutebrowser userscripts!

    The old venerable bookmarklets I wrote about here Updated Fiamma “Add link” bookmarklet (now there are two of them!) | Я сам, соломка, чай. are as dead as it gets, I’ll write one userscript to rule them all :) Or one userscript and one vim script to expand it.

    Current iteration is:

    #!/usr/bin/python3
    import os
    from urllib.parse import quote_plus
    
    def urlencode(string):
      return quote_plus(string)
    
    def replace(original):
        new = original.replace("|", "-")
        return new
    
    title = os.environ['QUTE_TITLE']
    url = os.environ['QUTE_URL']
    
    newTitle = replace(title)
    newUrl = replace(url)
    
    et = urlencode(newTitle)
    eu = urlencode(newUrl)
    
    fiammaUrl = 'https://pchr8.net/f/index.php'
    url = fiammaUrl+'?title='+et+'&action=edit&preload=Template:NewLink&preloadparams[]='+eu+'&preloadparams[]='+et
    
    with open(os.environ['QUTE_FIFO'], 'w') as f:
        f.write("open -w {}".format(url))

    Pages to test this on:

    Running userscript in qutebrowser

    I had issues with commands executing too early, for example before the previous one has executed. So:

    config.bind('B', 'spawn --userscript open_fiamma_page.py')
    config.bind('T', 'hint inputs --first;; later 20 leave-mode;; later 20 open-editor')

    Lastly for some reason the “later” sometimes are interpreted as starting at the same time, not from the time the last command finished executing.

    Vim macros for the vimwin

    (sorry)

    
    " let @H = 'gg??c??bi??c??b{{B|^[^[^[j0i|^[^[^[ji|j?kb^[^[^[ji|^[^[^[o}};q' " For the 5 lines
    " let @L = 'ji{{$?kb%?kb#set:\^Mk=?kD^[o|+sep=,}}^[' " For the tags
    " let @C = 'i[[C;tj?kb?kb?kbategory: ^[^[^[A]];q' " For each individual category 
    " let @F = 'jjVG:norm! @C\^M' "Apply that to all lines till the end
    " let @d = '@H@L@F'
    " let @q = '^[A^[bbbbbbi|??^B?kb^[:%s/=/{{=}}/ge^M'
    
    " Summed up:
    let @C = 'i[[C;tj?kb?kb?kbategory: ^[^[^[A]];q' " For each individual category
    let @H = '^[A^[bbbbbbi|??^B?kb^[:%s/=/{{=}}/ge^Mgg??c??bi??c??b{{B|^[^[^[j0i|^[^[^[ji|j?kb^[^[^[ji|^[^[^[o}};qji{{$?kb%?kb#set:^Mk=?kD^[o|+sep=,}}^[jjVG:norm! @C^M:x^M'
    " let @d = '@H@L@F'
    
    

    The above changes text like:

    https://www.pchr8.net/d/dtb/
    Diensttagebuch - A purely technical blog about things I did on particular days, for future reference and search.
    5
    
    
    tag1, tag tag2, tag3
    
    Cat1
    Cat2
    And a category with space
    

    to

    
    {{B|https://www.pchr8.net/d/dtb/
    |Diensttagebuch - A purely technical blog about things I did on particular days, for future reference and search.
    |5
    |6
    }}
    {{#set:
    k=tag1, tag tag2, tag3
    |+sep=, }}
    
    [[Category: Cat1]]
    [[Category: Cat2]]
    [[Category: And a category with space]]
    
    

    For the above, jekyll had issues with utf-8 encoding and the escaped characters, so I copy-pasted them with my mouse from my terminal.

    Additionally it converts the equal sign to its template, and saves-and-closes gvim.

    … And with the glorious new page Waffle House Index - Wikipedia - Fiamma a new era for that wiki starts again!

    This raises the question about what is the role of this blog, but I think here we’ll stick to IT stuff

    Vim script omit “Pattern not found” error

    ..especially when writing macros that replace stuff. The magic is the e option at the end:

    :%s/x/y/ge

    And the vim macro / script doesn’t break anymore.

    DTB Master file

    Added some things to the concat.sh script, it’s even more ugly now but the resulting page is okay:

    echo "Concatting all existing days"
    cd _posts
    echo \
    "---
    layout: page
    title: Master file
    permalink: /master/
    ---
    "\
    > ../master_file.md
    
    cat * | grep -v "layout: post" | grep -v "categories: \[" | grep -v "title:  \"Day" | grep -v "date:   20" | grep -v "\-\-\-"  >> ../master_file.md

    Day 449

    Random / Interesting

    Why do color TVs make black and white snow? | Hacker News

    The other question is “why don’t you see that noise when the TV is tuned in?” The TV has automatic gain control. When the signal is weak, it will amplify it up to the right level. If the signal is just background noise, then it will amplify that background noise until it’s at the “right level” for a proper TV signal. So, the gain is lower for stronger signals, and very high when there is no signal at all.

    the artefacts created in the black and white picture by the colour signal are hardly noticeable, but they are enough to recover the colour from a black and white recording! The Unofficial Colour Recovery Wiki | Fandom

    Programmer competency matrix

    Programmer Competency Matrix – Sijin Joseph, I don’t agree with everything but looks like a nice blueprint

    Random

    xkcd

    Picture from xkcd what-if 0034 found on this article about evaluating LMs: Evaluation Metrics for Language Modeling and hotlinked from what-if 0034.

    Qutebrowser

    Added to config.py:

    c.tabs.pinned.frozen = False
    c.tabs.title.format_pinned = "{current_title}"
    

    German / Deutsch

    Cabinfever is der Lagerkoller.


    Day 448

    Bash print full path to a file

    I’m so glad this exists and I don’t have to do pwd+ls+copypaste anymore!

    # realpath example.txt
    /home/username/example.txt
    

    Not a default shell built-in, readlink -e (or -m or -f) does the same.

    (shell - bash/fish command to print absolute path to a file - Stack Overflow)

    Quotes

    Moses was fond of repeating at this time a quote often used in Albany. “You can get an awful lot of good done in the world if you’re willing to let someone else take the credit for it.” (The power broker by Robert A. Caro, p.315)

    xclip using it right

    Copy and paste at the Linux command line with xclip | Opensource.com

    The line is yourcommand | xclip -sel clip which is aliased to xc, so yourcommand | xc.

    scp port forwarding

    If I have something running on servername:6006 reachable only from 127.0.0.1 (on the server itself), I can do this: ssh -L 4000:127.0.0.1:6006 servername

    Which makes it available for me from my localhost as 127.0.0.1:4000

    To check if the thing running on servername can be reached from outside, netstat -tulpen

    A Guide to SSH Port Forwarding/Tunnelling - Boolean World

    qutebrowser tabs width

    Added this to qutebrowser’s config.py, two keybindings to make the tabs width smaller and back, to save screen space.

    config.bind('<Ctrl-L>', 'set tabs.width 10%;; set tabs.favicons.scale 0.8;; set tabs.indicator.width 0;;set tabs.title.format {index}:{current_title}')
    config.bind('<Ctrl-R>', 'set tabs.width 20%;; set tabs.favicons.scale 1;; set tabs.indicator.width 2;;set tabs.title.format {audio}{index}: {current_title}')

    English

    tetchy - “Easily annoyed or irritated; peevish, testy or irascible.”

    Podcasts

    Lost in Larrimah - Whooshkaa has 6 episodes 20 mins each and it sounds interesting.

    Python formatting

    PyFormat: Using % and .format() for great good! is a website dedicated completely to Python formatting that I could read through someday.

    History is happening

    Tutto bene (from Coronavirus: Italy bans any movement inside country as toll nears 5,500 | World news | The Guardian)


    Day 446

    History is happening

    My favourite corona-Dashboard has a nice new option to “align by date of 100th case”: Coronavirus charts

    It looks like this today:

    Corona Dashboard


    Day 445

    German

    The Mad Hatter in Alice im Wunderland in German is Der Hutmacher!

    Mediawiki + SMW update

    This was so so so easy, oh my God. Even though I was updating basically everything from a very old version, to a different PHP and MariaDB version.

    TL;DR move files, install manually my one extension needed, export/import mysql table data, point the wiki to the newly created table/db, run php maintenance/update.php and it just magically took care of everything. Only gotcha was that I forgot the db prefix, which gave me DBQueryError after restore; error in update.php on Project:Support desk, solved with the first google result. This was so much easier than expected.

    EDIT2 - forgot about Extension:ParserFunctions - MediaWiki, and a couple of smaller ones. So:

    # End of automatically generated settings.
    # Add more configuration options below.
    
    enableSemantics('pchr8.net');
    wfLoadExtension( 'ParserFunctions' );
    
    wfLoadExtension('CategoryTree');
    $smwgShowFactbox=SMW_FACTBOX_NONEMPTY;
    wfLoadExtension('NewestPages');

    EDIT3: Had to move the /images/ folder with its content. To check for them, Gallery of new files - Fiamma works

    Now live again at pchr8.net/f/

    EDIT4: properties seem to be broken and capitalized, which makes semantic search unusable. I’ll deal with it later.

    Jonatan Hui blog

    Jonathan Hui blog Mostly ML stuff in a static html blog.

    zsh setting and checking environment variables

    If I do: export PYTHON_PATH=$(pwd), then check it via $PYTHON_PATH hoping to see something like:\ zsh: command not found: Fr 20. Mär 19:48:01 CET 2020 - this won’t happen, as this is a path, and the result would be same as cd $PYTHONPATH, therefore outputting nothing and leaving me with the impression that the value was not being set.


    Day 444

    Changed font in the Terminal

    Changed the font from Fira Code Light to Fira Code Medium (EDIT: now Bold. True-bold text still gets rendered as extra-bold, which is very nice too!). It works much better on not-bright-enough screens that stand in front of too-bright windows.

    Tensorflow saving model weird errors about init things

    I could not save a Tensorflow Keras model, the issue was that I passed arguments from init as: self.whatever = whatever, then changed self.whatever to a different data type (string to b’ytes’ w/ .encode in my case), then in the get_config() function then I happily said {'whatever': self.whatever,} which then could not be encode()‘d.

    Random / interesting

    Granular convection - Wikipedia is the process where biggerr parts of something float above when surrounded by smaller parts of something and vibration.

    History is happening

    I’m not sure this is the place for this (oh wait, my blog, I decide the rules, it is now), but since the universe is interesting right now, I feel like preserving some parts. Not necessarily like a diary, just links that I feel will represent this interesting time better than many words could.


    Day 443

    Githubusing keys instead of passphrase

    Read more...

    Day 442

    Keras / Tensorflow why saving a subclassed model is hard

    Read more...

    Day 441

    Qutebrowser tab-give keybinding

    Read more...

    Day 437

    Toread

    How to Make Yourself Into a Learning Machine - Superorganizers - fascinating practical use of the Zettelkasten method, amongst other things - don’t have time for this now but I will read it later. + Using Anki to Remember Everything You Read | Hacker News as my source.

    Read more...

    Day 436

    Tensorflow Keras reset states of everything

    Everytime I call model.fit() it does NOT reset the weights, DOES reset the hidden states (such as RNN/LSTM), does NOT reset optimizer settings. machine learning - keras.fit() re-initialises the weights - Stack Overflow

    Read more...

    Day 434

    Matplotlib/pyplot reset styles

    If I set a style like paper with plt.style.use('paper') it changes some settings (esp. in Jupyter Notebook) that don’t get overwritten by the next calls to plt.style.use(). For this, plt.style.use('default') exists. (Found here: python - How to recover matplotlib defaults after setting stylesheet - Stack Overflow)

    Read more...

    Day 430

    Day 429

    Python imports

    Read more...

    Day 428

    Tensorflow running eagerly TODO

    What is the difference between setting run_eagerly while compiling a tf.keras model vs setting it after compilation vs tf.config.experimental_run_functions_eagerly(True)?

    Read more...

    Day 427

    Tensorflow Dataset API split to train/test

    Splitting a tf Dataset is surprisingly hard. Best option is

    Read more...


Subscribe