pgtan

Joined 12 years ago

Karma
328
Submissions
176
Member since
Nov 5
TeX, Emacs, netpbm, Imagemagick, Gentoo
View on Hacker News

Recent submissions

Comment · 4 months ago
Comment · 6 months ago
Here are two checks using joins, one with sqlite, one with the join builtin of ksh93:

  check_empty_vhosts () {
    # Check which vhost adapter doesn't have any VTD mapped
    start_sqlite
    tosql "SELECT l.vios_name,l.vadapter_name FROM vios_vadapter AS l
        LEFT OUTER JOIN vios_wwn_disk_vadapter_vtd AS r
    USING (vadapter_name,vios_name)
    WHERE r.vadapter_name IS NULL AND
      r.vios_name IS NULL AND
   l.vadapter_name LIKE 'vhost%';"
    endsql
    getsql
    stop_sqlite
  }

  check_empty_vhosts_sh () {
    # same as above, but on the shell
    join  -v 1  -t , -1 1 -2 1 \
   <(while IFS=, read vio host slot; do 
  if [[ $host == vhost* ]]; then
      print ${vio}_$host,$slot 
  fi
     done < $VIO_ADAPTER_SLOT | sort -t , -k 1)\
   <(while IFS=, read vio vhost vtd disk; do
  if [[ $vhost == vhost* ]]; then        
    print ${vio}_$vhost
  fi
     done < $VIO_VHOST_VTD_DISK | sort -t , -k 1)
  }
Comment · 11 months ago
Comment · 1 year ago
Actually pdftex or luatex, but you are completely right, it can load a pdf file and do a lot of things with it.
Comment · 1 year ago
socialism's new excuse to grab other people's money
Comment · 2 years ago
Does someone have stock portfolio of superconductor manufacturer to share? I watch Furukawa, Sumitomo, and AMSC and they are performing not bad.
Comment · 2 years ago
Comment · 3 years ago
Comment · 3 years ago
Comment · 3 years ago
OK, for starter the while loop. Main rule of writing shell scripts is, Use The Shell, Luke. Don't start external programs, if your shell (which is already running) can do it. "while /usr/bin/true" is nonsense, every time an external program gets executed for nothing. There are plenty of bash (since this shell is used in the example) internals, which evaluate to true, like ":", "test 1", "(( 1 ))", maybe others too. So "while :" should be better. But why even use dummy true statement, since the loop terminates with read? You can put the read as argument to while directly: "while read -r line; do" ... Same with echo and date. Just use one single printf builtin.

while read -r line ; do printf '%(%FT%T%z)T %-9s %s' -1 "$(/usr/bin/id --user --name --real)" "$line" ; done

Comment · 3 years ago
This bash code is a parade example how NOT to write scripts.
Comment · 3 years ago
Well, Kornshell (ksh93) has some nice programming features, much better than bash.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton