This is a script meant to log stream of consciousness thoughts. In practice, I use this is a sort of lab-notebook for software and blog projects (and you can too!).
To start, just launch handy with no arguments and start typing. It will create a file called handy.txt and start appending what you write as time stamped lines in that text file. The next time you launch handy, it will read in this file and pick up right where you left off.
You can also specify the name of the file that the script writes to by providing the file name as the first command line argument:
python handy.py myfile.txt
It supports Windows and Mac (it might run on Linux too, but I don't have a linux box to check), and looks like this:
In addition to logging text, Handy also supports a number of utility features that I added to make my life easier. Here they are:
- Addition and Subtraction
- Bit Shifting
- Radix Conversion
- Two's Complement Conversion
- Ascii Values
- Inline Comments
- Clipboard Support
You can also do simple addition / subtraction between two numbers of different radixes (or the same radix, if you want to).
Similar to above, you can compute the result of a bit shift operation using "<<" and ">>" operators between two numeric values. One potentially unexpected behavior with this is that if you right-shift a binary value, handy will left pad the result with zeroes so the result displayed has the same length as the original input being shifted. This behavior does not apply to left shifts (which will add digits to the binary value).
If you enter a hex, decimal, or binary string, handy will convert it to the other two radixes for you:
If you enter a negative integer, it will be represented as a 2's complement hex / binary string when converted. This only works within the range of a 32 bit signed int. This conversion only works from negative int -> Hex / Binary, you currently can't input a hex value and convert it to an int assuming it's a 2's complement val.
Entering a single char, wrapped in single quotes (ie: 'A') will convert it to an ASCII byte value. You don't need to escape any value in between the leading and trailing quotes (so ''' is valid, as is '"'). Entering more than 1 char in between quotes won't work, and will be treated as a plain string.
With both of the above, if you want to append a comment to the log after the conversion or calculation, you can use the "//" to specify text you'd like to append:
This is just to aid in readability. You can omit the "//" and just start writing a string as well, it just formats differently.
I've found that some terminals don't handle the clipboard nicely (like the Windows Powershell terminal). For instances where whatever terminal you're running in prevents you from pasting with ctrl+v, the tab key will also paste into handy.
The code is terrible (but what code isn't). I don't write python enough to know what "pythonic" code is, and this whole thing grew by accretion with no clear plan. It does what I want it to do though, so I'm not going to bother cleaning it up (possibly ever). yolo.