:::: MENU ::::
Browsing posts in: Snippets

Multiple PHP versions on MAC via Homebrew

Great post about having multiple PHP version in your console: https://getgrav.org/blog/macos-monterey-apache-multiple-php-versions.

Few snippets from the post:

brew tap shivammathur/php
brew install shivammathur/php/php@7.0
brew install shivammathur/php/php@7.1
brew install shivammathur/php/php@7.2
brew install shivammathur/php/php@7.3
brew install shivammathur/php/php@7.4
brew install shivammathur/php/php@8.0
brew unlink php && brew link --overwrite --force php@7.3

Rename multiple files with find and rename

Nice shorthand to rename multiple files. First, make sure you have rename available:

brew install rename

and then use the snippet

find . -exec rename 's|FIND|REPLACE_WITH|' {} +

Dump python requirements for file or folder but not for the whole project

I don’t want to dump requirements for my whole project using:

pip freeze > requirements.txt

Instead of that I want to dump requirements for a file or particular folder. It’s a piece of cake with pipreqs. Install the package

pip install pipreqs

and then just run it with the folder or file for which you want to generate requirements.txt file

pipreqs my_folder

What is your IP from the world perspective?

Often I have to make sure how I am visible to the world – what is my IP address that some service will see. I’ve found a great tool for that – ifconfig.me. You can see a lot of useful details via a browser but you can use it in console as well!

curl ifconfig.me

and you’ll have your IP address!

curl ifconfig.me
> 37.47.XXX.XXX

or even more details with:

curl ifconfig.me/all