• 1 Post
  • 11 Comments
Joined 1 year ago
cake
Cake day: June 24th, 2023

help-circle



  • itsnotlupus@lemmy.worldtoLinux@lemmy.mlraw man files?
    link
    fedilink
    arrow-up
    25
    ·
    edit-2
    1 year ago

    You can list every man page installed on your system with man -k . , or just apropos .
    But that’s a lot of random junk. If you only want “executable programs or shell commands”, only grab man pages in section 1 with a apropos -s 1 .

    You can get the path of a man page by using whereis -m pwd (replace pwd with your page name.)

    You can convert a man page to html with man2html (may require apt get man2html or whatever equivalent applies to your distro.)
    That tool adds a couple of useless lines at the beginning of each file, so we’ll want to pipe its output into a | tail +3 to get rid of them.

    Combine all of these together in a questionable incantation, and you might end up with something like this:

    mkdir -p tmp ; cd tmp
    apropos -s 1 . | cut -d' ' -f1 | while read page; do whereis -m "$page" ; done | while read id path rest; do man2html "$path" | tail +3 > "${id::-1}.html"; done
    

    List every command in section 1, extract the id only. For each one, get a file path. For each id and file path (ignore the rest), convert to html and save it as a file named $id.html.

    It might take a little while to run, but then you could run firefox . or whatever and browse the resulting mess.

    Or keep tweaking all of this until it’s just right for you.



  • Last I checked, there were at least 3 subreddits where cryptocurrency is being handed out regularly to active participants.
    They’re called “Community Points”, and get a custom name for each sub (“moons” in /r/cryptocurrency, “donuts” in /r/ethtrader, and “bricks” in /r/fortniteBR.)

    I don’t know how the other subs fared, but /r/cryptocurrency became noticeably gamed by actors attempting to maximize their financial gains.

    So… I guess it’s gonna be awesome.




  • One of my guilty pleasures is to rewrite trivial functions to be statements free.

    Since I’d be too self-conscious to put those in a PR, I keep those mostly to myself.

    For example, here’s an XPath wrapper:

    const $$$ = (q,d=document,x=d.evaluate(q,d),a=[],n=x.iterateNext()) => n ? (a.push(n), $$$(q,d,x,a)) : a;
    

    Which you can use as $$$("//*[contains(@class, 'post-')]//*[text()[contains(.,'fedilink')]]/../../..") to get an array of matching nodes.

    If I was paid to write this, it’d probably look like this instead:

    function queryAllXPath(query, doc = document) {
        const array = [];
        const result = doc.evaluate(query, doc);
        let node= result.iterateNext();
        while (node) {
            array.push(node);
            n = result.iterateNext();
        }
        return array;
    }
    

    Seriously boring stuff.

    Anyway, since var/let/const are statements, I have no choice but to use optional parameters instead, and since loops are statements as well, recursion saves the day.

    Would my quality of life improve if the lambda body could be written as => if n then a.push(n), $$$(q,d,x,a) else a ? Obviously, yes.


  • itsnotlupus@lemmy.worldtoaww@lemmy.worldDiscussion: AI Posts
    link
    fedilink
    English
    arrow-up
    5
    arrow-down
    1
    ·
    1 year ago

    You can either go full bonzai and aggressively trim any little branch that pokes out of place to try to keep a meticulously maintained tree at all times, or you can just let the tree grows as it will, and if a branch becomes an obvious issue, then just cut the entire branch and graft it somewhere else.

    If I was a mod here, I would do the latter, maybe even setup an /c/AIAww or whatever in anticipation for what might come.
    That’s probably my laziness speaking.