Showing posts from 2018

JavaScript Event handlers

So for this experiment I was intrigued by the continual functions run in a website,  or event handlers.   It took me a bit to figure out what exactly needed a time out, closure, all the stuff mentioned in this article:

Medium : front-end-javascript-interviews-in-2018-19

After a fair bit of searching I decided what I wanted my experiment to be in order to understand these concepts better.

I'm going to make my own 'event_handler'.

I've done it in python with Tkinter:
An experiment with Tkinter python blog post

Now most would say, "Why go to all the trouble of making something that exists?"

And my answer will 99% of the time be, "Because I want to know how it works."
For me the best way to learn that, is to try and make it happen myself the way the already existing thing works.   My dad would say something along the lines of, "You really learn how a carburetor works after you've (successfully) rebuilt one." 

Helpful links I used:

Javascript : check if a word contains a char in a text file

JavaScript Experiment #1

The goal for this was to read a txt file, go through each word of that txt file, and make a string from every word in that txt file that contain the letter 'o'.

*"Halt!" and "hand.]"   are in there because in my list made from the text file:
       'down.]\nHalt!' --- is the item in the list.  It's printing the newline. So
        they appear seperated.
        Same with hand --     'hand.]\nWhoa',

There were many many answers that weren't exactly what I was looking for, but gave me the breadcrumb to follow to the next search I needed to do.

This was my extension to an exercise from Learn JavaScript the Hard way.
Shaving the yak is more fun if you get to give it a fun haircut before the real work starts. (*draws a maze in the yak fur with shears for my toy soldier to tromp through*)

Some things I found out:
(some string) = string   (x = char to look for)
Javascripts string.includes('x') returns…

Getting random lines from txt files

Working on my whispering wall the other day, I wanted a much better way to 'randomly' select lines it would give back to the user.  random.shuffle seemed like a better way.

Thanks again to the interwebs for the tools to search up the things I need.

   I wasn't sure how to properly handle the global aspect of 'LINE_GET' for this piece. LINE_GET is going to be the integer I use to select a number from the list that is made, that is then in turn used to get a 'random' line from my txt file.

   In my whispering wall, this variable would be a part of the WhisperingWall class. And it's alteration would be internal, but for the sake of making this blog post I needed it to be easy to access and alter.  And globals, well, everyone says they are bad. I may be writing completely horrible code for that part. I am not sure, but hey, I didn't use a global!  kinda... sorta....

two methods, a class(**cough global**), and a system argument (sys.argv),  tha…

fail on retraining tagger, file rewrites accomplished

(Original post was to be me figuring out how to train the tagger in NLTK so it doesn't tag everything it can't recognize as a noun.)

Monty python scripts --

NLTK Website docs:

When I went to do this project, I had no idea what it entailed.
So for the purpose of this post, let me say, This is how far I got.
I still have no clear picture if training the punkt pos_tagger is useful.
More research to do, but I think I need to give it an entirely different data-set to go off from.  Looks like the free one I downloaded isn't very good with tagging spoken language vs. written.

But if you came for some code, here's to methods I wrote to clean up the monty python scripts.

First step was to copy paste into a new file the script.
Second step:  save it as txt file
Third: run these py files on the script to clean it up a bit for training texts for NLTK, when I figure that bit out.

 ** finding a regex to rem…

Getting that key off from repo

For today, the plan is to get SQLite onto my computer, and try to get whispering wall interacting with that database to retrieve my script lines. 
FYI: The plan went completely sideways as I tried to get my secret_key off from github.
      1)delete from repo but not local
      2)force push origin master of pythonanywhere repo
      3)remove original key from and replace with snark
      4)tell gitignore to NOT ignore
      5)push new to git repo
      6)put back into gitignore
      7)change secret key back
      8)Find out at a later date if I could have just changed my key and ignored     
         doing any of this 

pictured: The result of shutting down my bash(s) because I couldn't exit vim while trying to change the gitignore file

First step, go to my Learn SQL the hard way to see setup instructions.
-- I always try to do "apt-get install" if I can rather then download.  If it's available it's just way faster…

npm nodejs and Linux

I use Linux, but I hope after student loans come in I can pick up a decent and cheap Microsoft laptop for the college classes.
Then the posts like this, I will attempt to have both systems included in the material. 

