Playing with Python

It’s been 15+ years since I have received a coding assignment, so recently, I decided to try moving in the opposite direction from Assembly, C, and Reverse engineering, and decided to take a course on Udemy for learning python.

So far, it is an excellent course.  If you are interested the course is located here.

The assignment:  create a Tic Tac Toe game in Python.  The results are as follows:

https://github.com/idarthjedi/TicTacToe/blob/master/tictactoe.py

Resurrection of Animals – you ask?

For my Christian friends:

I’m a logical person, I eat animals as much as I have them as pets, I won’t hold to false hopes, but I didn’t hear any logical, biblical, or otherwise, facts offered in the video below that a friend posted.

Do animals go to Heaven?

I think a more complete treatment can be found here:  

Will Spot be in Heaven?

Short version,  man and animal are different, but the bible is (mostly) silent to resurrection of animals.

I would say that I can’t tell what Paul is up to when he claims all of creation groans for resurrection and redemption, especially if it only means complete and utter annihilation and destruction for all created things but humans.

We know that the whole creation has been groaning as in the pains of childbirth right up to the present time. 23Not only so, but we ourselves, who have the firstfruits of the Spirit, groan inwardly as we wait eagerly for our adoption to sonship, the redemption of our bodies. 24For in this hope we were saved. But hope that is seen is no hope at all. Who hopes for what they already have? 25But if we hope for what we do not yet have, we wait for it patiently

What do you think?

Blessings in disguise

Today, I had the opportunity to be the hands and feet of Jesus; and I hesitated, and I lost out. I was left with a feeling of love, and wonder and shame.  Here is the story.

You need to have this background first:  I work in an area that is quite a bit run down, in the two years I have been here, there have been stabbings and shootings in the parking lot.

I have recently taken to walking through the parking lot to a gas station half a block over to a Subway.  It’s not the cleanest looking gas station, I feel a little out of place in my dress clothes; but the people are polite, and nice, and the food area is clean and well kept.

Today, as I was walking through, there was a fella outside picking through trash cans; as I walked by, he stood up and started shuffling his way behind me.  Given my background, I have a heightened level of situational awareness; so I watched him closely out of the corner of my eye, and then through the reflection of windows and cars.  No issues.

After I ordered, inside, and had a pleasant and familiar discussion with the ladies behind the counter, this same fella came stomping in.  Once again, my level of awareness increased. He stomped to the back of the store to grab a drink, and then over to the sandwich counter.

To the reply of the lady behind the counter he very gruffly said “I want a sandwich with everything on it”.  It seemed clear he was slightly intoxicated.

As I walked over to pay, racing through my mind was the fact that I knew this fella couldn’t pay for his own food.  Once I ascertained there seemed to be no immediate threat, I tried to rationalize how he went from picking out of the trash to buying a sandwich and drink.  Slowly, in my mind, crept the thought that I could pay for his sandwich, I had the means, and I could see a storm brewing.

As I started thinking through all the ways I could do it, without becoming ‘personally involved’, in less than the couple minutes that I stood there trying to rationalize what I was going to do, and how, an elderly lady came through the door and said over my shoulders to the cashier, “I’m going to pay for his sandwich”.

I was immediately overwhelmed with various emotions.  First, love and compassion for someone who would see a random stranger picking through trash, and instead of immediately viewing them as a threat, and running through scenarios on how to contain that threat, she went over and asked if she could help.

Then, shame, that as a young, relatively healthy human, with means, I would stand there contemplating for so long whether or not I should help, and he had a clear need. The book I bought on Amazon this morning cost more than the price of his meal.  I was rationalizing, because I didn’t want the “messiness” of dealing with the humanity of the situation.

In the end, I lost the opportunity to be the hands and feet of Jesus, but I got to witness someone, whether in Christ or not, was faithful to their fellow human, to part of the Message.  It was a blessing in disguise.

Perhaps, next time, I’ll stop thinking, and start doing.

