Monday, March 27, 2017

COOKIES

New topic!

Here are 3 reasons why you should care about cookies (the computer kind):
0) They are small and full of value (just like regular cookies)
1) They allow you to not sign in every single time you go to a website
2) They also might be used to track your online activity

Summarized and paralleled in table form:

Cookies
Cookies
Ingredients
Made of flour, sugar, butter, eggs, and chocolate chips to taste
A small text file compromised of (key, data) pairs
Pros
Taste and happiness elicited
Convenient method to store/remember data between sessions (either connections to website or opening a browser)
Cons
After inevitably eating more than you should, your stomach hurts and you depart on your guilt trip
Third-party cookies, often from advertising sites, can be used to track your activities online

Cookies can be found through 2 ways:

1. Go to chrome://settings and click on Show advanced settings... at the bottom
Under Privacy click Content settings... and click All cookies and site data...
This will show  a list of websites and the number of cookies stored by each.
However, this doesn't allow you to actually view the contents.

2. In File Explorer, go to C:\Users\[NAME]\AppData\Local\Google\Chrome\User Data\Default
Inside, you see many files. This is where the cookies seen before are stored.

I checked out a file named "Current session" in notepad, and found this file. 
While the file is full of gibberish and white space (it is slightly encrypted/modified before storing), we can see that Google Chrome uses this file to "remember" which tabs I had open (stackoverflow.com). This is useful if I accidentally close a tab and want to Ctrl + Shift + T it back to life.


I ventured deeper into my folder and found a file "33" in the folder for Google Calendar's cookies. (Most of the other folders were similar, with numbered files.)

 
The most striking part of this file was the emptiness. Here I show the most exciting section of it. The majority of this large file (see the small scrollbar) was simply empty:
One thing you see consistently in the text is "sqlite". This is the library Google uses to store the cookies on the hard drive. 
My guess is that this "33" cookie is used for Google Calendar to remember my specific preferences, such as which calendar views to enable.

Finding real cookies on my computer took some of the magic out of Google Chrome - akin to finding out that Santa had not been eating the cookies each year. Oh well, it was about time to grow up in the computer science world anyways.

Sources:
http://www.whatarecookies.com/
https://www.quora.com/What-does-the-code-for-a-tracking-cookie-look-like
http://stackoverflow.com/questions/31021764/where-does-chrome-store-cookies



Compil-- COOKIE BREAK!

So. My experience researching compilers has been rocky, with learning Flex and Bison while dealing with the constrained languages and profuse errors. I eventually got my simple compiler for LC-3 Assembly to work.

Flex code:
flex.png
This code identifies the tokens (see previous posts) in the LC-3 language

Bison code:
bison.png
This code specifies and identifies statements, valid sequences of tokens

This code took code from a simple version of Assembly adapted for LC-3, a simplified model of a computer, and turned it into binary (0s and 1s). Here you can see my output versus the output of an online LC-3 compiler.
result.pngpres.JPG
(^The result of 30+ hours of toil and tribulation)

Even with this (small) success, I've barely made progress on my overall project of making a compiler.


Referring to the above diagram, I have only researched and coded for the "Front End", and especially simple code at that. Starting the year, I knew this was an ambitious project, normally undertaken only by upperclassmen undergrad students. At my rate, it doesn't appear that I can finish a full compiler.
Instead, I will switch to a different (and tastier) topic in computer science that I have been interested in for a while:

COOKIES 

(coming at you next time!)

Sources:
Blood
Sweat
Tears
http://dinosaur.compilertools.net/