Learning and Consolidation
|

Learning and Consolidation

Learning and Consolidation are important to me. Over a year ago I wanted to learn Laravel and Angular but when I started to study them I felt lost. I felt that I didn’t understand the topics well enough. I went back to the basics. I followed several courses about JavaScript and how it works. I typed out all of the lesson codes, and debugged it until it worked. Some bugs took three or four hours to fix, but eventually I got there


As I followed two or more courses on the topic there was quite a bit of repetition. Another word for repetition is consolidation. By studying the same topics, taught by different people I consolidated my knowledge. I filled in the knowledge gaps and eventually I began to understand how the code works, even if I can’t write it from scratch yet.


The aim isn’t necessarily to be able to write a web app from scratch. The aim is to understand how all the elements work individually, as well as how they work together in an app.


Today for example in the Let’s Learn Laravel course I followed the lesson on form validation, with mention of Bcrypt and Node.js. This feels good, because I see how frameworks help to save time. For years I was happy to use WordPress as a user, because it works well as a blog and CMS. Now I have studied enough to build my own, although my greatest concern is safety. I want to migrate the static part of my website to Laravel, but I want to do so when I feel confident that it will not be hacked. I also want to do this without destroying the rest of the site in the process.


That’s where the current course comes in. I need help in understanding the process and the steps for setting up a project in Laravel, taking advantage of the tasks that it does for me. When the effort is ready I will deploy it to a web server and see how well it works.


One of the reasons to follow courses, even if they are filled with plenty of repetition, is to learn about concepts. I knew about include but I didn’t know about layout. By understanding layout you can prepare a template, where the elements that change are individual pages, and the layout does the rest, to keep the entire site looking the same. This will become my “portfolio”.

|

Playing with Vim and Laravel

I love using Atom because it’s light and fast, even on a six year old machine like mine. Github is soon going to archive atom. I will lose my favourite editor. That’s why I played with VS Code, Sublime Text and other solutions. Vim is the winner for now.


Vim is on every linux and mac machine, and can be installed on Windows. Out of the box Vim is a really simple, limited editor but if you invest the time, to find plugins, and learn how to use it then it becomes a great application.


This weekend in the process of studying Laravel I decided to use VIM and one of the best features with Vim is that when you’re following a tutorial you will get the file path given to you. Type it into terminal and you’re in the file. No scrolling through hierarchies, no reading through long lists. You go straight to the file and start working.


This is good for production websites too. I am currently in the process of taking the static content on my website and making it dynamic. This requires going to the section index page, seeing a file name and opening it. With vim I see that I want tricycle.html and I type it, and the file is open. This saves a great amount of time.


Vim can feel really slow when you train yourself to use i to insert, esc :wq to save and more, but once these are natural reflexes using Vim speeds up. I find that the more I use it, and the more comfortable I am with simple things, the more willing I am to experiment with additional features, for example option 8 and nine to jump by paragraphs to go up and down documents.


One of the biggest mental hurdles is remembering to work without a mouse, like we did in the eighties. Everything is via the keyboard so you don’t click and drag. You yank and put. You also shift V to select a line and jk up or down to select more lines. You can then delete.


I am not comfortable with cut and pasting yet but that will come with time. Vim is an excellent piece of software, but you need to invest time in learning how to use it.


I like that it’s free, available on almost all machines automatically, and that it’s resource light. There is no need to have a heavy application like Visual Studio Code running, if you learn Vim.

Laravel and Chirper

Today I used Laravel to code a Twitter clone called Chirper via the tutorial you can find here. The tutorial took about two hours before I got the notifications section of the tutorial. The tutorial is easy to follow and with my contextual knowledge I was able to write most of the code with a minimum of errors. The tutorial follows the CRUD model, Create, read, update delete, and adds in notifications for good measure.


I chose to follow the Blade course rather than the React course because at the moment I feel more at ease with PHP thank JavaScript despite spending months on JS courses. What I like about PHP and Laravel is that when there is an error the code will show you the code with an error and you just need to understand what it is.


With JavaScript and especially with typescript the error message provides you with code that is hundreds of lines away from what is causing the code to fail. It takes seconds or minutes rather than hours to debug an issue.


Although building a twitter clone might not sound exciting, it is worth doing. Creating, reading, updating and deleting are key parts of Content Management systems so if you can do it for content with 255 characters you can easily expand it to blog posts, articles and more. It also means that you have a chat app to use within a small group of friends.


The next step, once I finish the course, is to adapt the code to get the content from my website to work via the Laravel framework. For the next step I want to read documentation. Watching video tutotirals is great sometimes, but it’s time consuming. The next step is to read documentation, and understand it. I have spent enough time building context. Now is the time to put this knowledge into practice.