35 For I was hungry and you gave me something to eat, I was thirsty and you gave me something to drink, I was a stranger and you invited me in, 36 I needed clothes and you clothed me, I was sick and you looked after me, I was in prison and you came to visit me.

 

He is Jealous for me..

I was recently asked about my relationship with Jesus. I realized that I openly and always share my knowledge,  but rarely share my personal feelings; those intimate areas deep down in the recesses of my heart and soul. 

My relationships are very personal; like my relationship with my wife: I don’t walk around talking about it, and trying to explain the importance of her to me.  It’s such a personal part of me.  Words cannot adequately describe, it is for me, and her, and not for you: I don’t even try. 

Yet, I do talk about what it is like to be married, to have that special connection, that special someone, that safe place to be emotionally, spiritually and physically unclothed and unashamed.

So, while I can’t adequately describe my personal relationships, I can describe what it is like to have them.

If you have such a relationship, you will recognize this refrain; if you don’t, I hope that someday you will be found and enveloped into the most wonderful, indescribable, uncontainable existence.

God chose me.  Not for any merit, not for what I had to offer, before the foundations of the world; He knew me, called me, justified me, and is in the process of making me into the image of Jesus.

The things I do, say and think separate me from God; Jesus is my defense attorney, my friend, and confidant.  He knows everything about me, and still loves me.  He is patient with me in my failings, and compassionate, He provides for my personal, spiritual and family needs.  

How He loves me.

Just below the surface

​My seven year old son, out of the blue, quivering with tears, just came to ask mom why his parents didn’t want him, and soon after, with the same tears streaming down his face, came to tell me:

“thank you, thank you for adopting me, I’ll always love you, so much”.  

Talk about a tear jerker;  I guess some wounds run deep below the surface even when you don’t see them.

Another dark night has passed

I followed the BLM protests in NPN very closely tonight.  I have very close friends with dark skin – some of my children have real dark skin; not the hey-you’re-really-mulatto-not-African, but real, direct-descendants-from-Africa, dark skin.  Yet, whatever your color, if you want to identify with those with ‘black skin’: let me say this: Dark skin is beautiful, but white skin is too; so is every. shade. in-between.

In fact, it’s really the people behind the color that are beautiful, not the color itself – and some people, despite their color, are rotten.  Can you really judge everyone who shares a certain shade of melanin by the actions of other similar shades?  Every person is unique, every situation is different;  It isn’t the skin color that makes you who you are; it is who you are inside and what you do, that makes you who you are.

That said, the racism card is stupid; the distinction based on skin color is stupid: people are people.

As it relates to tonight’s local protests: I have no idea what blocking traffic does to accomplish the recognition that people are people; but I’m glad there was no reported violence – at least that still leaves our local community with the option to move forward with life without fear of continuous reprisals.

I am proud of our community that it remained non-violent; and yet ask of us all: aren’t there better ways?

family_2015

Teach your children at home, to understand that we are all created in His image; formed from the same seed, valued in the same way.  Don’t teach division and segregation.

Independence day 2016

Spending time over the last two years in both Boston and Virginia learning about the revolutionary war and incidiary environment which bred the realization that there could be a better world.

Saw statistics today that less than 30% of our United States of America have faith in their government, less than 15% have faith in their president, less than 5% have faith in their Congress.

Close to 70% do not believe our government has our best interest at heart and close to as many are disillusioned by the corrupt self-serving nature of our government (what we call special interest groups and lobbying).

I don’t have the details available to review the validity of the methods used to gather these stastics, but it speaks to what I hear in society from both the left and the right.

What would the founding fathers think and say?  How do we fix what is so obviously, terribly broken?

Saw this floating around on Facebook today which gave me pause to contemplate this post.

It is not July 4th we are celebrating, it is independence day – yet tyranny and oppression come in many forms.

What’s next?

Breaking free from the confines of the mind… is this what insanity is like?

