FlattDev Just a dude! Not an AI Large Language Model!

Flasktutorial

  1. Started the Mega Flask Tutorial by Miguel Grinberg. It’s a great tutorial that has you build a web app in Flask. So far I’ve completed the first 3 lessons. Pushed the files to a project repo on Github at Microblog

  2. Pushed my blog post creation Python script to github. It can be seen at BlogInitScript. As discussed in previous blog this script automates the process of creating a blog post file in Jekyll. This is a work in progress and I plan on improving it as I learn more.

  3. Created a global gitignore file so that extraneous system and editor files are not pushed to my repos.

Future projects:

  1. Continue and finish the Mega Flask tutorial

  2. Create a twitter bot in Python that will auto post my blog posts.

  3. Re-visit my portfolio page and fix the mobile responsiveness. It’s not quite right.

  4. Add a couple projects to the placeholder areas on my portfolio.

  5. Continue studying Python

Books I want to buy and work through

  1. Automate the Boring Stuff with Python

  2. Python Crash Course

  3. Python Tricks

  4. Invent Your Own Computer Games with Python

School starts again Jan 14. Taking Calc 2 and Computer Science 2, which is Data Structures and Algorithms. God help me!!!

The other evening I got sucked into a 2 hour discussion/argument on Twitter about politics. I have gotten good at mostly ignoring these kinds of things and not participating but every so often I do still find myself sucked into them. Then several hours pass and I realize what a huge time sink it is with absolutely nothing gained from the endeavor. I subsequently deleted all of those tweets of mine because I don’t want my Twitter to be political at all. I have strong opinions of my own but by putting my opinions out there in such a public manner, I run the risk of alienating people. That’s not smart and not what I want to do. I have carefully curated my Twitter feed to only include educational accounts, science, programming, computer science and web development and as long as I stick to that, Twitter has proven to be a fantastic resource for finding and engaging with amazing people and information.

Been blown away too with what a fantastic resource Hacker News is. A wealth of great resources are shared there, not just related to esoteric programming subjects but to science and philosophy too.

One such is a pdf article that was written in 1939 by Abraham Flexner called The Usefulness of Useless Knowledge Well worth the read and highly recommended by yours truly. Check it out.

New Year 2019

New Year 2019 and coding education update

So I’ve been quite productive as of late with my coding education progress and thought I’d share a few cool things.

  1. 100DaysofCode doesn’t really seem to work for me. Not that I havent been coding everyday but I don’t always have time to or I forget to post it to twitter everyday.
  2. I got an A in my Computer Science I class which used C++
  3. I’m on pset3 in CS50. I believe it’s pset3, the music files in c.
  4. I successfully ported my final exam from CS1 from C++ to Python just because. In addition to my formal educaton in CS at local community college, I’m also trying to learn as much as I can on my own and this includes Python. So after learning the basic synstax, I figured what better to truly immerse myself in the language than to try to port my final exam to Python. If I didn’t know how to do something I just googled it. I had some issues with the difference between arrays in C++ and lists in Python and how they are implemented differently but I finally got it and finished the project. I uploaded both solutions to my github and can be seen at:

C++ solution:

Python solution:

  1. And maybe the most exciting for me is that I created my very first Python script that does something useful for my workflow. I was about to write this blog post in Jekyll when I realized, “Hey, I bet I could write a python script to automate the task of creating the file with the YAML header and all and open the file in my editor.” So I got down to the business of writing such a script with the help of Google and this is what I came up with and it works. This was truly an eye opener for me. It was like a light switch. Not just doing endless tutorials and learning syntax I could do something useful and learn at the same time. Amazing.

#!/usr/local/bin/ python3

import time, os, glob, subprocess


title = input("Title:   ")
cat = input("Category:  ")
tags = input("Tags:  ")
d = time.strftime('%Y-%m-%d')

path = "/Users/FlattDev/Documents/Blog/bflatt72.github.io/_posts"

os.chdir(path)

f = open("%s-%s.md" % (d, title), "w+")