To be fair to Zed's book, he clearly tells us to watch the videos.  I don't understand it, but I just have such an aversion to watching videos rather then figuring stuff out on my own.  Watching someone else do it just takes the fun out of it.  So I'm sure all this was covered in the video, I may go back and see it once this is posted.  Otherwise I might be tempted to wipe the whole thing for feeling like an arse afterwards.

I was going through Zed Shaw's pre-release of Learn JavaScript the hard way, and an instruction said to install the 'readline-sync' through npm, but I kept getting this error:

So after finding a couple links that wanted me to check the .json files for dependencies,  *Which I do not know how to do yet*
I decided to try unins…

Still working on that MySQL

Hint:  If you just want the code, scroll to the bottom.

I applied for some tech entry jobs, and after seeing all the different applications they want you to 'know' or have experience working with, I've decided.

The decision:
Find a different application that the tech companies want you to have experience with, and do a blog experiment with them,  figure a bit out, and then I can honestly say I have 'experience' with that application.

So I want to complete my experiment with MySQL, and then I can say, 'yes, i have experience with SQL.' 

I don't have a ton of time today, I started hacking away at the files in my pythonanywhere to get my script files lines into the database.  If you read the prior blog post, I didn't get very far.

I realized the first thing I am going to need to do is modify that SQL database I made.  (littleNoodles)
I created it with just a primary key, Integer,  and I need it to except the line of text from the text file.  So first …

Whispering wall scripts into SQL

Helpful Links:

Today I am going to try and get my Whispering wall scripts into SQL. 
I want the W.W to be able to expand, and read from a database the responses instead of the scripts.  Especially since the random just doesn't seem to pick a variance from the scripts.  Not sure how it'll be better, but I'm thinking I'll have the SQL keep track of responses already used, and pick a different one if it is a repeat,  Start over if all responses have been used. 

Anyways, more on that, Just typing this in to save as a draft so while I work on it, I can add all the useful links I use in the process.

**  #1  ---  ENTER MY VIRTUAL ENV, do all this there ####
###  Step  ** 10 really should be first .... ###
###  You need the MySQL install.…

python simple finite state machine and logger

Doing another exercise from LMPTHW, and I'm enjoying it.
Only broke into Maximum recursion depth once so far.

Also I found this good article on logger, and I am really going to start using it from now on.  Just yeah.  It's not much work at all to put it in there.
---logger article:

So a picture of what my plan was going in:

And a picture of the code results in Command Prompt ( Bash ):

color codes link :
And I'm not sure I can explain well enough yet, but basically you're making a 'machine'  that transitions to a predetermined amount of settings -- states.
In my code, it's  the class's functions [ FSM_OFF, FSM_GO, FSM_GREEN, FSM_YELLOW, FSM_RED, FSM_BLINKING_RED, FSM_ERROR]

And the list of triggers/instructions to change the state are determined in each of those states.     **FSM_BLINKING_RED is…

Getting some NLTK running in my Django website

First off,  Some links:

Django Girls Tutorial

NLTK site

And if you wanna see the website in action:

If your a new reader and haven't seen my work with NLTK, a quick note that I did a lot of playing with it to see how it all works.

You can refer to this blog link to see some of the work:


I followed all my own instructions to make nltk functional in the pythonanywhere server:

Enter your python virtual environment:
on my server: (bash) source <name of your env>/bin/activate
You might have a different set up.
My pythonanywhere runs my site through the virtual environment
The Django Girls Tutorial is excellent for all this information.

1) pip install -U nltk
2) pip install -U numpy

open the python shell and:
>>>import nltk
< Stuff happens Cross your fingers for no errors!>
<Stuff happens *finger…

Django & Mysite.settings import errors

Tutorials are Awesome!  
Check it out!  my site: Nellies Noodles
I found this django tutorial, and it is damn good.
That is unless you don't know what your doing, like me, and just try to skip to the parts you want to see because you think you can do it all alone...
Lesson learned.
Django Tutorial

I'm going to go over a few things that really threw me off, so if someone else is trying this for the first time, they'll have a little hint where to look.

Besides the whole, I can skip ahead of this yak shaving bit! , issue, When I finally removed my initial project and started new, and got to the point that everything should have worked, these are the problems I encountered.

1)  When trying to find the 'link' to my live and running website, I had to create the Web App first.

The first few times, the  pythonanywhere  did not see I already had the Django files  and set the new directory empty expecting me to make the django app inside it.  *the has a fre…