Friday, August 25, 2017

A More Efficient If (VM Code) Than Shimon's

Shimon (or one of his underlings - maybe Yaron)

expression
if-goto IF_TRUE0
goto IF_FALSE0
label IF_TRUE0
if-statements
goto IF_END0
label IF_FALSE0
else-statements
label IF_END0

when all you really need is :

expression
if-goto IF_TRUE0
else-statements
goto IF_END0
label IF_TRUE0
if-statements
label IF_END0

So, why would they choose to implement the less optimal thing?

Monday, August 21, 2017

VMEmulator Help - Can't Set Value of a RAM Word

If you have your Animation set to "No Animation", then you won't be able to. So, change that to "Program Flow", set your RAM, and then revert..

Sunday, August 13, 2017

Jack FAQ

Are fields private? Accessible only to methods? Or, if you have an object, can you do

obj.field from anywhere?

Can't find a good FAQ on their web :(

Wednesday, August 9, 2017

When python pip Spoils the Party

Your old version of pip tells you :

You should consider upgrading via the 'python -m pip install --upgrade pip' command.

Then, when you try :

$ python -m pip install --upgrade pip
/usr/bin/python: No module named pip

Thank you Guido!

Fortunately, googling got me

$ pip install -U pip

threw out a tonne of errors about permissions (this is Cygwin), but seems to be working okay..

$ pip --version       makes me happy

Tuesday, August 8, 2017

Python CSV to Excel (xlsx) Thanks to pyexcel

import pyexcel
import glob
import sys
import re
import os

# $ python script.py arg1 [arg2]
# # arg2 optional, arg1 not. arg1 a path to dir or *.csv or specific.csv
# arg2 can be -merged or specfic.xlsx
# if multiple infiles are seen, then if no arg2, each file will result in unique .xlsx

if ( os.path.isdir( sys.argv[1] ) ) :
    infiles = glob.glob( sys.argv[1] + '/*.csv' )
elif ( re.search( '.csv' , sys.argv[1] ) ) :
    infiles = glob.glob( sys.argv[1] )
else :
    sys.exit()

if ( len( sys.argv) > 2 ) :
    if ( re.search( '-merged' , sys.argv[2] ) ) :
        pyexcel.merge_csv_to_a_book( infiles , 'merged.xlsx' )
    elif( re.search( '.xlsx' , sys.argv[2] ) ) :
        pyexcel.merge_csv_to_a_book( infiles ,  sys.argv[2] )
else :
    for file in infiles :
        pyexcel.merge_csv_to_a_book( [file] , file.replace( '.csv' , '.xlsx' ) )