print("------", file=f)
print("Title:%s\r" % title, file=f)

if cat: print("Categories: %s\r" % cat, file=f)
if tags: print("Tags: %s\r" % tags, file=f)
print("------", file=f)
f.close()

list_of_files = glob.glob('/users/FlattDev/Documents/Blog/bflatt72.github.io/_posts/*.md')
latest_file = max(list_of_files, key=os.path.getctime)

subprocess.call(['vim', latest_file])

What the script does is the following:

  • prompt for post title, category and tags.
  • sets the current date
  • gets the path to the _posts folder
  • changes to that directory
  • opens the file with the correctly formatted title
  • prints the YAML header information to the file
  • closes the file
  • gets a list of all .md files in that folder
  • gets the last file added to that folder
  • opens that file in Vim for editing.

Pretty damn cool.

Then I made a shell alias that points to the script so that it can be executed by just typing the name of the file.

I’ve been using Vim a lot and getting pretty handy with it but then I downloaded VS Code and was blown away by it. Wow! Game changer. Installed Python extensions and wrote this blog post in it. Set up my terminal to open a file in VS Code by just typing code.

  1. Another related epiphany is that the best way to learn is to do and to build instead of endless tutorials. However, tutorials that actually have you build something are great. Currently working through the Mega Flask tutorial by Miguel Grinberg. It’s a great tutorial that actually has you build a functioning web app.

That’s all for now.

Happy coding.

Success is a Habit

We are what we repeatedly do. Success then, is not an act, but a habit. – Aristotle

So I started going back to school, again, at the age of 46, for Computer Science at my local community college. The current semester just ended and I got an A in Computer Science I and CalculusI. CS used C++ as the programming language. We touched on objects and classes but did not have to use them on the final programming exam. We did have to use functions and an array to calculate a loan schedule on a vehicle based upon user inputted data. I got a perfect score on my implementation.

I am also trying to learn as much as I can on my own and that includes writing this blog post in Vim. Completed Vimtutor and now trying to use it as much as possible. In addition, I have been taking Harvard’s CS50 via Edx. So far I have completed ps0 and ps1 and listened to all of the lectures. I now at least know about C (and C++ from school), Python, SQL, Flask, JavaScript, jQuery, JSON files, and of course HTML/CSS.

In the last couple of months I have also purchased a used 2010 Macbook and upgraded it to High Sierra, started using iTerm2, zsh, and ohmyzsh. For school programming we were using visual studio but I switched to XCode on my Macbook. Also learned how to compile and run C++ programs from the command line using g++.

Been very productive over the last several months and I am incredibly proud of myself but the more you learn the more you realize you don’t know. But when you love to learn it’s not an issue.

So why am I doing all of this? Well I could fill several blog posts with the long of it, but suffice it to say that at the age of 46, and with almost enough college credits to make two bachelor’s degrees, I still don’t even have an Associates degree. A few changes of majors and starting and stopping school over the years and a plethora of bad decisions has led me to where I am today. I have a good job that pays the bills, but I don’t think it’s a secret that it’s not a job I’d like to be doing for the rest of my life. For one thing, I work 12 hour night shifts and have been for the past 10 years. The older I get the harder it becomes, especially when you have a wife and kids. I would like to one day work in Computer Science or Web Development either at my current company or somewhere else that values my experience and knowledge. But I have no idea if I will ever be able to get hired anywhere as a junior developer at my age but I’m doing this anyway because I love it and just because.

That’s hope, right?

Mindfulness

Whatever you can do, or dream you can, begin it. Boldness has genius, magic, and power in it. Begin it now! – Goethe

When you grow up, you tend to get told that the world is the way it is and your life is just to live your life inside the world. Try not to bash into the walls too much. Try to have a nice family life, have fun, save money. That’s a very limited life. Life can be much broader once you discover one simple fact. That is–everything around you that you call life was made up by people no smarter than you. And you can change it. You can influence it… Once you learn that, you’ll never be the same again. – Steve Jobs

