Monday, January 22, 2024

 Having Peg Grammar Troubles?

Try this trick for Expression Engines in the C Languages. Instead of the hassle of having to use Peg Grammar routines and countless methods for precedence orders, instead simply do it with Function Naming. I wrote this small Test in C++ without a loop and several look-a-head token variables.


Try this trick for Expression Engines in the C Languages. Instead of the hassle of having to use Peg Grammar routines and countless methods for precedence orders, instead simply do it with Function Naming. I wrote this small Test in C++ without a loop and several look-a-head token variables.

#include <iostream>

#include <string.h>


double add_two_mult_one(double x, double y, double z){

    double t = x+y*z;

    return t;

};

double prec_add_two_mult_one(double x, double y, double z){

    double t = (x+y)*z;

    return t;

};


double add_two_add_prec_mult_two(double x, double y, double a, double b){

    double t = x+y+(a*b);

    return t;

};

int main()

{

    /* if(tok[i]=='LPAREN' && tok[i+1]==VALUE && tok[i+2]=='PLUS'....etc.) {

           dbl v = PRECENDENCE_add_two_mult_one(tok[i+1], tok[i+3].....etc.);     

    }else etc. */

    double x = prec_add_two_mult_one(2, 2, 5);

    

    double y = add_two_mult_one(2, 2, 5);

    

    double z = add_two_add_prec_mult_two(2, 2, 5, 5);

    

    std::cout << x << "\n" << y << "\n" << z <<  "\n";


I call this "Alphanumeric Function Grammar" which does not require any node traversing from right to left or back again. Why? Because the Pre named Functions for their Precedence Orders are all fully  Recursive and if you Pre Set them all then your done.

Node Traversing is a Pain and developers simply cannot easily get them to work correctly traversing back from Left To right without having extra Structs to store their Precedence Orders.

Its all about Naming and Conditionals and a few Sate Switch Variables to achieve what a Node Traversal Engine is causing to be extremely complicated.

Friday, September 28, 2018

How Browsers Render HTML And CSS

  I've read many articles online about how the Browser and CSS work together. Some say the Dom connects them. Others claim CSS is a computer language. Others will say the HTML and CSS are connected by the Parser before being rendered together. Many developers have fallen to misunderstanding and believe in mythical ideas. I will go into great detail and explain how they actually work.

The Browser  

  The secret to how the Browser works is key in understanding documents and how they store data both visually and hidden.  But realistically it's still kept secret by many companies and the individuals who developed them.

The Canvas

  Browsers Build a Document Page View by Requesting then Parsing the Dom ObjectModel or (HTML) and render them onto the Canvas. The Canvas uses screen positions called Pixel Coordinates. They begin at (x1 , y1) upper left corner and ending at (x2 , y2)  at the bottom right hand corner. And scroll down the page based on height and length of the Document. And do this in numeric pixel order as shown below:

(left, top, right, bottom) or (x1, y1 , x2, y2) or (0, 0, 1366, 768) if your on a desktop.

The Mosaic Canvas

Microsoft Windows licensed a copy to create IE but claim they never used it. Netscape created the Navigator. Both had, modified and created two customized versions of the original NCSA Mosaic Canvas. Microsoft had been testing with Tk until Mosaic was born. Here are key functions that all Canvas perform:

  • Draw squares, rectangles, circles, lines, archs etc.
  • Set Text, Fonts, Font Size, Color foreground and background
  • Set Images
  • Set Frames or Windows
  • Set Labels, Buttons, Entry Widgets etc.
  • Set Colors
  • Set Positions Using Coordinates
  • Set Event Listeners on the canvas for Events from mouse or keyboard input
Here are the Tag Methods:

  • tag_add       Text Data
  • tag_bind      Event Bindings
  • tag_config   
  • elide            Designed for Div tags to be placed Invisible/hidden as dividers
  • bbox            Div encloses all other tags between it for placement or attributes
  • tag_raise
  • tag_lower
  • tag_move    Moves tag or tags used with tag_config
  • insert           Knows where the last object was placed on the screen
  • index           Knows where the last character of text was placed on the screen
  • There are many more.......

The Parser

Parser's take the Dom Object or HTML and fetch all the data found both inside and in between HTML tags. The most vital of this sequence is to get first the CSS Style Sheet links, image paths and JS paths to request them. Then at the same instance the text is stored in many arrays or manageable List as Python calls them to be used for markup conversions in for loops.

The Parser To Canvas Markup

The Html Tags staged in a tree structure are Parsed for both identification class and id names (and these are the add_tag names) for the string data between them. The Parser then passes them to the Tokenizer where they are broken down into canvas markup. Then using the Canvas tag_add() function it adds all the text data one by one onto the canvas. The CSS canvas markups using a tag_config() function follow below them and set all the attributes for the already present HTML tag_add() functions updating them to render the page. The CSS is done before the Hyperlinks so the Event Positions wont change by the tag_config, tag_bind and bbox() methods.

The Canvas Render

In order 
  • All Text, Images, Buttons, Labels, Frames, Windows are Tagged and added to the canvas
  • Then the Tags are Configured by attributes markup for colors, fonts, sizes bg and fg
  • Then bboxed for all Divs, moved into position with all the tags in between them
  • And finally the Binding Tags for Hyperlinks Events are added last to ensure their positions has not moved by the bbox and can be detected by the Event Listeners by position
  • Page is rendered

Canvas Markers

One more trick up the Canvas methods sleeve. Yes the add_mark, config_mark and more are also added into the mix. These set markers are for You Guessed It--"For Copy and Paste events, Printers and Language Translations" also called Sentinels or simply Marks.

HTML And CSS Facts

Html and Css actually are not directly connected in any way. Because the only thing that they share in common is only the Entity tag names. And when the Canvas receives the markup tokens from both it actually does not combine them either. It only renders what the CSS markups tell it and coincidentally the Canvas Tags match their Config Tags that were already placed beforehand. And that is all it cares about to bring you your View. 
 

Saturday, September 1, 2018

Python Tkinter is as good if not better for GUI creation !

And Here is why !

I read on many developer sites and blogs where everyone says Tkinter in Python is not good enough. Well just maybe you have not seen it's potential enough. Proof is everything.
 

Friday, February 10, 2017

Friday, January 27, 2017

How To Run A Python Program On Windows Withoiut A .EXE File Or Compiler.

How To Run Python Apps On Windows Automatically Without Any .exe File.
Misconceptions about Python.
  1. You don't need any py2exe or compiler to run any Python program on Windows.
  2. Python versions 2.7 and higher all contain OS.
  3. Create a .py file that will use OS that runs your Python program automatically. 
  4. Name it: MYAPP.py and add the following three lines.
  5. import os
  6. userw='path_to/my_app.py'
  7. os.system("start "+userw)
  8. Create a desktop shortcut for this .py file.
  9. When you double click it on your widows desktop it will run your python app..
  10. Only inconvenience is that you need two files to run each program. But not a big deal right?
How To Hide A Password In A Python Program So It Cannot Be Accessed. 
Steps:
  1. Create a temporary Python File named secret.py and 
  2. Store it on a private disc or USB storage device.
  3. Have it create if does not exist an sql-3 database named private_keys.
  4. Have it create a table holding your passwords and several keys matching functions in your app.
  5. Have it to allow you to enter or change passwords and keys.
  6. Lastly have every database connection or transaction using a SELECT statement require a managers passkey.
  7. Delete this python file after loading it into the users computer or any running the app.
  8. Now your python app is secure and no one can read the database.db file to get your password.
  9. And the python app cannot run or execute without the correct password.
  10. Have another database hold several keys also for multiple functions in your apps.
  11. Now you can Obfuscate your python program and unless the hacker knows the actual database table names cannot access or correctly run your Python App.  
  12. They can read your program but cannot read or access any of your apps stored keys passwords and or stored data created by the app without major knowledge of python programming.
Who cares if they can read your program. Without those keys and passwords no data can be seen and most employees running business IT apps you create using Python cant understand this. Now if you are developing critical Banking software then you will need the following:
  1. In your Windows7-10 computers or workstations place your working python edition and python files and programs into the Super User the Main Admin.
  2. Next Create a Link file named access.py that uses "import os" to run your app.
  3. This will allow you to run anything without needing a WINDOWS.EXE file
  4. Now add it to the desktop.
  5. Give this file Public Permission Status by right clicking and setting the windows users to execute only but both read and write to deny. 
  6. Now log out your windows admnin then log it back to the windows user.
  7. Now both your Python file and python version cannot be viewed but the app is allowed to run by windows permissions.
There are major security advantages to Windows and this is one of them.

Friday, July 17, 2015

//THE ULTIMATE DOUBLE SALT HASH MD5 MASKED !

function saltIt($pass)
{
$salt1='abcdefghijkl'; //OUR FIRST 12 CHAR SALT
$salt2='opqrstuvwxyz'; //OUR 2ND 12 CHAR SALT
$md5 = (md5($pass));
$hash1 = $salt1.$md5.$salt2;// SALT1-MD5-SALT2 COMBINED
$hash2 = strrev($hash1);    //WE FLIP-REVERSE THE HASH
echo $hash2;//CHANGE TO RETURN
}//end func

$password='razorback1';
echo'----OUR FULL HASH DOUBLE SALT AND REVERSED ALSO--';
saltIt($password);
//OUTPUTS-->zyxwvutsrqpo82fad4f7115b8bee54e7c9245fa594dalkjihgfedcba

function unsalt($pass2)
{
$a1 = substr($pass2, -44);    // WE STRIP THE FIRST 12 CHAR SALT
$b1 = strrev($a1);           //WE UN-FLIP THE HASH
$md_5 = substr($b1, -32);    // WE FETCH OUR ORIGINAL MD5 AND STRIP THE 2ND SALT
echo $md_5;//CHANGE TO RETURN
}//end func

echo'--OUR ORIGINAL MD5 UNSALT-->';
$pass_data ='zyxwvutsrqpo82fad4f7115b8bee54e7c9245fa594dalkjihgfedcba';
unSalt($pass_data);