For years I trained my brain to engage in lucid dreaming, I’ve played with hypnosis, NLP, paraliminal learning, photo reading, and other crazy reprogram and expand your brain exercises.  Last night I got what I deserved (I guess).

As I awoke, but still asleep, I began to dream that I was programming my body in my brain.  I was pushing and popping instructions off the stack of my mind to create my heartbeat, to expand my diaphragm, to push blood through my veins.  For a brief moment, I thought “this is awesome”, I’ve finally broken free of The Matrix.

However, very quick I realized that if I was controlling my autonomic functions, if I screwed up on the programming, my heart would stop, I would suffocate, my organs would die of asphyxia. Having this realization, I started to panic.

Mind you, I was dreaming, but aware I was dreaming.

So, I finally said to myself, this is silly, why panic, you can just wake up.  But I couldn’t.  I tried to stop thinking about programming my bodily functions.  But I couldn’t.  I tried to stop worrying about injecting the wrong opcodes.  But I couldn’t.  So then I started thinking, “Is this what happens when you go crazy”.  “Will I wake up, insane”.  “What if I can never get control over my mind again”.

I always thought going John Nash crazy wouldn’t be so bad, at least it would be in brilliance; but now, I couldn’t imagine being stuck in a world where I knew I was trapped in my own mind, but couldn’t break free.

Have you ever started thinking so much that your head started to throb?  Burn?  Ache?  I felt like my CPU was overclocked, overheating and was about to core dump.

And then I crashed – I don’t remember how it resolved, or how long it went on, but I woke up this morning… a little ragged, with vivid memory of the whole ordeal.  Happy to report, that I am still part of The Matrix, and I’m not John Nash insane.

Maybe I should stop messing so much with my brain.  Maybe I should take a break from technology.

Nah.  Back to The Matrix.

Updated Bubble Sort in x86 ASM

So, after another week of studying assembly, I went back and rewrote my bubble sort algorithm.  I’m feeling a lot better about this implementation.  I’m sure it could could be even better, but I’m pretty pleased with it this time.

Here is the code:

 

; Author J. Logiodice
; Date: 05/28/2016
; Purpose: Bubble SOrt
; This method will read in a series of TOTAL_NUMS numbers
; And bubble sort them, then print them out in sorted order to the screen
format PE console
entry start

include ‘win32a.inc’

TOTAL_NUMS = 10 ;10

section ‘.bss’ data readable writeable

array_numbers dd TOTAL_NUMS dup (?)
nMinus1Mem dd ?
boolSwapped db ?

section ‘.text’ code readable executable

start:

; Set up the loop variables
mov ecx, dword TOTAL_NUMS
mov esi, dword TOTAL_NUMS ;ecx
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Read in one number at a time, for TOTAL_NUMS numbers, store them in the bytes that
; start with array_numbers
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

loopRead:

; have to use esi because read_hex uses edi
dec esi

; read input into eax but first clear out eax
xor eax, eax
call read_hex

; move value into memory offset (reverse order)
mov dword [array_numbers + esi * 4], eax

loop loopRead

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; loop iteratively over the array until no more swapping occurs,
; and the highest number ends up in the lowest part of the array (lowest to highest)
; start with array_numbers
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Set back up the loop variables
restartLoop:

mov ecx, dword TOTAL_NUMS – 1
; set the swapped variable to false
mov [boolSwapped], byte 0 ;dword 0

lea esi, [array_numbers]

loopSort:

; jump to the loop exit if ecx is 0
; this will occur if we are at the end of the counter, or if the
; initial array was of size 0 bytes
jecxz loopExit
; load the first number in array_numbers into eax
lodsd
; after lodsd, edi is pointing to edi – dword
; if we compare the value at edi at this point it is effectively the value below eax
; compare eax to the number below it in the array
cmp eax, [esi] ;, eax
; if [esi] > eax, then no ZF or CF set, so jump below or equal
jbe noSwap
; if here then eax is lower, swap eax and the higher number in memory
mov ebx, dword [esi]
mov [esi], dword eax
mov dword [esi-4], ebx

