Firehose Weekly fuel for the dev firehose


# permalink

find executable

Search for executable files using find command

answered by GreenGiant - Stack Overflow

On GNU versions of find you can use -executable:

find . -type f -executable -print

For BSD (and MacOS) versions of find, you can use -perm with + and an octal mask:

find . -type f -perm +111 -print

In this context "+" means "any of these bits are set" and 111 is the execute bits. Note that this is not identical to the -executable predicate in GNU find. In particular, -executable tests that the file can be executed by the current user, while -perm +111 just tests if any execute permissions are set.


# permalink

tips

Create a new user who is a member of the same groups as the current user.

$ groups
users lp wheel dialout video audio render docker autologin

$ printf "%s\n" $(groups) | sort
audio
autologin
dialout
docker
lp
render
users
video
wheel

tr '\n' ',' translates the newlines into commas, converting the list of groups into a comma-separated string

sed 's/.$//' uses sed (stream editor) to remove the last character (which will be the trailing comma from the previous step)

$ printf "%s\n" $(groups) | sort | tr '\n' ',' | sed 's/.$//'
audio,autologin,dialout,docker,lp,render,video,wheel

$ my_groups=$(printf "%s\n" $(groups) | sort | tr '\n' ',' | sed 's/.$//')
$ sudo useradd \
    --comment "Hullo" \
    --gid sudo \
    --groups $my_groups \
    --create-home \
    --no-user-group \
    newuser

# using short options
$ sudo useradd -g users -G $groups -m -N newuser

# permalink

yay AUR helper

Yay is a command-line tool to install and manage software from the Arch User Repository. It is included in the community repository of Manjaro Linux.

> pacman -Ss yay
community/yay 10.0.4-1
    Yet another yogurt. Pacman wrapper and AUR helper written in go.

> sudo pacman -S yay
> man yay
> yay --help

# upgrade system
> yay -Syyu

# remove stale packages
> yay -Qdt
> yay -R $(yay -Qdtq | xargs)

# cleanup
> yay -Sc --noconfirm

# edit PKGBUILD
> mkdir ~/AUR_local && cd ~/AUR_Local
> yay --getpkgbuild julius-game
:: Querying AUR...
:: Downloaded PKGBUILD (1/1): julius-game
> ls julius-game/
total 12K
-rw-r--r-- 1 user0 user0  173 Sep 22 11:04 julius-game.desktop
-rw-r--r-- 1 user0 user0  145 Sep 22 11:04 julius-game.install
-rw-r--r-- 1 user0 user0 1.4K Sep 22 11:04 PKGBUILD
> cd julius-game
> vi PKGBUILD
> makepkg -si

# show foreign packages
# i.e those not belonging to official repos
# yay -Q --foreign
> yay -Qm

# info about AUR package
> yay -Si ktlint
:: Querying AUR...
Repository      : aur
Name            : ktlint
Keywords        : None
Version         : 0.38.1-1
Description     : An anti-bikeshedding Kotlin linter with built-in formatter
URL             : https://ktlint.github.io/
AUR URL         : https://aur.archlinux.org/packages/ktlint
....

# permalink

fast inverse square root

source: Fast inverse square root - Wikipedia

Fast inverse square root, sometimes referred to as Fast InvSqrt() or by the hexadecimal constant 0x5F3759DF, is an algorithm that estimates 1/sqrt(x), the reciprocal (or multiplicative inverse) of the square root of a 32-bit floating-point number x floating-point

float Q_rsqrt( float number )
{
	long i;
	float x2, y;
	const float threehalfs = 1.5F;

	x2 = number * 0.5F;
	y  = number;
	i  = * ( long * ) &y;                       // evil floating point bit level hacking
	i  = 0x5f3759df - ( i >> 1 );               // what the fuck?
	y  = * ( float * ) &i;
	y  = y * ( threehalfs - ( x2 * y * y ) );   // 1st iteration
//	y  = y * ( threehalfs - ( x2 * y * y ) );   // 2nd iteration, this can be removed

	return y;
}