LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs > Michael Uplawski
User Name
Password

Notices


  1. Old Comment

    I am gaining distance.

    About 150 new trees, since yesterday and the pruning of another hundred or so, really made a lot more sense than the two hours that an AI-supported translation of my manual-page has taken me to complete. The next time, you do that yourself, I am unavailable.
    Posted 03-12-2024 at 02:14 PM by Michael Uplawski Michael Uplawski is offline
  2. Old Comment

    Found the old replace command

    nice one @the_dsc
    Posted 07-04-2023 at 05:15 AM by ychaouche ychaouche is offline
  3. Old Comment

    Found the old replace command

    Quote:
    Originally Posted by jr_bob_dobbs View Comment
    So I re-read this blog again.
    Recently I started a text file with the name of each of my programs and a line or two explaining what each one does. This saves me from writing a program twice because I forgot what the first version was called! This has been a big help! You might want to do this?
    Great idea. Sometimes I find myself writing scripts twice, funnily enough, at least once, even with the same file name. I should adopt something like this.

    For functions, I have some bash functions in a file following a simple "not-even-markup" code-formatting, and one of those functions lists all functions, "lsfunctions," printing things in a "formatted" way, reading from the functions file itself :

    Code:
    #!/bin/bash
    
    bold=$(tput bold)
    normal=$(tput sgr0)
    
    lsfunctions ()
    {
    tail -n+10 /$HOME/scripts/functions | grep "()" | sort|  sed "s|(.*#||;s|^|${bold}|;s|\ |${normal}\ |"
    } 
    
    cblowercase() # converts clipboard to lowercase
    {
    xclip -o | tr '[:upper:]' '[:lower:]' | xsel -i
    }
    
    [...]
    Code:
    $ lsfunctions 
    cblowercase converts clipboard to lowercase
    cbuppercase converts clipboard to uppercase
    c  - command line calculator, bc.  
    cdc cd $clipboard
    [...]
    The "not even markup" thing is just the comment following the function declaration on the same line, used by grep to find both the function name and the definition.

    "tail -n+10" is limitting the following grep to everything after the first ten lines of the "functions" file, since there's little point in have lsfunctions explaining itself.

    Not sure it if was my idea to begin with, I probably copied it from someone else, maybe in this very forum.

    I think one can even come up with a fancier parser, expanding things like "\n" into newlines and whatnot.

    It's perhaps also not that hard to come up with some function that would do this kind of "homemade apropos" thing but for user scripts, given that they also have some kind of header that the function parses, and that they're on a specific location, I guess.
    Posted 07-03-2023 at 03:59 PM by the dsc the dsc is offline
  4. Old Comment

    False statement

    If you are attracted by the scientific method, maybe take a look at René Descartes and his “Discours on the Method”, the founding document of today's scientific research method.

    The method had been developed for himself because he was fed up with ad hoc interpretations and experimental evidence that was impossible to reproduce (and also... he has had too much time on his hands). His own findings were about 98% rubbish, as he was starting from wrong assumptions. But he provided the means for later scientists to prove it.

    If he lived today, Descartes would himself be the first to laugh about the statement “René, I do not want to be harsh, but your scientific work is utter bull!”, then invite you for a drink. Because that is what he wanted: Create a base for others to work on. Unfortunately his theories were so well explained that they stayed valid for much too long...

    Pour examiner la vérité, il est besoin, une fois dans sa vie, de mettre toutes choses en doute autant qu’il se peut.

    To examine truth, it is necessary, once in a lifetime, to put all things into question, as much as it can be done.
    Posted 01-23-2023 at 06:55 AM by Michael Uplawski Michael Uplawski is offline
    Updated 01-27-2023 at 06:45 AM by Michael Uplawski
  5. Old Comment

    spellcheck in qutebrowser

    Logic is overrated.
    Posted 12-13-2022 at 11:35 AM by Michael Uplawski Michael Uplawski is offline
  6. Old Comment

    Handwritten Web-Pages

    Quote:
    Originally Posted by ychaouche View Comment
    This is wild. Does every scan require unique optimization or are there presets you can save once and apply many times? I'm thinking about things like reducing the number of nodes for every curve for example.
    You are putting the right questions. Not just the right *kind* of question.
    I have inquired about automation somewhere else but gain the impression that automating SVG-manipulations is not yet something that many people think about. The Inkscape developers are as engaged as they probably should be and the discussions on ... git(hub|lab) ... are usually enlightening.

    But for the time, I venture that you have to program the necessary routines yourself.
    My own endeavor to render links on fine-lined objects more comfortable to click, has not advanced.

    What it needs to automate SVG editing is knowledge of XML. Most programming environments offer routines for standard-tasks and even libraries. Those know – however – nothing about SVG paths and stuff...

    I am perplex myself. SVG is officially cool and widely used. A paradox.

    Grouping of tasks and batch-routines would be one solution to many problems. AFAIS, Inkscape will not be able to this in the near future.
    Posted 11-26-2022 at 04:55 AM by Michael Uplawski Michael Uplawski is offline
    Updated 11-26-2022 at 05:00 AM by Michael Uplawski
  7. Old Comment

    spellcheck in qutebrowser

    b/c you mentioned qutebrowser?
    Posted 10-26-2022 at 08:42 AM by ychaouche ychaouche is offline
  8. Old Comment

    spellcheck in qutebrowser

    Quote:
    Originally Posted by ychaouche View Comment
    I tried a couple "alternative" web browsers.
    Why do you write that?
    Posted 10-26-2022 at 06:40 AM by Michael Uplawski Michael Uplawski is offline
  9. Old Comment

    Found the old replace command

    @uplawski
    Funny enough, mysql-server ships with a replace command.

    Code:
    $ package.whatprovides /usr/bin/replace
    mysql-server-5.5
    $

    @jr_bob_dobbs
    I too used to forget how I named my scripts and bash functions/aliases, then I started grouping them in "packages" and make the most out of tab completion so that I don't need to remember their names anymore, one of them is the package.whatprovides function I used above. The other tools in the "package" package (very confusing name for an example) are :

    Code:
    # package.<tab>
    package.count           package.files.local     package.install         package.list.all        package.list.updatable  package.search.byfile   package.whatprovides
    package.describe        package.files.remote    package.is.installed    package.list.files      package.remove          package.search.byname
    # package.
    I also have my "mail" utils
    Code:
    # mail.<tab>
    mail.access.external.live                   mail.exchange.from.outside                  mail.log.exchange.search.bysender           mail.spam.rules.edit                        mail.users.password.change
    mail.alias.edit                             mail.exchange.live                          mail.password.checkstrength                 mail.user.detail                            mail.users.password.change.fromcsv
    mail.alias.global.count                     mail.exchange.recievers.sorted              mail.queue.summary.sorted.bydate            mail.user.info                              mail.users.password.change.fromcsv.auto
    mail.alias.global.disable                   mail.exchange.report                        mail.queue.watch                            mail.user.new                               mail.users.password.changes
    mail.alias.global.enable                    mail.exchange.report.wonotifs               mail.sec.failauth.expect                    mail.user.quota                             mail.users.password.changes.lastn
    mail.alias.open                             mail.exchange.senders.sorted                mail.sec.failauth.get                       mail.user.rename                            mail.users.password.changes.lastn.numbered
    mail.alias.remap                            mail.exchange.storage.live                  mail.sec.failauth.live                      mail.user.rename.from.csv                   mail.users.password.check
    mail.alias.search                           mail.exchange.to                            mail.sec.failauth.report                    mail.users.count                            mail.users.search.loose
    mail.alias.show                             mail.hosts.connections.live                 mail.sec.failcop                            mail.users.disable                          mail.users.search.normal
    mail.dsn.follow                             mail.hosts.sorted                           mail.spam.check.ip                          mail.users.enable                           mail.users.search.strict
    mail.dsn.get                                mail.hosts.top                              mail.spam.check.ip.list                     mail.users.lastn
    mail.dsn.live                               mail.imap.activity.all                      mail.spam.live                              mail.users.lastn.numbered
    mail.dsn.report                             mail.imap.activity.live                     mail.spam.report                            mail.users.login.via.roundcube.live
    mail.exchange.from                          mail.log.exchange.search.byreceiver         mail.spam.rule.describe                     mail.users.login.via.roundcube.report
    # mail.

    And some handy "net" utils
    Code:
    # net.<tab>
    net.connexions                              net.connexions.dropped.report               net.connexions.whatconnectsto               net.ip.reverse                              net.port.probe.remote
    net.connexions.by.application.live          net.connexions.from.application             net.ip.info                                 net.paste
    net.connexions.by.application.live.numeric  net.connexions.from.outside                 net.ip.private                              net.port.name
    net.connexions.dropped.live                 net.connexions.to.outside                   net.ip.public                               net.port.probe.local
    # net.

    Most of them are functions and aliases with a few exceptions (for eg. when the code needs to be called from an awk script, in that case I write it as a standalone bash script).

    I also like grouping them together in their source files and adding some funny boxes around them to make them stand out.
    Code:
    #           __   _,--="=--,_   __
    #          /  \."    .-.    "./  \
    #         /  ,/  _   : :   _  \/` \
    #         \  `| /o\  :_:  /o\ |\__/
    #          `-'| :="~` _ `~"=: |
    #             \`     (_)     `/
    #      .-"-.   \      |      /   .-"-.
    # .---{     }--|  /,.-'-.,\  |--{     }---.
    #  )  (_)_)_)  \_/`~-===-~`\_/  (_(_(_)  (
    # (            Network/Internet           )
    #  )                                     (
    # '---------------------------------------'
    
    
    function net.paste {
    if (($# == 0)) 
    then
        curl -kF "clbin=<-" "https://clbin.com"
    else
        curl -kF "clbin=<-" "https://clbin.com" < "$1"
    fi
    }
    alias net.ip.private="ifdata -pa $INTERFACE"
    alias net.ip.public='curl ifconfig.me; echo'
    function net.port.probe.local(){ _asroot lsof -i ":$1"; }
    function net.port.probe.remote(){ nmap "$1" -p "$2" ;}
    function net.port.name(){ grep "\b$1\b" /etc/services; }
    function net.ip.reverse(){ local IFS; IFS=.; set -- $1; echo $4.$3.$2.$1; }
    [...]
    
    
    #         _\|/_
    #         (o o)
    # +----oOO-{_}-OOo-+
    # |    Packages    |
    # +---------------*/
    
    alias package.count='package.list | wc -l'
    
    function package.list.all {
        current=$(pwd)
        cd /var/lib/dpkg/info
        function x {
    	for filename in /var/lib/dpkg/info/* 
    	do 
    	    x=${filename#/var/lib/dpkg/info/*}; 
    	    echo ${x%.*}
    	done
        }
        x | sort | uniq
        cd $current
    }
    
    
    function package.list.updatable {
        function _package_description { 
    	read input;
    	dpkg -l ${input} | grep " ${input} " | awk '{$1=$2=$3=$4=$5=$6="";print $0 }' | sed 's/^ */,/';
    	unset input;
        }
    
        function _updatable { 
    	apt-get --just-print upgrade 2>&1 | 
    	perl -ne 'if (/Inst\s([\w,\-,\d,\.,~,:,\+]+)\s\[([\w,\-,\d,\.,~,:,\+]+)\]\s\(([\w,\-,\d,\.,~,:,\+]+)\)? /i) {print "$1 ,$2, $3 \n"}';
        }
        _updatable | while read -r line; do echo -en "$line $(echo $line | awk '{print $1}' | _package_description )\n"; done;
    }
    
    function package.describe {
        apt-cache show "$1" | grep-dctrl -s Description-en -
    }
    
    alias package.is.installed="dpkg-query -W"
    alias package.search.byname="apt-cache search"
    alias package.search.byfile="apt-file search"
    function package.list.files { dpkg -L "$@" 2>/dev/null || apt-file list "$@"; }
    alias package.install='_asroot apt-get install'
    alias package.remove='_asroot apt-get remove'
    function package.whatprovides { dpkg -S "$1" | cut -f1 -d: | sort | uniq ; }
    [...]
    Posted 07-28-2022 at 10:50 AM by ychaouche ychaouche is offline
  10. Old Comment

    download radio broadcasts in mp3 format

    Nokogiri is a nice addition to the web scrapping tools like pup and webscraper.io.
    I don't know how to use any of the three, but I hope I get the opportunity to use
    them and play with them someday.

    I came to know pup when Microsoft took over github and removed youtube-dl for
    copy-right infringement (maybe by fear of having a lawsuit by some of its many
    adversaries? but that's another topic). As a reaction, people started writing
    replacement software, and one of them was a simple bash script that was like under
    50 lines of code that would download media from youtube using "pup" and "jq", two
    tools I never heard of before.

    Then searching for webscraping tools I also discovered webscraper.io, which took
    on the task of identifying the paths for you, with a fair degree of precision, all
    with a visual tool like the developer bar of your favorite browser that let you
    point and click on the elements of the page to inspect their HTML and CSS properties,
    along with their paths and other useful information.

    Thanks for the nice share!
    Posted 07-28-2022 at 07:41 AM by ychaouche ychaouche is offline
  11. Old Comment

    Handwritten Web-Pages

    This is wild. Does every scan require unique optimization or are there presets you can save once and apply many times? I'm thinking about things like reducing the number of nodes for every curve for example.
    Posted 07-28-2022 at 05:05 AM by ychaouche ychaouche is offline
  12. Old Comment

    False statement

    Quote:
    Science is doubt. Not assertion.
    That's some powerful quote. It inspired me to search for more. I was not disappointed :

    Quote:
    Science is a thoroughly conscious ignorance.
    Attributed to James Maxwell.

    source : https://www.wired.com/2012/07/firestein-science-doubt/
    Posted 07-28-2022 at 04:16 AM by ychaouche ychaouche is offline
  13. Old Comment

    spellcheck in qutebrowser

    I tried a couple "alternative" web browsers when I became unhappy with firefox's IO problems.
    The list includes palemoon, seamonkey, k-meleon, qupzilla, dillo, Dooble, and Midori.
    None of them work for the modern web (mainly, the support for Web Componenents which
    websites and web apps like yahoo mail, linkedin etc. are fond users of).
    Posted 07-28-2022 at 04:04 AM by ychaouche ychaouche is offline
  14. Old Comment

    Obsolete: xpath / Nokogiri: Find all nodes in a SVG path.

    As there are absolute and relative coordinates in a <path/>, the latter must be transformed to absolute values if they will serve to position a new graphical object on the same canvas.

    My sought procedure to calculate the bounding box of an arbitrary path must include a path-parser: It must “react” to path commands (like 'M', 'm', 'z'), then either store the following coordinates or transform them to 'absolute values'. Interruptions within the same path must be detected (subsequent 'm', 'M' after 'z') and new “initial points” be set accordingly.

    I will program this but already feel on my way to solve the riddle...

    There is a bunch of software around which does exactly that, but (HELL!) I do not like it. And I want to know what I do. “Other software” does a lot more than I want and lacks code comments. If I must rely on rubbish code, it should be my own rubbish! – I do not reinvent the wheel, but make square wheels round and smooth.
    Posted 06-21-2022 at 12:38 AM by Michael Uplawski Michael Uplawski is offline
    Updated 06-21-2022 at 12:42 AM by Michael Uplawski ('z')
  15. Old Comment

    spellcheck in qutebrowser

    Hello Michael,
    if Max-Planck-Gymnasium means something to you, please write me an eMail at jhaberer (at) gmx ...
    Thanks
    Joachim

    P.S. If you are the wrong recipient, sorry!
    Posted 12-30-2021 at 04:39 AM by JoDerBaer JoDerBaer is offline
  16. Old Comment

    Unbuffered shell-input

    No worries on the language, I just wanted to confirm what it was you were actually looking for.

    Within the context of the tty/terminal driver you commonly see it referred to a 'raw' vs 'cooked' input rather than the more verbose "non-line-buffered" I used.
    Posted 10-19-2021 at 05:27 AM by GazL GazL is offline
  17. Old Comment

    Unbuffered shell-input

    The non-blocking/unbuffered confusion is due to my reading English texts which only vaguely evoked the documentation that I had in German.
    Posted 10-19-2021 at 12:46 AM by Michael Uplawski Michael Uplawski is offline
  18. Old Comment

    Unbuffered shell-input

    Quote:
    Originally Posted by GazL View Comment
    I may be misunderstanding your requirements, do you really mean non-blocking, or do you mean non-line-buffered?
    As far as I remember, my search for a solution produced examples with non-blocking input. So I considered this the correct terminology. I understand unbuffered just as well an cannot say why I would prefer one expression over the other. This is a language problem and I will correct my blog post, when I find better translations. Thank you for pointing it out.

    Quote:
    If the latter, will read -r -s -N1 not serve your needs?
    It does. Believe it or not, I would have expected that the built-in read command were mentioned in the man-page to Bash, where it is not, and thus executed read --help for the very first time, this evening.

    Thanks again,
    Michael
    Posted 10-18-2021 at 03:15 PM by Michael Uplawski Michael Uplawski is offline
  19. Old Comment

    Unbuffered shell-input

    I may be misunderstanding your requirements, do you really mean non-blocking, or do you mean non-line-buffered?

    If the latter, will read -r -s -N1 not serve your needs?
    Posted 10-18-2021 at 04:19 AM by GazL GazL is offline
  20. Old Comment

    False statement

    Quote:
    Originally Posted by jr_bob_dobbs View Comment
    And here I was expecting for an expansion of the information on the false command given in its man page.

    Do nothing, unsuccessfully.
    You are probably commenting on-topic, however.
    Posted 04-06-2021 at 12:27 AM by Michael Uplawski Michael Uplawski is offline

  



All times are GMT -5. The time now is 09:37 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration