Sunday, August 30, 2020

Wireless Hello World

That means - you press a (possibly virtual) button and an LED lights up someplace else.

https://www.youtube.com/watch?v=OhnxU8xALtg

 Arduino, HC-05 bluetooth module, breadboard, processing, sketch, blue control Android app

Google search that was useless : "what is the easiest way to get a notification on your phone from a device at home?"

Another one "do you need a subscription to get notifications from home kit devices?"

Wednesday, January 15, 2020

Set Up Raspberry Pi's WiFi Access Through Windows

Okay, had heard that, once you have the card ready for the Pi, it's also readable on the PC - in an intelligible way.

Tried the card from 5 years ago - and, when I plug it in (it's an SD, not microSD BTW - for the version 1 Pi)- I get two new USB drives showing - one readable, the other saying "Need to format." No thanks.

But, with the brand new one I just got, when I plug in, I get..

four new drives! And yes, there's a boot(G:) that does have the wpa_supplicant.conf

So, let's see :)

Yes, that gets the Pi showing up when you run nmap through the Zenmap GUI (for those of you who are wary of the Russian alternative - Advanced IP Scanner).

But, try getting in with ssh and... connection refused. *d Caleb Bergquist. Be thorough man!

Turns out, you need a file in your boot directory called ssh - just an empty file. And that will take care of it. My advice, go to Cygwin and then /cygdrive/g and touch it and you're done. Notepad++ manages to still give you grief, though I'm sure it's Windows to be blamed.

But, beware - what do you do if you've booted up your Pi and now can't turn it off for want of being able to connect? Caveman :( You have to connect a USB keyboard and then, very carefully,

CTRL-ALT-F1 and then very carefully, "sudo shutdown -h now" and see the LED blink 10 times and then you're good to pull the plug.

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' ) )

Wednesday, May 17, 2017

A Handy Debugging Tip If You're Using Python

You want to run until a certain condition is satisfied - because, once you get to an advanced level and you're analyzing the 'class' rule, you're up against subtle fails..

python -m pdb SynAnal Square/SquareTokens.xml

> break 115 , rule == 'paramList'

> c

Now, you get straight to the action. Nice?

Check out some Python performance tips here : https://wiki.python.org/moin/PythonSpeed

Tuesday, May 9, 2017

Jack Grammar - Only Rules Support * and ? - Not Primitives

After coding, I had to use Excel to see this - rather than comb through my text. The power of visualization..

Part of it is doing a rule using a formula : (in the box, type)

=AND( ISNUMBER(B2), B2 > 1 )

class
1
1
1
3
3
1
class
 keyword
 identifier
 symbol
 rule
 rule
 symbol
classVarDec
1
1
1
3
1
classVarDec
 keyword
 rule
 identifier
 rule
 symbol
addlVarDec
1
1
addlVarDec
 symbol
 identifier
type
1
type
 keyword||identifier
subroutineDec
1
1
1
1
1
1
1
subroutineDec
 keyword
 keyword||rule
 identifier
 symbol
 rule
 symbol
 rule
parameterList
2
parameterList
 rule
params
1
3
params
 rule
 rule
param
1
1
param
 rule
 identifier
addlParam
1
1
addlParam
 symbol
 identifier
subroutineBody
1
3
1
1
subroutineBody
 symbol
 rule
 rule
 symbol
varDec
1
1
1
3
1
varDec
 keyword
 rule
 identifier
 rule
 symbol
statements
3
statements
 rule
statement
1
statement
 rule
letStatement
1
1
2
1
1
1
letStatement
 keyword
 identifier
 rule
 symbol
 rule
 symbol
index
1
1
1
index
 symbol
 rule
 symbol
ifStatement
1
1
1
1
1
1
1
2
ifStatement
 keyword
 symbol
 rule
 symbol
 symbol
 rule
 symbol
 rule
elseBlock
1
1
1
1
elseBlock
 keyword
 symbol
 rule
 symbol
whileStatement
1
 expression
 )
1
1
1
whileStatement
 keyword
 symbol
 rule
 symbol
 symbol
 rule
 symbol
doStatement
1
1
1
doStatement
 keyword
 rule
 symbol
returnStatement
1
2
1
returnStatement
 keyword
 rule
 symbol
expression
1
3
expression
 rule
 rule
subExp
1
1
subExp
 symbol
 rule
term
1
term
 rule
constant
1
constant
 integerConstant||stringConstant
arrayElem
1
1
1
1
arrayElem
 rule
 symbol
 rule
 symbol
paranthExp
1
1
paranthExp
 symbol
 rule
 symbol
unOpTerm
1
1
unOpTerm
 symbol
 rule
subroutineCall
1
subroutineCall
 rule
simpleCall
1
1
1
1
simpleCall
 identifier
 symbol
 rule
 symbol
classMethCall
1
1
1
1
1
1
classMethCall
 identifier
 symbol
 identifier
 symbol
 rule
 symbol
expressionList
2
expressionList
 rule
expressions
1
3
expressions
 rule
 rule
addlExpr
1
1
addlExpr
 symbol
 rule
keywordConstant
 true|false|null|this
keywordConstant
 keyword