; if a swap occured, set boolSwapped = 1

mov [boolSwapped], 1b
noSwap:
; jump here if no swapping needs to occur, but we’re still in the loop
loop loopSort

loopExit:

; if boolSwapped isn’t false, then we’ve swapped at least one
; during the iteration, let’s go through it one more time to make sure
; that we don’t have any more to swap
cmp [boolSwapped], 1b
jae restartLoop
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Print each number back out to the screen for unmodified numbers
; we will loop from the lowest to highest part of the array – which is the largest to smallest number
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

mov ecx, TOTAL_NUMS
lea esi, [array_numbers]

loopPrint:

jecxz loopExit
lodsd
call print_eax

loop loopPrint
exit_prog:
push 0
call [ExitProcess]
include ‘training.inc’

x96 ASM bubble sort in VIM

Bubble sort in x86 ASM

[[NOTE: For a more efficient way to implement the bubble sort, see my later post]]

Why?  I have no idea.  It’s funny how many times I set off my AV scanner trying to compile and run my PE.  That brings back some great memories with the VCL.

I’m sure there are cleaner ways to do it – but right now, I’m just worried about making it work.  😉

NOTE: Written in FASM, and the training.inc can be found over at xorpd on git.

; Author J. Logiodice
; Date: 05/22/2016
; Purpose: Bubble SOrt
; This method will read in a series of TOTAL_NUMS numbers
; And bubble sort them, then print them out in sorted order to the screen
format PE console
entry start

include ‘win32a.inc’

TOTAL_NUMS = 10 ;10

section ‘.bss’ data readable writeable

array_numbers dd TOTAL_NUMS dup (?)
nMinus1Mem dd ?
boolSwapped dd ?

section ‘.text’ code readable executable

start:

; Set up the loop variables
mov ecx, TOTAL_NUMS
mov esi, ecx
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Read in one number at a time, for TOTAL_NUMS numbers, store them in the bytes that
; start with array_numbers
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
loopRead:

dec esi

; read input into eax but first clear out eax
xor eax, eax
call read_hex

; move value into memory offset (reverse order)
mov dword [array_numbers + esi * 4], eax

loop loopRead

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; I am sure there is a more effecient way of doing this
; I will probably try and clean it up later, but for now it works.
; loop iteratively over the array until no more swapping occurs,
; and the highest number ends up in the lowest part of the array (lowest to highest)
; start with array_numbers
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Set back up the loop variables
restartLoop:

mov ecx, TOTAL_NUMS
mov esi, ecx

; set the swapped variable to false
mov [boolSwapped], dword 0

loopSort:

dec esi
mov eax, esi
sub eax,1d

test esi, esi
jbe loopExit
mov edx, dword [array_numbers + eax * 4]
cmp edx, dword [array_numbers + esi * 4]
jbe noSwap
; if we get into this section, then swapping needs to occur
; set the boolSwapped to true
mov [boolSwapped], dword 1

; need to swap the two numbers
mov [nMinus1Mem], dword edx
mov edx, dword [array_numbers + esi * 4]
mov [array_numbers + eax * 4], dword edx
mov edx, dword [nMinus1Mem]
mov [array_numbers + esi * 4], dword edx
noSwap:
; jump here if no swapping needs to occur, but we’re still in the loop
loop loopSort

loopExit:

; if boolSwapped isn’t false, then we’ve swapped at least one
; during the iteration, let’s go through it one more time to make sure
; that we don’t have any more to swap
cmp [boolSwapped], 1b
jae restartLoop
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Print each number back out to the screen for unmodified numbers
; we will loop from the lowest to highest part of the array – which is the largest to smallest number
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

;mov edi, array_numbers
mov ecx, TOTAL_NUMS
mov esi, ecx

loopPrint:

dec esi
mov eax, [array_numbers + esi * 4]
call print_eax

loop loopPrint

exit_prog:
push 0
call [ExitProcess]
include ‘training.inc’