The past is a foreign country: They do things differently there.” – L.P. Hartley - The Go-Between - 1953 novel

And alone and without his nest shall the eagle fly across the sun.” – The Prophet - Khalil Gibran

These are great quotes I’ve recently come across in my readings and the thing they have in common is the idea of change or human potential, that we are capable of so much more than we give ourselves credit for or believe. Living a life of intentionality. Being mindful in how we live our lives, instead of just blindly tripping our way through life and letting life and circumstances happen to us.

I’ve been thinking a lot about these concepts lately and the idea occurred to me that the way the vast majority of Americans live their lives is as Thoreau said, “the mass of men lead lives of quiet desperation.” We go to work, we come home, we sit in front of the TV for hours, we eat horrible food that is horrible for our bodies, we mindlessly consume everything. We are voracious consumers, but of everything that is bad for us, of nothing of true lasting value. Very few of us ever really accomplish anything in our lives outside of our careers, if we even feel accomplished there. We consume, we are passive. We are vegetables. We are fat and lazy and stupid. We don’t want to learn anything, read anything substantive, do anything, be anything. We just wanna be left alone in our own misery. Just leave me alone. We watch Cops and 24 hour news and The Voice so that we can live vicariously through others. We do nothing. We are nothing.

That’s how I lived my life for many years until at the age of 41, 50 lbs or more overweight, out of a 6 year failed relationship with the mother of two of my children, I decided to change my life. I knew something had to change and that something was me. I started going to the gym and I’ve been going for a little over 3 years straight, but this isn’t a blog about the gym. It’s about wholeness and living a complete life and while I was going to the gym and getting my physical life in order, it was only recently that I realized that I can use that same comittment and discipline that I honed over three years in the gym to power all aspects of my life.

I don’t have to be glued to Facebook and other social media. I don’t have to be glued to the TV or the radio. I’m at a point in my life where I truly don’t understand people who say they are bored. How can you be bored when life is so short and there is so much to learn and do? 27 days ago I started the #100DaysofCode challenge on Twitter and I’ve accomplished so much. It’s amazing how much we can do when we turn off the distractions of life and live a life of intentionality and being mindful about what we are doing.

Living a life of intention means that for everything we do there is a purpose. We don’t just plop in front of the TV and veg out for hours on end, watching the same mindless BS. I actually haven’t even had cable TV for several years now and I believe it has helped to re-wire my brain. I probably only have 3 or 4 shows that I enjoy watching on TV, but I watch them on Netflix or CBS app and I intend to sit down and watch them. The Big Bang Theory is one of my favorites. Other than that, the TV is never just on to be on. I watch a lot of educational Youtube videos and have recently gotten into listening to podcasts, because the radio is more mindlessness. I’m convinced that no matter what channel you turn it to, they are all playing a setlist of maybe 10 songs if you’re lucky and they play the hell out of it. The same 10 songs over and over and over again and I can’t stand it. Why do I wanna listen to the exact same songs I’ve heard a million times? I love music but I can’t stand listening to the same shit all the time. There are actually long stretches of time where I won’t even turn the radio on in the car at all, unless NPR is on the air and I’ll listen to them.

And when you decide to live life this way you’ll find that the universe opens itself up to you in meaningful ways. You’ll encounter other people who live their lives this way, and you’ll come across other resources for living life this way almost as if by accident. You’ll be flooded with ideas for future projects and things to learn and do and see.

Don’t just be a passive consumer. Dead fish go with the flow. Learn something that is difficult and will take time. Read something important. Listen to others who are smarter and more accomplished than you, whether on Youtube or a podcast or through TED. Read War and Peace. You know you’ve been wanting to. Read 30 self development books in 6 months and blog about it. Run a 5k race. Run another one. Spend quality time with your family not glued to your smart phone. Turn that damn thing off once in awhile. Go outside for a walk. Take the dog for a walk. The kids. The wife. Cook a meal together. Take some classes. Write something. Help others. And when you do, “Speak your Truth even if your voice shakes!”

