In the middle of the desert you can say anything you want
I should make use more often of the fact that @staticmethod
and @classmethod
methods can be called as self.mystaticorclassmethod()
in the “standard” methods.
(Another installment of “I should use tree
more”)
The running tests window has options, like “select first failed test on completion” and “scroll to end”.
Pycharm / intellij idea have an action called “Reopen closed tab”. Set it to <C-S-T>
a la Chrome, works nicely!
There’s also a default <C-A-left>
shortcut for last cursor location1 that does the same.
My current keymap looks like this:
<keymap version="1" name="XWin copy" parent="Default for XWin">
<action id="ActivateCommitToolWindow">
<keyboard-shortcut first-keystroke="shift alt 3" />
</action>
<action id="ActivateDebugToolWindow">
<keyboard-shortcut first-keystroke="shift alt 2" />
</action>
<action id="ActivateFavoritesToolWindow" />
<action id="ActivateFindToolWindow" />
<action id="ActivateMessagesToolWindow" />
<action id="ActivateProblemsViewToolWindow">
<keyboard-shortcut first-keystroke="shift alt 4" />
</action>
<action id="ActivateProjectToolWindow">
<keyboard-shortcut first-keystroke="shift alt 1" />
</action>
<action id="ActivateRunToolWindow" />
<action id="ActivateServicesToolWindow" />
<action id="ActivateStructureToolWindow" />
<action id="ActivateTODOToolWindow">
<keyboard-shortcut first-keystroke="shift alt 5" />
</action>
<action id="ActivateVersionControlToolWindow" />
<action id="CheckinProject">
<keyboard-shortcut first-keystroke="ctrl k" />
<keyboard-shortcut first-keystroke="ctrl alt c" />
</action>
<action id="DuplicatesForm.SendToLeft" />
<action id="DuplicatesForm.SendToRight" />
<action id="EditorDown">
<keyboard-shortcut first-keystroke="down" />
<keyboard-shortcut first-keystroke="altGraph t" />
</action>
<action id="FileChooser.GotoHome" />
<action id="FileChooser.GotoModule" />
<action id="FileChooser.GotoProject" />
<action id="FindNext">
<keyboard-shortcut first-keystroke="f3" />
</action>
<action id="GotoTest" />
<action id="IntroduceConstant" />
<action id="MoveEditorToOppositeTabGroup">
<keyboard-shortcut first-keystroke="ctrl alt l" />
</action>
<action id="NextSplitter">
<keyboard-shortcut first-keystroke="ctrl l" />
</action>
<action id="PrevSplitter">
<keyboard-shortcut first-keystroke="ctrl h" />
</action>
<action id="ReformatCode" />
<action id="ReopenClosedTab">
<keyboard-shortcut first-keystroke="shift ctrl t" />
</action>
<action id="ServiceView.ShowServices" />
<action id="Switch To Last Tab">
<keyboard-shortcut first-keystroke="alt period" />
<keyboard-shortcut first-keystroke="alt 0" />
</action>
<action id="Switch To Tab #1">
<keyboard-shortcut first-keystroke="alt 1" />
</action>
<action id="Switch To Tab #10">
<keyboard-shortcut first-keystroke="alt 0" />
</action>
<action id="Switch To Tab #2">
<keyboard-shortcut first-keystroke="alt 2" />
</action>
<action id="Switch To Tab #3">
<keyboard-shortcut first-keystroke="alt 3" />
</action>
<action id="Switch To Tab #4">
<keyboard-shortcut first-keystroke="alt 4" />
</action>
<action id="Switch To Tab #5">
<keyboard-shortcut first-keystroke="alt 5" />
</action>
<action id="Switch To Tab #6">
<keyboard-shortcut first-keystroke="alt 6" />
</action>
<action id="Switch To Tab #7">
<keyboard-shortcut first-keystroke="alt 7" />
</action>
<action id="Switch To Tab #8">
<keyboard-shortcut first-keystroke="alt 8" />
</action>
<action id="Switch To Tab #9">
<keyboard-shortcut first-keystroke="alt 9" />
</action>
<action id="TodoViewGroupByFlattenPackage" />
<action id="TypeHierarchy" />
<action id="TypeHierarchyBase.BaseOnThisType" />
<action id="Vcs.Log.FocusTextFilter" />
<action id="Vcs.ReformatCommitMessage" />
<action id="com.mikejhill.intellij.movetab.actions.MoveTabLeft">
<keyboard-shortcut first-keystroke="shift ctrl page_up" />
<keyboard-shortcut first-keystroke="ctrl comma" />
</action>
</keymap>
Added “Obsidian footnotes1” plugin, bound it to <C-R>
, adds numbered footnotes. Emulates my old vim footnote macro, except that footnotes are numbered and therefore automatic.
Ideally (for the master page, hypotetical merging of markdown files) I’d allow for non-automatic ones as I had in vim (I type whatever
, press the footnote shorcut, creates a footnote with index whatever
) and this would be a nice case for a simple obsidian template but I won’t be doing it in the near term.
find -size 0 -print -delete
, or find /foldername -size 0 -print -delete
.1
balenaEtcher - Flash OS images to SD cards & USB drives is mentioned in the official Mint installation guide1 and is quite neat!
No support for persistant storage like the good old unetbootin, but I guess still higher-level than dd
.
functools
has lru_cache
, really easy to add it as decorator to a function to cache the responses! Example directly copied from caching - Python in-memory cache with time to live - Stack Overflow:
from functools import lru_cache
import time
@lru_cache()
def my_expensive_function(a, b, ttl_hash=None):
del ttl_hash # to emphasize we don't use it and to shut pylint up
return a + b # horrible CPU load...
def get_ttl_hash(seconds=3600):
"""Return the same value withing `seconds` time period"""
return round(time.time() / seconds)
# somewhere in your code...
res = my_expensive_function(2, 2, ttl_hash=get_ttl_hash())
# cache will be updated once in an hour
Used it practically in some code that called an expensive external function multiple times. Bad code I didn’t have time to fix, but it took 2.5 seconds to run. Adding the lines above shortened the runtime from ~2.5 seconds to 0.02 seconds with cache lifetime of 60 seconds.
Didn’t update the function at all without the del ttl_hash
and default none parameter bit, TODO understand what’s really happening there.
This is really cool and of course historical document processing is an established research area: Introduction — dhSegment documentation
Git doesn’t track permissions, except whether the file is executable for the current user. 1
To recursively set all files (but not directories, because then you can’t ls
them…) to not-executable:
find . -type f -print0 | xargs -0 chmod -x
To unset this for current repo (--global
to unset this globally):
git config --local core.fileMode false
Goal: convert “2010-01-01” into “Day 1234”.
First tried to create a Hugo shortode, but you can’t use a shortcode inside a template:
Process: loading templates: ".../index.html:84:1": parse failed: template: index.html:84: unexpected "<" in command
Next step - a partial template! To call them one uses {{ partial templatename .}}
, with .
being the “context”. I passed .Key
, that has the groupBy date, and it works.
So, the partial template day.html
does ugly math to get the number of days since the first day of 2019:
{{ $date := (printf . | time) }}
{{ $startUnix := (printf "2019-01-01" | time) }}
{{ $diff := sub $date.Unix $startUnix.Unix }}
{{ $diffInDays := div $diff 86400}}
{{ $diffInDays }}
Then I use it inside templates like this:
<h2 class="title day">
{{ partial "day.html" .Key }}
</h2>