Jump to content

alfred-bitwise-evaluator


Recommended Posts

Dear Alfred users,

This workflow is mainly useful for developers, which needs to evaluate bitwise expressions. I hope you will find it useful.

 

Github: https://github.com/vookimedlo/alfred-bitwise-evaluator

 

alfred-bitwise-evaluator

Alfred 3 workflow for evaluating bitwise expressions.

Installation

  1. Install alfred-bitwise-evaluator workflow.
  2. All further updates are handled automatically.

Usage

In Alfred, type bitwise and enter your bitwise expression which shall be evaluated.

bitwise evaluate

Selected result is copied to your clipboard.

bitwise show all

Expression is being evaluated as you type the expression. If expression cannot be evaluated, either for illegal characters or syntax error, user will be notified about that.

bitwise show error

Bitwise expression syntax and operators precedence

Workflow is based on Perl, therefore it uses its syntax and operators precedence, which is easy to use. The golden rule in programming languages is the following: "If you are unsure about the operator precedence, always use parentheses to be sure what you are doing.". It's not a shame!

OPERATOR NAME SYNTAX
Bitwise NOT ~a
Bitwise AND a & b
Bitwise OR a
Bitwise XOR a ^ b
Bitwise left shift a << b
Bitwise right shift a >> b

Integer formats

The four formats listed below are printed.

INTEGER FORMAT SYNTAX EXAMPLE
Decimal 1234
Binary 0b1110011
Hexadecimal 0x1234
Octal 01234

Workflow Keyword

The default workflow keyword bitwise could be changed in alfred workflow settings. This variable will not be overwritten once the new workflow update is installed.

bitwise workflow configuration

Note

Before the expression is evaluated, input data will be checked for illegal characters. If those are found, evaluation will not continue. This is done for making the workflow harmless. If you remove this check, you could evaluate any Perl code, which could be pretty dangerous. Do that only if you know what you are doing!!!

 

Edited by Vookimedlo
Updated to be in sync with the most recent workflow version.
Link to comment
  • 9 months later...

I really find this workflow useful and have been using it a lot.

 

Would it be possible to add to it, so that instead of having to press a modifier key to copy different results other than binary and then view them, the result in both decimal, hex, binary and octal is immediately printed to the screen as four separate items in Alfred? And then copying a result is just done by selecting the corresponding item?

Link to comment

I really wanted the feature I describe above, so I went ahead and modified the code to achieve this behaviour. I don't have any experience with Perl, so I guess the stuff I have rewritten is pretty poorly written code, but for now it works. This is what is now shown when the workflow is called with an expression that can be evaluated:

RMgMDW7.png

 

And this is what it looks like when you insert an expression that can't be evaluated:

VcHG7dL.png

 

I have forked the original repo and made a pull request. For now, the modified workflow can be downloaded from here,

Link to comment
On 10/8/2018 at 1:24 AM, shmulvad said:

I really wanted the feature I describe above, so I went ahead and modified the code to achieve this behaviour. I don't have any experience with Perl, so I guess the stuff I have rewritten is pretty poorly written code, but for now it works. This is what is now shown when the workflow is called with an expression that can be evaluated:

RMgMDW7.png

 

And this is what it looks like when you insert an expression that can't be evaluated:

VcHG7dL.png

 

I have forked the original repo and made a pull request. For now, the modified workflow can be downloaded from here,

 

Merged back to trunk. New release is available.

The original post above was updated with the current readme.

 

Thanks!

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...