Pages

Saturday, June 28, 2025

How to Install and Configure NVIDIA Graphics Card in FreeBSD

 

[SKIP - NOT USED] Install driver for NVIDIA Graphics Card

pkg install nvidia-driver
sysrc kld_list+="nvidia nvidia-modeset"
sysrc linux_enable="YES" 

[SKIP - NOT USED] Configure the NVIDIA driver in a configuration file

cat >> /usr/local/etc/X11/xorg.conf.d/20-nvidia.conf << EOF
Section "Device"
    Identifier "Card0"
    Driver     "nvidia"
    BusID     "pci0:0:1:0"  
EndSection
EOF

[SKIP - NOT USED] NVIDIA configuration (it creates /etc/X11/xorg.conf)

pkg install nvidia-xconfig
nvidia-xconfig

Tuesday, June 17, 2025

How to get VMs with specific custom attribute?

Here is the Onliner to list VMs with custom attribute "Last Backup" ...

Get-VM | Select-Object Name, @{N='LastBackup';E={($_.CustomFields | Where-Object {$_.Key -match "Last Backup"}).Value}} | Where-Object {$_.LastBackup -ne $null -and $_.LastBackup -ne ""}

and here is the another one to count the number of such VMs ...

Get-VM | Select-Object Name, @{N='LastBackup';E={($_.CustomFields | Where-Object {$_.Key -match "Last Backup"}).Value}} | Where-Object {$_.LastBackup -ne $null -and $_.LastBackup -ne ""} | Measure-Object | Select-Object Count

 

How to get all VMs restarted by VMware vSphere HA? PowerCLI OneLiner below will do the magic ...

Get-VIEvent -MaxSamples 100000 -Start (Get-Date).AddDays(-1) -Type Warning | Where {$_.FullFormattedMessage -match "restarted"} | select CreatedTime,FullFormattedMessage | sort CreatedTime -Descending | Format-Table


Sunday, June 15, 2025

How to compress PDF file in Linux

I'm using Linux Mint with xsane for scanning documents on my old but still good Canon MX350 printer/scanner. Scans are saved as huge PDF documents (for example 50 MB) and I would like to compress it to consume much less disk space.

Install Ghostscript

apt install ghostscript

Compress the file input.pdf

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output_compressed.pdf input.pdf

Let's break down these options

  • -sDEVICE=pdfwrite: Tells Ghostscript to output a PDF file.
  • -dCompatibilityLevel=1.4: Sets the PDF version. Version 1.4 is quite old but widely compatible and often allows for good compression. You can try 1.5 or 1.6 for slightly more modern features and potentially better compression in some cases.
  • -dPDFSETTINGS=/ebook: This is the main compression control. As mentioned, /ebook usually gives a good balance.
  • -dNOPAUSE -dQUIET -dBATCH: These make Ghostscript run silently and non-interactively.
  • -sOutputFile=output_compressed.pdf: Specifies the name of the compressed output file.
  • input.pdf: original 50 MB PDF.

Lossy compression (322x) from 50 MB to 155 KB without any visible degradation is worth to keep cloud (Google drive) costs low.


Sunday, June 1, 2025

My VIM configuration file

My preferred editor in unix-like systems is vi or vim. VI is everywhere and VIM is improved for scripting and coding.

Below is my VIM config file /home/dpasek/.vimrc

 syntax on  
 filetype plugin indent on  

 " Show line numbers  
 set number  

 " Show relative line numbers (optional, good for motions like 5j/5k)  
 " set relativenumber  
 " Highlight matching parentheses  
 set showmatch  

 " Enable auto-indentation  
 set smartindent  
 set autoindent  

 " Use spaces instead of tabs, and set width (adjust to taste)  
 set expandtab  
 set tabstop=4  
 set shiftwidth=4  
 set softtabstop=4  

 " Show line and column in status line  
 set ruler  

 " Show partial command in bottom line  
 set showcmd  

 " Show a vertical line at column 80 (optional)  
 set colorcolumn=80  
 
 " Disable VIM mouse handling and keep it to terminal  
 set mouse=  

 " Enable persistent undo (requires directory)  
 set undofile  
 set undodir=~/.vim/undodir  
 
 " Make backspace behave sanely  
 set backspace=indent,eol,start  
 
 " Enable searching while typing  
 set incsearch  
 set hlsearch     " Highlight all matches  
 set ignorecase    " Case insensitive search...  
 set smartcase     " ...unless capital letter used  
 
 " Status line always visible  
 set laststatus=2