jeudi 1 juin 2023

Do not show a volume in finder (MacOSX)

 From https://www.idownloadblog.com/2016/12/02/how-to-hide-mounted-volumes-from-desktop-finder/


1) Ensure the volume that you want to hide is mounted and visible in the Finder, desktop, or Disk Utility.

2) Make a note of the chosen name of your volume, for example, Time Machine or Storage.

3) Launch Terminal and type the following command, replacing “Drive Name” with the name of your own volume, which you noted earlier (keep the quote marks):

sudo SetFile -a V /Volumes/"Drive Name"

4) Enter your password when prompted.

Note: Install command line developer tools if you’re prompted to do that.

5) In terminal: killall Finder

To revert :

sudo SetFile -a v /Volumes/"Drive Name"
killall Finder

lundi 3 avril 2023

Search a text within the file content in Unix and R

 In UNIX:

grep -rnw '.' -e 'texttosearch'

To search within the current directory '.' or 'path" to search in the path.
The options
-r means "recursive"
-e is the pattern to search for
-n Each output line is preceded by its relative line number in the file, starting at line 1.
-w The expression is searched for as a word (as if surrounded by ‘[[:<:]]’ and ‘[[:>:]]

Do not hesitate to do a man grep to see the dozens of options!


In R, a equivalent using "brut force" (without recursive option) is found in the package HelpersMG (https://CRAN.R-project.org/package=HelpersMG) :
inside(
  text = stop("A text to be searched for is necessary"),
  path = ".",
  pattern = "*\\.R$",
  showallfilenames = FALSE,
  ...,
  fixed = TRUE,
  ignore.case = FALSE
)

dimanche 26 mars 2023

Indistinguishable Objects to Distinguishable Boxes

# Indistinguishable Objects to Distinguishable Boxes

# The number of different ways to distribute Nballs indistinguishable balls into

# Nboxes distinguishable boxes is C(Nboxes+Nboxes-1,Nboxes-1).

# For example, 5 balls into 3 boxes can be done in these C(7,2) = 21 ways:


# Number of balls

Nballs <- 10

# Number of boxes

Nboxes <- 3


# The number of different ways to distribute n indistinguishable balls into

# k distinguishable boxes is C(n+k-1,k-1).

# nb<-choose(N+nbjour-1,nbjour-1)=dim(tb)[1]

# divers<-matrix(rep(0, nbjour*nb), ncol=nbjour)


# generate all possible positions of the boundaries

xx <- combn(Nballs+Nboxes-1, Nboxes-1)

# compute the number of balls in each box

a <- cbind(0, diag(Nboxes)) - cbind(diag(Nboxes), 0)

tb <- t(a %*% rbind(0, xx, Nballs+Nboxes) - 1)



mercredi 22 mars 2023

Install spymicmac on Ubuntu 22.04 with Anaconda3 installed

 Software micmac can be found here:

https://spymicmac.readthedocs.io/en/v0.1.1/setup.html

When installation was tried using the setup from this page, an error was throwing in relation with qt5. It seems that there was a mistake with Anaconda qt5 installation.

The solution has been to find the directory of installation of qt5 using:

locate /qt5/plugins/

In our case, it was:

/usr/lib/x86_64-linux-gnu/qt5/plugins

Then, rather than doing:

cmake .. -DWITH_QT5=1 -DWERROR=0 -DWITH_CCACHE=OFF

as indicated in the spymicmac documentation, use:

cmake .. -DWITH_QT5=1 -DWERROR=0 -DWITH_CCACHE=OFF -DCMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu/qt5/plugins



samedi 1 octobre 2022

Uninstall iSCSI Initiator X

 The method to uninstall iSCSI Initiator X in the web site of the editor is wrong:

https://www.kernsafe.com/help.aspx?product=iSCSI%20Initiator%20X&topic=macos-iscsi-initiator-uninstallation

use rather:

sudo rm -rf /Library/KernSafe

sudo rm -rf /Library/KernSafe-iSCSI-Initiator-X-3.20

sudo rm -rf /Applications/"iSCSI Initiator X.app"

sudo rm -rf /Library/LaunchDaemons/com.kernsafe.initiator.x.plist

And restart


jeudi 1 septembre 2022

prevent apt to stop updates in Ubuntu 22.04

 In Ubuntu 22.04, the needrestart command, which is part of the apt-get upgrade process in Ubuntu, by default this is set to "interactive" mode which causes the interruption of scripts.

To change this behavior, we can edit the /etc/needrestart/needrestart.conf file, changing the line:

#$nrconf{restart} = 'i';

to

$nrconf{restart} = 'a'; (if we want to restart the services automatically) or $nrconf{restart} = 'l'; to simply list the services that need restart.

Another trick:

To disable "Pending kernel upgrade" via command line:

sudo vim /etc/needrestart/needrestart.conf

then uncomment this line

#$nrconf{kernelhints} = -1;

jeudi 18 août 2022

sudo reports an error

 Check that your hostname is well declared in /etc/hosts:

mgirond@pepa:~$ hostname

xxxx

mgirond@pepa:~$ cat /etc/hosts

127.0.0.1 localhost

127.0.0.1 xxxx


# The following lines are desirable for IPv6 capable hosts

::1 ip6-localhost ip6-loopback

fe00::0 ip6-localnet

ff00::0 ip6-mcastprefix

ff02::1 ip6-allnodes

ff02::2 ip6-allrouters

ff02::3 ip6-allhosts