Learning About Laravel and PHP
|

Learning About Laravel and PHP

Today I started to follow a course where someone turns a static html page into a Laravel blog. I experimented with home.blade and one or two other features and I got two pages to load, and the login to work, without more than that.


What makes today’s learning and experimenting interesting is that the time I spent creating PHP arrays for my website content is now easy to transfer to json files for use with dynamic websites. What this means is that content that was stuck on individual pages is now organised by website section. I am now free to do more.


The primary goal is to convert the static part of my website into a flexible content management system as well as to possibly swallow up the WordPress powered blogs. For at least a year I have disliked that Wordpress uses react, so if I can replace WordPress with Laravel then I will be happy. All websites that use React look the same to me, and I don’t want to use technology that was developed by Facebook, no matter how popular.


Having a website is not just about writing blog posts and creating content. It is also about playing with technology and learning new skills. I want to understand how laravel works, and to have a way to demonstrate that I have learned relevant skills for future job applications. This website isn’t small. It has quite a few sections, topics, content and more. It’s worth working on and improving this website.


And Finally


I am curious about playing with ActivityPub. It is still in early days but if and when it is ready, it will be a more advanced of interactive RSS. I want to see what possibilities it will open up.

Conservation and PHP

Today I have struggled with PHP. I struggled because I want to recreate the same table using loops with PHP as I did formatting with HTML. If I wasn’t up for a challenge I would let PHP loops format it according the default and I’d be done. In the end I did get the table to display as I wanted but not using for loops. I created a table page, laid it out using the data file I’ve been using for this section, and then using include to add that content where I wanted it to be on the page.


It works, and it’s elegant. I want it to be done by a loop. This is important to me because it requires me to learn more about how to use nested loops and this is an important element of programming. It’s a skill worth having.


Before : intermediate : After


Above you can see before css was added, the website looked simple. When CSS was added it looked better, and once it became php it looks similar but the code needed is much less, as data is with included files. The footer and the nav bar are always the same, and for most pages the usual loops are enough to display content on all pages.


With PHP you can just echo html and the page will display as you want it to. With variables and includes you can display the information you want to display automatically, rather than manually.


In most cases you can use “Title”, and “content” and use HTML to format all the data as you want it to be. By doing this the conservation page would be done within minutes but the content would be less flexible. By creating arrays within arrays I make things more modular. I can remove or add sections and it will just change that part of the site without affecting other parts.


The point with PHP, frameworks and javascript is to set everything up so that when changes are made they can be as small or as big as we want, in a modular manner. That’s why my struggling to get things to work today is important. Once I learn how to do this, I will be more confident with future challenges.

A Rainy Day Without Walking

Today the weather app said that it would start raining at 1500 so I didn’t go out for a walk. In the end the rain started at around 1630 or even later. I could have gone for a walk and I could have come back dry or almost dry.


For years I went for walks almost everyday, whatever the weather conditions. I grew tired of the habit. I have had this habit for five years or more, three of which have been during the pandemic.


I am tired of two things. The first is about walking into the building with muddy shoes. The building has no system to clean shoes after a walk in the mud so I can’t remove the mud easily. Usually if I walk in the mud it’s the next day that I leave a mess. I wouldn’t worry but apparently others do.


The second reason I don’t want to go for walks is that I’m tired of encountering people walking as couples or groups. If I encountered people walking alone, especially people my own age then it would be fun. Seeing couples, when you’re solitary during a pandemic is unpleasant. I often change route to avoid them, especially since they almost always take the entire width of the roads or other paths.


I spent today completing the conversion to php from html for the geography part of the website. I have moved from studying PHP to putting the knowledge into practice. Now I will work at having something to showcase, and to have something for the portfolio, to build confidence so that I can apply comfortably.

A Shift to PHP

PHP has been around for decades but I learned of a way to experiment with it easily recently so that is why I am playing with it now. The main page is php as is my first “blog” although it was part of a column for the student newspaper, that I converted to an electronic format and published frequently.


I tried to keep Surfing the World Wide Waves looking as it had back in the day. The aim is to practice with PHP and get some things to become automatic. I include one php file with the data, and a second for the footer. I use a loop to populate each blog post.


It looks like this


  • include data_file.php
  • echo header etc.
  • article title, content etc
  • include footer


The format is simple and I could have made everything a for each loop so that each page is generated automatically but for the sake of learning and persistance I updated each page individually.


Aside from learning how to use PHP it was also an opportunity to practice using VIM.


List of PHP files accessed with vim.


VIM is great for this process because you type vim name of file and you edit the little lines. I used shift V to use visual edit. I bulk deleted the old code I wanted to replace with the include footer line. It’s a repetitive task but that’s good for learning, and for a skill to practice and become habit.