Do!

Be!

Life is a garden. Dig it! – Joe Dirt

Setting up Custom Domain Name

So, last night I got around to purchasing a domain name for my blog/portfolio site. After researching several different domain name providers, I came across 1and1.com, which has an introductory offer too good to pass up, which is $.99 for the first year of your domain, provided that this is your first one. After first year it goes up to $14.99 but you could always change domain name providers if you found a cheaper offering.

So, I purchased the domain flattdev.com and proceeded to set it up with my Jekyll blog site hosted via Github pages at bflatt72.github.io. The first step is to go to the settings page of your repo and scroll down to where it says custom domain. Type your new domain name in there and click save.

From there, I knew that I had to set up the domain via the provider in order to point it to the site on Github. But 1and1 doesn’t make this easy at all. They pretty much assume you already know what you are doing, because there is nothing to tell you exactly what you need to do. Did I need to set up forwarding to point it to the site? Or did I need to change the DNS settings? Nothing really tells you. On Github, if you click next to the custom domain setting on Learn More, there is some helpful info, which basically boils down to, you have to check with the domain provider to find out how to do it. But it did point me in the right direction of WHAT needed to be done.

First I tried to redirect the domain and that wasn’t working, however maybe I didn’t wait long enough for it to propogate? At any rate, I changed the DNS settings, changing the A Name to point to Github’s IP address, which they provided in their help pages. And, bingo, my page started to work and it worked all night at work and in the morning when I got home. This evening, back at work, I checked it and it had quit working, saying there were too many redirects or something. I’m not sure. I’m not a network guy, as you can tell. But I checked back at 1and1 and found that it had been changed back to a redirect, for some strange reason.

At this point, frustrated and just wanting someone to tell me which method I needed to employ, I called their 1-800 number and after waiting on hold for over 20 minutes, I finally reached a person, who didn’t seem like he knew anymore about this shit than I do. Frustrated with him, I told him I’ll figure it out myself, thanks for your help, and hung up.

After much trial and error, and reading between the lines of what the tech support was TRYING to say, and reading Stack Overflow and Google, here is what I had to do:

For the main domain, flattdev.com, I had to change the DNS settings to point to the IP address of Github’s servers. Github says you have to change the A Name to point to two separate IP addresses but I could only find a way to point it to one, which I did and which is 192.3.252.153 and 192.30.252.154. I just set it to the first one and after a few minutes my website began to work with the new domain name.

Then if you want to set up the domain to work with the www subdomain, you have to set that up by first creating that subdomain and using a frame redirect on it to point to your actual Github domain at username.github.io. After that change took effect, it began to work.

Very frustrating, and I’m betting that tech support and help pages at Godaddy are probably a lot better than they are at 1and1. They say you get what you pay for, but if you know what you’re doing, and now you do after reading this blog, you can’t really beat a domain name for $.99: just don’t expect much in the way of help from their tech support.

Updates

  • Finished the portfolio project on Free Code Camp.

  • It is now parked on a separate page of my blog at flattdev.com

  • Added a button on the portfolio to point back to the blog.

  • I have read the first book Up and Running in You Don’t Know JS by Kyle Simpson.

  • Working on Basic JavaScript in Free Code Camp.

  • Reading The War of Art by Stephen Pressfield

  • Saw Bladerunner 2049 other day and really enjoyed it.

  • Listened to several coding podcasts on my travels to and from Raleigh from Knoxville over the weekend. Enjoying CodeNewbies and Developer Tea. Also listened to TWiT, not realizing it was still being produced. How old is Leo Laporte getting to be?

Leo Laporte

Notable blog posts I read

Goals

  • Write for at least 15 minutes every day.

  • Continue with 100DaysofCode, currently on Day 22.

  • Start the Make a Bookmarker project that saves to local storage, using only vanilla JS by Traversy Media on Youtube.

  • Next books to read:

    1. The Obstacle is the Way by Ryan Holiday.
    2. Tranform Your Habits by James Clear

Until next time, Peace!!