grex is a library as well as a command-line utility that is meant to simplify the often complicated and tedious task of creating regular expressions. It does so by automatically generating a single regular expression from user-provided test cases. The resulting expression is guaranteed to match the test cases which it was generated from.
As Stefan shows: simply type in some terms into grex that you want to match and the RegExp comes out … 🤯
I just learned about the CLI tool `grex`. It might change how I approach regular expressions (🤞🙈).
MirrorDisplays a simple application that toggles between mirrored and extended desktop modes. It’s the easiest way to turn on, or turn off display mirroring.
Also comes with a (separately installable) CLI tool which makes this pretty interesting
The command line tool is good for giving shell-scripts the power to control display mirroring and opens up the possibility of controlling mirroring remotely over ssh.
usage: mirror [option] Only the first option passed will be applied
-h Print this usage and exit.
-t Toggle mirroring (default behavior)
-on Turn Mirroring On
-off Turn Mirroring Off
-q Query the Mirroring state and write "on" or "off" to stdout
-l A B Makes display at index B mirror the display at index A
Unfortunately not installable using Homebrew, so you’ll have to get the app from the GitHub releases page. You’ll also have to explicitly allow the mirror CLI tool to be opened through the Security & Privacy
Recently I needed to base64-encode a string. To do this I turned to the CLI and piped the output of echo to base64.
# Don't use! Correct command further down this post.
$ echo 'test' | base64
Although the output looks quite good, things didn’t quite work out when using the string: it failed when used in an implementation.
Tracking down the issue I worked my way back and decided to double check the base64-encoded string (dGVzdAo=) for its correctness. Using PHP I re-encoded the input and voila:
$ php -r "echo base64_encode('test');"
That’s different output … and it’s also to correct result. But how come? Is base64 on the CLI wrong?
Don’t worry, base64 on the CLI works fine. The problem we’re having here is further upstream, namely with the use of echo. By default echo will append a newline to its output, and that’s why base64 is returning an unexpected result.
Thankfully echo has a -n switch to suppress the trailing newline. By using that, things work as expected:
# Add -n to echo to prevent it from adding a newline
$ echo -n 'test' | base64
Let this post act as a note to my future self … 😅
Did this help you out? Like what you see? Thank me with a coffee.
I don't do this for profit but a small one-time donation would surely put a smile on my face. Thanks!
bandwhich sniffs a given network interface and records IP packet size, cross referencing it with the /proc filesystem on linux or lsof on macOS. It is responsive to the terminal window size, displaying less info if there is no room for it. It will also attempt to resolve ips to their host name in the background using reverse DNS on a best effort basis.
The other day I opened up a PHP project that I hadn’t worked on in a while. No longer remembering which Composer Scripts I had defined for it, I needed to take a peek inside composer.json to see which ones were available to me. Then it hit me: why is there no autocompletion for composer available?
The code builds further upon this earlier work by Rob Allen. Key area where it differs from Rob’s work is that composer-autocomplete also provides autocompletion for composer run-script, listing which Composer Scripts are available to you(as I initially wanted).