Now that this repetitive task has been done I have more flexibility to edit the footer without having to edit every other individual file. I would have tried with the header element but I need to think about how to do this without losing meta data etc. It should be added to the data file and I could access it as a variable in a different part of the page.


With time I will fine tune all of these ideas and it will be reusable for future projects.

Experimenting with PHP

I have been following courses for three years now. Within the last week or two I decided to start experimenting with PHP using my website as a guinea pig. I have already converted a few pages to PHP. Some of them use for each loops and others use the include functionality. My aim is to practice the skills that I have studied, within a production environment.


Some of the tasks are repetitive. This isn’t a bad thing. It builds habit and understanding. By doing something frequently enough the pattern gets burned into my subconscious. When that’s done I will spot errors automatically, and if I get an error message I will know what it means.


One error message I got was $article was not found and after seeing it three or four times, I know to check that I have included the array data php file. Problem fixed, time to move on to the next page.


What I enjoy about PHP so far is that it’s intuitive. Error messages are from the line beneath the line where the error is. This means that bugs are fixed within seconds not minutes.


Another aspect that I really appreciate about foreach loops is that they’re direct. With Javascript you need to understand the DOM, parent elements, children etc to get things to work. With PHP, so far, I work directly with the elements that I’m manipulating.


If I tried to do my instagram clone now I would find it much easier to do. I progressed.


Looking forward learning to use PHP directly, means that when I use WordPress, Laravel and other solutions I will understand what I am doing, and what is going wrong, if things do not work.


For now I am happy to rework my website. I will practice new skills. The website will benefit.

|

PHP from the Command Line

Recently I learned that PHP has a built in server. You don’t need xampp or any of the other solutions. All you need is terminal open, have the current directory be the one with the PHP files you want to serve and type: “php -S localhost:8000”


This might sound obvious to some but it took years for me to come across this. When you have to install xampp or other solutions you need to dedicate HD space, run the servers and more.


With just one line in terminal we can start the server and start experimenting with and learning PHP. With this you can be up and running within seconds or minutes, rather than hours, and it is flexible.


I’m sharing this with you now because I wish that at least once course had mentioned it. This is the simplest and most elegant solution I have found. Best of all it’s free.


For more info: https://www.php.net/manual/en/features.commandline.webserver.php

On Whether I Prefer Vanilla JavaScript or Frameworks?
|

On Whether I Prefer Vanilla JavaScript or Frameworks?

Today someone on twitter asked this question, and rather than be reply: 320 of 10,000, I chose to write a blog post about it. The TLDR answer is Vanilla JS because if you learn how it works without the help of a framework you understand the language. This doesn’t mean that I don’t have an interest in learning to take full advantage of frameworks.


As I listen to JavaScript Jabber one thing is clear. Whereas if we listen to courses and twitter discussions we are tricked into thinking that we should either use React or Angular we see, through JavaScript Jabber that frameworks are as diverse as they are flexible. One app will be excellent for one type of task and another will be awesome for something else. If you spend time learning Vanilla JavaScript, and then you learn about the diverse choice of frameworks then you can either write concise and effective code that does what you need with little to no bloat.


I don’t want to just learn a framework and be inflexible. I want to learn how it works, behind the scenes. Before WordPress, I was learning about navigation using Server Side Includes and other such tricks. When I played with PhpBoards, WordPress, Drupal, Joomla, wiki software, and more I managed to use them as a user, and they did want I wanted, but I never looked behind the curtains so I could use WordPress, but I couldn’t create my own themes, etc, and to some degree, I still can’t.


I have spent time trying to make it so that I can share my instagram archive on my website without using Instagram, and I managed with WordPress. Recently I tried using Vanilla Javascript and I found manipulating the DOM to be challenging. This is precisely why learning to code with Vanilla JS is so important. It shows you the complexities, and with time you learn how things work together.


One of the jokes is that if you get stuck you should RTFM and with frameworks that’s often quite easy. With Vanilla JavaScript RTFM doesn’t mean read just one manual. It means read about a variety of concepts until you understand enough to get it to work by yourself.


So far I can show a random post after each reload, or show the ten most recent posts and their caption. The next three challenges are:


  1. Go through the posts at a time
  2. Add crud capability using JavaScript. At first I will try with an empty json file, and then move on. CRUD requires understanding of the fs library (I need to double check the term)
  3. Add the ability to transfer data from the json to an SQL or NoSQL database.
  4. Experiment with Houdini and responsive design with a wall of pictures.


We’ll see what else I can think of. The point of this is to take skills I learn in courses and apply them to a project without having someone else provide me with the list of necessary steps.


That’s it for now.