<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sumi Sastri on Medium]]></title>
        <description><![CDATA[Stories by Sumi Sastri on Medium]]></description>
        <link>https://medium.com/@sumisastri?source=rss-79bb57ae3dc8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Ir7R6FalJbgpxkaEdprmfA.jpeg</url>
            <title>Stories by Sumi Sastri on Medium</title>
            <link>https://medium.com/@sumisastri?source=rss-79bb57ae3dc8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 23:43:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sumisastri/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From the super-fast HTML Crash Course a deeper dive]]></title>
            <link>https://sumisastri.medium.com/from-the-super-fast-html-crash-course-a-deeper-dive-6287027aaf32?source=rss-79bb57ae3dc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/6287027aaf32</guid>
            <dc:creator><![CDATA[Sumi Sastri]]></dc:creator>
            <pubDate>Thu, 08 Aug 2024 12:43:56 GMT</pubDate>
            <atom:updated>2024-08-08T12:43:56.795Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Learn to Code HTML5 — Part 1: The fundamentals</strong></p><figure><img alt="The word programmer on a scrabble board" src="https://cdn-images-1.medium.com/max/640/1*9mfIp77ITNgWAm508_MeOw.jpeg" /><figcaption>Photo Credit: Alltechbuzz at Pixabay</figcaption></figure><p>In the first of my series, Learn to Code — I provided a broad overview of why and how to go about <a href="https://medium.com/cancer-research-uk-tech-team-blog/learning-to-code-part-1-of-5-a117f2c0811c">learning to code</a>.</p><p>This article has been updated on <a href="https://sumisastri.github.io/dev-blogs/">my personal blog</a> in 2024.</p><p>In <a href="https://medium.com/cancer-research-uk-tech-team-blog/learning-to-code-part-3-of-5-7c3827c2981a">Part 3</a>, I demo the basics of how HTML (hyper-text-mark-up language) code runs on <a href="https://codepen.io/sumisastri/pen/yLgRpZN">this link </a>or as CodePen terms it a pen</p><p>In this article, I focus on theoretical aspects of HTML. We will look at a brief history of HTML through all its versions to HTML-5, how browsers read HTML files and how and why HTML is so important as a building block to make the web accessible to the widest global audiences.</p><p>Later in the series, we will build more projects purely with HTML. Feedback from my first series Learning to Code was that while the series provided a good overview of HTML, CSS and JavaScript readers wanted to understand how each of these coding languages worked in isolation first.</p><p>HTML is fundamentally a mark-up language. Mark-up languages are not the same as programming languages as they use tags to “mark-up” text and display them on a web-page.</p><p>Programming languages have blocks of logic that change the static display of text on a page. JavaScript therefore is considered a programming language.</p><p>The HTML tags tell web-browsers, which in turn are pieces of software that interpret/ read/ parse the page for the syntax and semantics, how to read the information on a page and display its contents.</p><p>HTML files are special types of files which tell the computer when encounters a `.html` file that it has to be opened in a browser.</p><p>Other files like `.doc` or `.xls` open out in the Microsoft application (app)on the desktop.</p><p>Screen readers help accessibility of the information to those who may not be able to receive this information in the same way.</p><p>To access the widest audience — those with different visual, audio and physical needs to access the web — often rely on the information provided by screen readers to access information, or other assistive technology — like voice to access web and mobile apps.</p><p><strong>HTML Semantics vs Syntax</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*veBfzhvpgo-bcRrQ" /><figcaption>HTML Opening and Closing Tag (Photo Credit: <a href="https://unsplash.com/@jacksonsophat?utm_source=medium&amp;utm_medium=referral">Jackson Sophat</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a>)</figcaption></figure><p>HTML makes use of tags to make it easy for browsers to recognise and parse. Semantic tags have the same semantic sense as plain English, making it very easy to learn. So a &lt;form&gt;&lt;form/&gt; tag means a form is nested between the opening form and closing form tag — like so:</p><p>&lt;form&gt;</p><p>&lt;input&gt;Form Input 1&lt;/input&gt;</p><p>&lt;input&gt;Form Input 2&lt;/input&gt;</p><p>&lt;form/&gt;</p><p>The full list of tags is in the <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element">documentation</a> which is a great reference if you want to understand exactly what the syntax of the tags are, their names and the role they perform on a page.</p><p>While the heading tags or `htags` represent headings on a page there are tags for audio, video, images, page navigation, creating tables.</p><p>The script tags are used to embed JavaScript code while the meta-tags embed access to external libraries. This makes HTML very flexible and extensible or scalable.</p><p>HTML syntax is how the tags are opened and closed in angle brackets`&lt;form&gt; &lt;/form&gt;`.</p><p><strong>Standardisation and cross-browser compatibility from the ashes of the browser-wars</strong></p><p>HTML to HTML5 — traditionalists wanted to keep HTML purely for sharing text documents on the internet.</p><p>As people wanted more information shared — images/ colours/ fonts/ video/ audio — the first version of HTML was inadequate.</p><p>In the 1990s the browser-wars started as the traditionalists did not want this upscaling of the basic reason for the existence of HTML — to share scientific documents over the world-wide-web.</p><p>Each browser developer started writing their own code modernising how their browsers worked. While we still have a plurality of browsers today — Chrome, FireFox, Edge, Safari — the move is now more towards harmonisation of standards and cross-browser compatibility and accessibility of information across the web.</p><p>In 2005, the first beginnings of cross-browser collaboration led to images being written in CSS and HTML in text. The lack of standardisation in approaches led W3Schools and WHATWG(Web Hypertext Application Technology Group) to define how information could be viewed no matter what the browser was and ensure cross-browser compatibility of HTML-CSS and JavaScript written in web-development packages.</p><p>The Document Object Model API was built and it was agreed plugins were not the best way forward and that browsers should also be device-agnostic and work across mobile phones, tablets, computers and wearables.</p><p>Today (2023) the share of the market for Edge/ Opera/ Safari has decreased while Chrome, FireFox have increased.</p><p><strong>How does HTML work in the client-server world to retrieve information with a URL?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8mqpMl8URSG9YYb2" /><figcaption>Photo Credit: <a href="https://unsplash.com/@austindistel?utm_source=medium&amp;utm_medium=referral">Austin Distel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Clients are the devices we used — phones, laptops, wearables, tablets.</p><p>Servers are how the devices are networked together either via local or wider networks. These are referred to LANs and WANs (Local-Area-Network and Wide-Area-Network).</p><p>URLs — unique resource locators — are unique numbers that identify a document on a server. A URL is made up of 3 parts</p><p><a href="https://codepen.io/sumisastri/pen/yLgRpZN">https://codepen.io/sumisastri/pen/yLgRpZN</a></p><ol><li>The protocol (is it http or https)</li></ol><ul><li>Protocols — HTTP/ HTTPS/ FTP (Hypertext Transfer Protocol/ Secure Hypertext Transfer Protocol/ File Transfer Protocol) — this is the way Hypertext is transferred it is a protocol or a set of rules that transfers information.</li><li>HTTPS is the secure way to transfer information. FTP transfers any file format not just HyperText in a specific protocol or set of rules associated with the way the information is transferred.</li></ul><p>2. The domain (codepen.io — the domain name)</p><p>3. The file to retrieve `sumisastri/pen/yLgRpZN` this is the superfast HTML crash code pen document to retrieve</p><p>When you make a request for a URL from your client (device) it goes to the server and requests multiple files from the domain it is directed to. Domains as you can see have different dot extensions codepen has `.io` the Museums Association has `.org` and commercial entities often have `.com`.</p><p>These domain names are determined by <a href="https://lookup.icann.org/">ICANN</a> a registration service for domains known as the (DNS) the Domain Name Service. When you look at `codepen.io` this is called the top-level domain name which is represented by a unique IP (internet Protocol) number or address. ICANN changes the number to a name.</p><p>There are also a lot of hidden (meta-data) files in this request — cookies/ passwords/ the request protocol or header/ the information you get back or the response protocol data. Therefore it is useful to note that all of this data is what the internet protocols send back not the images/ pages you have requested.</p><p>When you are building a website, you are building this information to send to the domain as a packet of files that are stored and that will be returned when a user asks for it. Only one of the files that you are sending is a `.html` file. For styling you will send `.css` files and if you use JavaScript then `.js` files are sent as well.</p><p>These files are bundled or packaged so that it is quicker to upload all of these files to the internet via DNS propagation. This sends the information from your client (computer) to the server to the domain name service through a system of sub-networks in the DNS system.</p><p>Packaging/ bundling files is an important process as it makes the transfer of information fast, efficient and as a result energy efficient as well — as it consumes less memory and less battery/ electric energy.</p><p><strong>Making the web more accessible</strong></p><figure><img alt="An enhanced keyboard for better web accessibility" src="https://cdn-images-1.medium.com/max/1024/0*q1pAXRXTSUfG-mPD" /><figcaption>Photo Credit: <a href="https://unsplash.com/@sigmund?utm_source=medium&amp;utm_medium=referral">Sigmund</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>More and more people who are differently abled are now accessing the internet and standards have changed to make the web accessible to all.</p><p><a href="https://www.w3schools.com/html/html_accessibility.asp">W3Schools </a>provides guidelines for accessablity.</p><p>The first most basic step is to use semantic or easy to understand HTML tags — body, section, aside, audio, video are some such tags. However, for the visually impaired for example, in the image tag an `alt` attribute, or alternative text, is important as a screen reader will read this out so that the user knows what that space on the page represents.</p><p><a href="https://developer.mozilla.org/en-US/docs/Learn/Accessibility/HTML">Mozilla</a> has more in-depth documentation. Aria labels on forms is another way of making forms more accessible.</p><p><a href="https://webaccess.berkeley.edu/resources/tips/web-accessibility]">Berkley University</a> has a good section on how to make your pages more accessible.</p><p>Not only does this improve inclusion it makes commercial sense as you make your site accessible to a wider audience.</p><p><strong>Working with code editors</strong></p><p>HTML can be written in a variety of code editors — NotePad, NodePad++, VIM, SublimeText, Atom, VSCode are some options. As a beginner the best option is a code sandbox like codepen.io.</p><p>If you want to use a code editor the 3 most popular are <a href="https://code.visualstudio.com/">VSCode</a> , <a href="https://atom.io/">Atom</a> and <a href="https://www.sublimetext.com/">Sublime Text</a></p><p>Code editors can be personalised and the developer experience improved with extensions and specific set up. Download an editor and create an account with the editor of your choice. I personally prefer VS Code but have used both Sublime Text and Atom.</p><p>In this series on learning to code HTML, I will only be using CodePen and all the code is easy to access, whether you have a CodePen account or not.</p><p>With the basic theoretical knowledge of HTML is, how files are accessed by browsers as well as a code sandbox, in the next article we will look at best practices when writing HTML code.</p><p>Best practices help code execute more efficiently and improve the developer experience when writing and debugging code in code reviews or even if your future self returns to the code you have written and you look at refactoring the code.</p><p>In <strong>Part 2: Best practices in setting up HTML5 page </strong>we will look the key concepts that govern writing clean HTML code and how to set up and debug your code with CodePen -&gt; next</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6287027aaf32" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git and git heads: how to track origin head, create a detached head and reset or revert detached…]]></title>
            <link>https://sumisastri.medium.com/git-and-git-heads-f1f8c3d9c7df?source=rss-79bb57ae3dc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1f8c3d9c7df</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[version-control]]></category>
            <dc:creator><![CDATA[Sumi Sastri]]></dc:creator>
            <pubDate>Tue, 17 Jan 2023 14:13:14 GMT</pubDate>
            <atom:updated>2024-10-04T08:54:08.234Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Git and git heads: how to track origin head, create a detached head and reset or revert detached heads</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4ABwePP0rU2rpHe0" /><figcaption>Photo credit: <a href="https://unsplash.com/@synkevych?utm_source=medium&amp;utm_medium=referral">Roman Synkevych 🇺🇦</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><em>This article is part of a series on </em><a href="https://sumisastri.github.io/dev-blogs/version-control-repo-management/"><em>branch management</em></a><em> on my personal tech blogs page.</em></p><p>Git — which in British slang means an annoying and infuriating person aka a right git-head.</p><p>It also happens to be a version-control system authored by Linus Torvalds.</p><p>It is no accident, that (GIT) which politely stands for Global Information Tracker, was termed git by Torvalds as he considered it nothing but a “stupid content tracker”.</p><p>For the sake of accuracy here’s a <a href="https://git-scm.com/book/en/v2/Getting-Started-What-is-Git%3F">link to the documentation</a></p><p>Git, to its reputation has some infuriating and annoying terminology, and performs certain content tracking tasks in its own way. Setting git heads is one of them. Git heads can get detached, need to be reset — three ways hard, soft or mixed — or can be reverted instead of reset.</p><p>All a bit confusing until you learn all about git origin heads and how to attach and track them before you can detach and meddle with them.</p><p><strong>What does origin-head mean in a git branch?</strong></p><p>Git branches and <a href="https://git-scm.com/book/en/v2/Git-Branching-Branch-Management">git branch management</a> from the git book goes into some detail on how to manage branches but I found understanding what an origin-head was difficult.</p><p>A basic concept to get right is, that all commits in a git branch are part of a Merkle Tree. <a href="https://en.wikipedia.org/wiki/Merkle_tree">Wikipedia has a good image and description that really helps understanding the concept</a>.</p><p>A Merkle tree is made up of a series of hash-tags that uniquely identify all the commits in a branch. To change the history of a git commit means understanding how each commit fits into this tree-like structure.</p><p>At the top of each branch of the Merkle tree is the head, or origin head. If you commit and run a `<em>git log</em>` in your main branch you should see `<em>commit 123ab456 (HEAD -&gt; main, origin/main, origin/HEAD)</em>`.</p><p>The number you see in the commit is a Secure Hash Algorithm or SHA, or hashtag, that contains all the data of the commit and points to the top of the Merkle tree or the head of the branch.</p><p>This is how a commit points to the head of the git branch. The commit with the hash number holds the data of the author, date and the commit message which describes what the change in the version is all about.</p><p>So when you `<em>git add &lt;filename&gt;</em>` you add your blobs in your working file into a staging area. When you `<em>git commit -m”Commit message”</em>` you save the blob in a log queue.</p><p>Run a `<em>git log</em>` and you should see the blob of data:</p><blockquote>commit 123ab456</blockquote><blockquote>Author: YourName &lt;your email&gt;</blockquote><blockquote>Date: Fri Jan 13 15:11:26 2023 +0000</blockquote><p>The main or master branch is a branch like any other made up of commits. In the case of a main branch, the sub-branches are merged into the main branch and these merged branches are the key commits.</p><p>If you run `<em>git branch</em>` in a repo, you will see a list of branches with an asterisk against the name of the branch you are working on.</p><blockquote>Feature-Create-data-table</blockquote><blockquote>BugFix-Remove-logo</blockquote><blockquote>Chore-Update-docs</blockquote><blockquote>HotFix-Add-codes-to-db</blockquote><blockquote>* Spike-Experiment-with-libraries</blockquote><blockquote>Feature-Create-admin-user-form</blockquote><p>Each of these branches will be merged into the main branch and each of these branches will have their own origin head.</p><p><strong>What does a blob refer to in a git branch and how does it relate to origin head?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8vvajvGT6zwfVk98" /><figcaption>Photo Credit: <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If the concept of git as a tree of data can be used as an analogy, then the commits are like leaves on the branch. Each leaf is a data object or a blob.</p><p>A blob is an acronym for both basic large object or a binary large object (BLOB) but is spelt as a common noun — blob and referred to as such. While many consider a commit as a file that is being committed, we are merely committing blobs of data to the data tree in the branches of the data tree.</p><p>As we have seen, at the top of every branch is the head. To attach the blob data to the branch the first commit must attach itself to the head and is set to the origin head. Each origin head is unique and at the top of the branch that the blob is attached to.</p><p><strong>Setting the origin head of each branch for the first time</strong></p><p>When you first create or clone a repo, add and commit changes, in your first commit you need to set the origin head to track the changes in the main branch with a `<em>$git push -u origin main</em>`. This sets the head to origin-main (previously known as origin-master). You only need to do this one before you create other branches off the main (master) branch.</p><p>However, each new branch you create must also be connected to its unique origin head to track changes of the branch.</p><p>To set up a new branch `<em>git checkout -b &lt;branch-name&gt;</em>` defines your new branch, you can also use the more up to date `<em>git switch -b</em>` to create a branch. When you add and commit for the first time to this branch and push the changes you need to set the upstream origin to the new branch to track the origin head of the new branch you will get a prompt to set the upstream origin of the branch eg: `<em>git push — set-upstream origin &lt;branch-name&gt;</em>`. Once again, you only need to do it with your first commit.</p><p>The branch now tracks unique changes made in your code with the SHA or hashed algorithm. As you have seen above in the log, the SHA is the commit number — `<em>commit 123ab456</em>`. The commits in this branch track the branch origin head and when you merge the branch into master all the changes in the branch track the master branch with its own unique SHA representing the point at which the branch origin head starts tracking the master origin head.</p><p>When you merge master into a branch, all the SHA’s merged into master are merged into the branch and track the branch origin head.</p><p>This flip-flop between the branch and master origin heads can create some challenges.</p><p><strong>Manually setting branch origin head if the process fails</strong></p><p>Sometimes — especially if your computer is slow, you can create a new branch with the `<em>git checkout -b &lt;branch-name&gt;</em>` command and start to add and commit code. When you push the code and you set the origin `<em>git push — set-upstream origin &lt;branch-name&gt;</em>` you find it runs through all the processes checking deltas but the final blob is not pushed to your GitHub repo.</p><p>This happens because you have not successfully checked out of the previous branch into the new branch you have created. Therefore, the branch you have created has an origin head that has not been set and GitHub is still tracking the origin head of the branch you have checked out of.</p><p>To match the new branch head with the remote branch head you will have to set the upstream manually with `<em>git push — set-upstream origin &lt;your branch name&gt;:&lt;your branch name&gt;</em>`. You only have to do this once.</p><p>You may get a prompt to run `<em>git config</em>` to automatically set your upstream branch. You can `<em>git config — global push.autoSetupRemote true</em>` this way you do not need to manually set the upstream branch up with each creation of a new branch.</p><p>If you wish to ignore this config option, you will need to manually attach the branch blobs to the branch origin head.</p><p><strong>What is a SHA and what does it do in git?</strong></p><p>A SHA is a hash function which takes an input and produces a 160-bit (20-byte) hash value known as a message digest — typically rendered as a hexadecimal number, 40 digits long. It was designed by the United States National Security Agency, and is a U.S. Federal Information Processing Standard.</p><p>SHA-1 sometimes know as SHA-0 is deprecated/ SHA-2 and SHA-3 are now required for SSL certificates for browsers by the NIST (National Institute of Standards and Technology).</p><p>Version control systems still use SHA-1 to hash versions.</p><p>Every blob has a SHA which is the serialised number that holds the commit message, author name, time and date of creation.</p><p>As you add commits and run `<em>git log — oneline</em>` you will see all your commit messages in a single line with the commit message and the serialised number that uniquely identifies it. The `<em>oneline</em>` flag removes the author, date and other information that is contained in the `<em>git log</em>` command so that you can see the key information</p><p>In this case there is only one branch which is origin master therefore all the commit logs you see point to the origin head of the master branch.</p><blockquote>b4ceaa6 (HEAD -&gt; master, origin/master, origin/HEAD) Add regex</blockquote><blockquote>eec4771 Conditionally render url on submit for home page</blockquote><blockquote>0beb61d Fixes radio buttons css and custom component</blockquote><blockquote>c1790e4 Debug radio buttons</blockquote><blockquote>3d2fee9 Add radio buttons — initial set up</blockquote><blockquote>db6284a Add radio buttons component to component library</blockquote><blockquote>6505fea Add checkbox to registration page</blockquote><blockquote>1d3e6a6 Refactor select filter to make it a reusable typescript component</blockquote><p><strong>What is a detached head in git?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v14flD-YQwUfHkH4" /><figcaption>Photo Credit: <a href="https://unsplash.com/@cadop?utm_source=medium&amp;utm_medium=referral">Mathew Schwartz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A blob may be detached from a head — that is when you get a detached head. It can be consciously created so that you can work in a detached head.</p><p>The use of detaching a blob from the head is to pretty much remove a part of the data to experiment with it — if the experiment proves to have no value the detached head can be discarded. If the the experiment is useful, then the blob can be reattached to the branch head.</p><p>However a detached head might occur by accident. If you get an error message you need to attach the blob to a branch.</p><p>Here are 3 easy steps to fix this</p><p><strong><em>Step 1:</em></strong></p><p>First check out of the branch that is in headless state `<em>git checkout &lt;headless-state-branch&gt;</em>`. This will save the detached head to this branch.</p><p><strong><em>Step 2:</em></strong></p><p>Attach the headless blob to a branch which is tracking an origin head correctly `<em>git checkout &lt;branch-name-to-attach-headless-blob&gt;</em>` this is any branch of your choice, including main (master).</p><p><strong><em>Step 3:</em></strong></p><p>In this branch merge `<em>git merge &lt;headless-state-branch&gt;</em>` the headless branch now tracks the branch you have switched to, i.e. `<em>&lt;branch-name-to-attach-headless-blob&gt;`.</em></p><p>If you do not want the code in the headless state branch instead of merging you delete the blob by `<em>git delete &lt;headless-state-branch&gt;`</em> this is a destructive command and is not recoverable.</p><p>You may want to read the chatter on <a href="https://stackoverflow.com/questions/10228760/how-do-i-fix-a-git-detached-head">StackOverflow</a> which I personally found confusing although it made me do some root cause analysis to find out how git tracks changes.</p><p>Understanding the Merkle tree, how a commit is a blob and how a blob is attached to an origin head made it easier to understand some of the challenges with git heads.</p><p>More reading on detached heads</p><ul><li><a href="https://circleci.com/blog/git-detached-head-state/#:~:text=What%20does%20detached%20HEAD%20mean,commit%20or%20the%20remote%20repository.">Circle CI</a></li><li><a href="https://www.cloudbees.com/blog/git-detached-head">Cloud Bees</a></li></ul><p><strong>What is the difference between git reset hard, soft and mixed?</strong></p><p>You may want to reset the head of your list of commits to a particular SHA. This can happen if you have committed code and think that some of the commits have added no value to the code base. You want to rewind to a particular point in the commit history where the code was working and more useful to continue from this point that the point you are at.</p><p>Here is some fake commit history to work with to illustrate the point.</p><blockquote>commit 123ab456</blockquote><blockquote>commit 223ab446</blockquote><blockquote>commit 223de446</blockquote><p>In this example at SHA `<em>commit 223de446</em>` you want to rewind and go back to `<em>commit 123ab456</em>` and you do not know whether to reset or revert…what you need to know is that there are three types of resets and a revert may be the safer option.</p><ul><li>`<em>git reset — mixed &lt;SHA&gt;</em>` default behaviour and is same as `<em>git reset &lt;SHA&gt;</em>` if you do not specify a flag, the default behaviour when your run a `<em>git status</em>` the files are in working directory — the place where they would be if you ran a `<em>git add &lt;filename&gt;</em>` when you are working on code</li><li>`<em>git reset — soft &lt;SHA&gt;</em>` does not remove either tracked or untracked files, you can deal with these files manually either discarding them or keeping them in the staging directory. This is the same place after you have added the files and have the files ready for a `<em>git commit</em>` — the SHA is removed from the files but the files are not removed from the branch</li><li>`<em>git reset — hard &lt;SHA&gt;</em>` removes all tracked files from the branch and you will not find these files either in the working directory or staging area. Untracked files will remain in the working directory.</li></ul><p>Resets can be a bother and it may be therefore wiser to choose a revert.</p><p><strong>What is the difference between reset and revert in git and when to use them?</strong></p><p>If you run `<em>git revert &lt;SHA&gt;</em>` no files are deleted unlike the reset command. Revert is often the better choice as a new SHA is created migrating all the files from the commit that you want to revert to.</p><p>In the example using the fake commit data from the if you run the command `<em>git revert commit 123ab456</em>` all the files in this commit will be created in a new SHA — remember the SHA is a function that creates meta data around the files that they contain.</p><p>All the blob data that you commit to a revert will be contained in the revert. The SHA function runs the new commit has the old files and a new SHA.</p><blockquote>commit 123ab456</blockquote><blockquote>commit 223ab446</blockquote><blockquote>commit 223de446</blockquote><blockquote>commit 22356de44689 — — now is reverted to the information in commit 123ab456</blockquote><p>The files (or blobs) `<em>commit 223ab446</em>` and `<em>commit 223de446</em>` will be ignored `<em>commit 22356de44689</em>` is created with your files from `<em>commit 123ab456</em>` . This blob `<em>commit 22356de44689</em>` continues to track your branch origin head and you can work on your files as if you have discarded the blobs `<em>commit 223ab446</em>` and `<em>commit 223de446</em>` without having to delete them.</p><p>If you run a `<em>git diff 123ab456 22356de44689</em>` between the old and new commit blobs you will see the changes you have made and you can push them to the branch origin head.</p><p>While this works like an amend, it does not amend the git history and is better than the `<em>git - -amend</em>` command. It is also better than the `<em>git reset</em>` command as you do not have to deal with lurking files in your working directory or staging directory or even think about whether you should be running a hard, soft or mixed reset.</p><p><strong>What does git commit — amend do and why is git reset is the better option?</strong></p><p>Before you push a commit, the commits are queued and batched and you can still make changes using `<em>git commit - -amend</em>`. For example you notice that you have written the wrong commit message when you run a log</p><blockquote>af406b7 (HEAD -&gt; Feature-add-new-branch) Update docs 6</blockquote><blockquote>0a12f1c (origin/Feature-add-new-branch) Update docs 4</blockquote><p>You now want this commit message to read Update docs 5. When you run the `<em>git commit - -amend-m “Update docs 5”</em>`.</p><blockquote>fd9b085 (HEAD -&gt; Feature-add-new-branch) Update docs 5</blockquote><blockquote>0a12f1c (origin/Feature-add-new-branch) Update docs 4</blockquote><p>You can see that this has now been amended successfully by running a `<em>git log - -oneline</em>` again and checking if the amend has worked. You can also use the `<em>- -amend &lt;filename&gt;</em>` flag to add a file that you may have missed out in the commit.</p><p>The amend, however changes git history — you will note the SHA — or the algorithm for the hash — is rerun and you have two different SHAs for the two separate commits.</p><p>Using amend when you are code-sharing with a large team should be used advisedly. It is ok for side projects where you are the only user of the repo making changes because it does change the history.</p><p>When you push your code to your branch origin you have created a file or blob that now tracks the branch’s origin head until it is merged with the main branch. Once it is merged into the main branch, it now tracks the origin head of the main branch.</p><p><strong>How to consciously create a detached head state?</strong></p><p>And now I leave the best for last.</p><p>A detached head — when you get into a detached head state accidentally sounds awful and medieval. A head lopped off hanging bloody on spikes on the top of castle or fort gates comes to mind.</p><p>Actually, a detached head is not so diabolical. When it comes to git heads and a detached head can work like a code sandbox. You can use if if and when you want to refactor code.</p><p>Using `<em>git reflog</em>` you can check into a branch and move it to a headless state. `<em>reflog</em>` or reference log is a list of the logs and each commit as it is represented in its distance away from the origin head. This is serialised in numbers starting from 0, in short it is the log of when you last referenced the logs.</p><p>For example if you want to experiment in the files from the commit in `<em>HEAD{1}</em>` you can copy the SHA of the commit and checkout into the commit. When you run `<em>git checkout af406b7</em>` a fake SHA representing `<em>HEAD{1}</em>` you immediately get a notification that you are in the detached head state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SWWyHuCn8OdgbUib" /><figcaption>Photo by <a href="https://unsplash.com/@afgprogrammer?utm_source=medium&amp;utm_medium=referral">Mohammad Rahmani</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The notification gives you a list of these advantages — You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by switching back to a branch — in effect, it works like a code sandbox.</p><p>If you do want to retain the experimental work you can create a new branch `<em>git switch -c &lt;new-branch-name&gt;`</em> — this branch will remain in the headless state unless you set the remote origin to track these changes. As we have seen earlier you can add and commit but when you push you can run the command `<em>git push — set-upstream origin &lt;your branch name&gt;:&lt;your branch name&gt;</em>` with this detached head to attach it to a unique origin head. Once again, you only need to do this once to track all commits in this previously headless branch. In this example what I have done is `<em>git push — set-upstream origin backup-update-6:backup-update-6</em>`</p><p>If you do not create a branch and track changes in this detached head state, git will garbage collect and in 30 days the changes will be permanently removed.</p><p><strong>How to manage git heads easy if you know how</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dvsVSmdvWkWO0WsI" /><figcaption>Photo Credit: <a href="https://unsplash.com/@priscilladupreez?utm_source=medium&amp;utm_medium=referral">Priscilla Du Preez</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>As you can see Torvalds is actually right, it is quite an easy to understand content tracking system if you know how the git head is set.</p><p><strong>In summary</strong></p><ul><li>The head of the whole project you are tracking in a repo is set once in the main branch.</li><li>Each data blob or commit tracks the head that the branch is tracking via a SHA algorithm that collates all the data and tracks the deltas with a hashed number.</li><li>The main branch is exactly like any branch.</li><li>All new branches created are merged into the master branch.</li><li>Each new branch has its own unique head to track changes in the sub-branch.</li><li>Unless upstream origin head is set once, either manually or through a `<em>git config`</em> automatically, you have a detached head.</li><li>Detached heads are like sandboxes and can be manually re-attached to the origin.</li></ul><p>Hopefully this helps you from head butting a git head!</p><p>In this series <a href="https://medium.com/@sumisastri/how-to-change-a-local-git-branch-name-in-five-easy-steps-b79900a69517">How to change a git branch name</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1f8c3d9c7df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to change a local git branch name in five easy steps]]></title>
            <link>https://sumisastri.medium.com/how-to-change-a-local-git-branch-name-in-five-easy-steps-b79900a69517?source=rss-79bb57ae3dc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/b79900a69517</guid>
            <category><![CDATA[version]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Sumi Sastri]]></dc:creator>
            <pubDate>Thu, 29 Dec 2022 19:52:02 GMT</pubDate>
            <atom:updated>2024-10-04T08:52:41.121Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="The word change with its mirror image" src="https://cdn-images-1.medium.com/max/1024/0*iQCKt88-tRDiTL-d" /><figcaption>Photo Credit: <a href="https://unsplash.com/@jannerboy62?utm_source=medium&amp;utm_medium=referral">Nick Fewings</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><em>This article is part of a series on </em><a href="https://sumisastri.github.io/dev-blogs/version-control-repo-management/"><em>branch managemen</em></a><em>t on my personal blog pages.</em></p><p>Changing a branch name in Git sounds easy but there are some gotchas. Here’s an easy way to get it right.</p><p>Git is a tool that tracks changes to source code, and it’s very basic. That’s what it does. It tracks changes to any file, but it’s mostly used for source code files. Earlier in the series the article on <a href="https://sumisastri.medium.com/git-and-git-heads-f1f8c3d9c7df">Git and git heads</a> provides some context on how git as a version control system works under the hood.</p><p>The challenge is once a file is created, it is created permanently.</p><p>Let’s look at this scenario.</p><p>You’ve checked of your master branch and created a file `<em>git checkout -b “My-bile-name”`</em> and you hit enter without really reading what you have written, or fat fingers and hit the enter button too fast.</p><p>Now you haven’t really noticed this and you have continued to write some code that you really need in the branch. And you don’t want to lose the code you have written.</p><p>We’ve all been there… so what do you do to change the file name to <em>`My-file-name`</em>. Remember, the challenge is that <em>`My bile name`</em> has been created and will remain in the repository permanently. If you do not delete this branch the code from both branches collide.</p><p>It is not as simple as just changing a file name and the code you have written in one file gets transferred to the file with the new file name.</p><p>You have to also solve the challenge of having a lurking file that is tracking changes to your code in a separate origin head to delete.</p><h4><strong>Here are 5 easy steps to follow to change your branch name, transfer the code to the new branch and delete the old branch</strong></h4><p>To cut to the chase</p><ol><li>Checkout of the branch with the incorrect name `<em>git checkout any-other-branch`</em></li><li>Change branch name <em>— `git branch –m old-name new-name `</em></li></ol><p>3. Check in to new branch `<em>git checkout new-name</em>`</p><p>4. Push changes to the new origin head `<em>git push -u origin new-name</em>`</p><p>5. Safely delete old branch `<em>git push -d origin old-name</em>`</p><p>For a little more detail on the steps following an example and seeing how this works.</p><p><strong><em>Step 1</em></strong>:</p><p>If you are in the branch `<em>My-bile-name</em>`, checkout of the branch into another branch `<em>git checkout any-other-branch</em>`.</p><p><strong><em>Step 2:</em></strong></p><p>Change the name of the branch `<em>git branch –m old-name new-name</em>`. To follow the example above `<em>git branch -m My-bile-name My-file-name</em>`. The <em>`m`</em> flag denotes move.</p><p><strong><em>Step 3:</em></strong></p><p>Now you can check into your new branch `<em>git checkout new-name</em>`. To follow the example `<em>git checkout My-file-name</em>`</p><p><strong><em>Step 4:</em></strong></p><p>You need to make sure that the code in the old branch is now pushed to the new origin head so you run the command `<em>git push -u origin new-name</em>`. Again to follow the example `<em>git push -u origin My-file-name</em>`. This command maps the code from your old branch `<em>My-bile-name</em>` to the new branch `<em>My-file-name</em>`.</p><p>You should see a success message <em>[new branch] new-name-&gt; new-name branch ‘new-name’ set up to track ‘origin/new-name`, </em>or as in the example<em>[new branch] My-file-name -&gt; My-file-name branch ‘My-file-name’ set up to track ‘origin/My-file-name`</em>.</p><p><strong><em>Step 5:</em></strong></p><p>Check the list of branches `<em>git branch -a</em>` you will see your old branch and to avoid code collision you need to delete this branch. You can also go to <em>GitHub, </em>if that is your version control system and create your pull request. You will see both branches here as well. Or if you use a GUI to check version control you can also check your GUI for the branches that are live.</p><p>As you are checked into the branch `<em>My-file-name</em>` you can now safely delete the old origin head of the branch `<em>My-bile-name</em>` running the command `<em>git push -d origin old-name</em>` or as in the example `<em>git push -d origin My-bile-name</em>`.</p><p>You should get a confirmation message in terminal — <em>[deleted] old-branch</em></p><p>The local and remote now will have only one branch with all the commits in the new branch.</p><p>The old branch has been safely deleted after new branch created.</p><h4>Additional answers and resources</h4><p>Git <a href="https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-branches-in-your-repository/renaming-a-branch">documentation</a> always the best option to go to source!</p><p>There are good examples on <a href="https://stackoverflow.com/questions/6591213/how-do-i-rename-a-local-git-branch">Stack Overflow</a> as well on this link if you want to see other ways to solve the challenge you are facing on the question <strong>How do I rename a local git branch?</strong></p><p>A general google search also provides a lot of answers — but I personally found the answers confusing as the steps are there but why you are executing the steps in a particular order was not.</p><p>If you find you follow video-tutorials better I recommend this <a href="https://www.youtube.com/watch?v=oaIrEwzBXuY&amp;t=87s">YouTube</a> really thorough and easy to understand with a few ways to rename a local git branch. And for <a href="https://www.youtube.com/watch?v=cEfoB8Hl2gY">complete beginners this tutorial</a> is even better!</p><p>Happy days!</p><figure><img alt="Happy folks jumping to the sun rising in the background" src="https://cdn-images-1.medium.com/max/1024/0*s4ka7mMATWS-2M92" /><figcaption>Photo Credit: <a href="https://unsplash.com/@guillealvarez?utm_source=medium&amp;utm_medium=referral">Guille Álvarez</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b79900a69517" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning to Code Part 5 of 5 — How the internet works — deploy your app to the web with Netifly]]></title>
            <link>https://medium.com/cancer-research-uk-tech-team-blog/learning-to-code-part-5-of-5-85a61f418a93?source=rss-79bb57ae3dc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/85a61f418a93</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Sumi Sastri]]></dc:creator>
            <pubDate>Mon, 26 Apr 2021 19:49:27 GMT</pubDate>
            <atom:updated>2024-08-08T12:53:10.413Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Using the internet on a mobile phone" src="https://cdn-images-1.medium.com/max/640/1*20wAIR2cBS-oeTyyoeAOMg.jpeg" /><figcaption>Credit: Pixabay</figcaption></figure><p>As we are going to deploy our portfolio site to the web, in this article we review how the internet works and how your files are read, stored and received by your users and viewers.</p><p>An updated version of this article in 2024 is on <a href="https://sumisastri.github.io/dev-blogs/">my personal blogs pages</a>.</p><figure><img alt="A computer network of 2 computers linking a buyer and a seller" src="https://cdn-images-1.medium.com/max/640/1*cqZjP3PPM3yo34G47jedKw.jpeg" /><figcaption>Credit: MediaModifier for Pixabay</figcaption></figure><p>The internet, is just a network of computers that talk to each other over a computer network. A network can be made up of two or more computers.</p><p>The internet connects trillions of computers and mobile devices over the world, using the world-wide-web. The internet itself is a data-layer over the web that shares all of this information.</p><p>This information is collected via web-browsers, from websites. Web-browsers are software-engines that read and interpret the computer code from web or mobile apps and transmits this information via unique-resource-locator(URL) to a server. A server hosts billions of URLs and “serves” them back to any other user who is interested in this information.</p><p>All of this information is written in code on one computer (client) sent to a server via an Internet Protocol (IP) address . An IP address is a series of numbers that uniquely identifies a computer . The server decodes the query-string — your URL — and then sends this information back to a user. This process is often called the client-server model.</p><p>If you are a buyer and are looking for a product to buy, your laptop is the client, your request for a URL goes via interconnected servers managed by the DNS (Domain Name System) to the seller’s computer (another client) and serves back the content hosted on an URL once again through this network of servers back to your laptop or mobile device all in a matter of micro-seconds.</p><h4><strong>How HTML, CSS &amp; JavaScript are parsed on the web</strong></h4><figure><img alt="Code with HTML CSS and JavaScript" src="https://cdn-images-1.medium.com/max/1024/1*DU2YN_YGGWwYQkIb3dbu3Q.png" /></figure><p>When a request comes in to the client — your computer with your HTML, CSS and JavaScript files — via your computer’s operating system allows the files on your system to be read by or parsed by the web browser.</p><p>The first files that are fetched are HTML and CSS. Then JavaScript, via its connectivity to the Document Object Model, or DOM, is parsed.</p><p>(In <a href="https://sumisastri.medium.com/learning-to-code-part-4-of-5-38f7e39d5c83"><strong>Part 4: Your own portfolio or website template with HTML, CSS &amp; JavaScript</strong></a><em>, you will find a more detailed explanation the DOM-tree and how JavaScript interacts with HTML and CSS, with the code for the portfolio site we are going to deploy in this article.</em>)</p><p>What <a href="https://www.netlify.com/">Netifly</a> does is a pre-rendering, pre-reading, or a pre-parsing of these files, before the file is actually transferred to the URL where it is hosted.</p><p>Traditional websites need the client-server model to run. Running sites this way needlessly slows things down, provides way too many opportunities for attack, and is expensive to scale.</p><p>Unlike the large legacy apps, JAM-stack projects neatly separate the frontend pages and user interface (UI) from the backend apps and databases.</p><p>Read Part <a href="https://sumisastri.medium.com/learning-to-code-part-2-of-5-f7e93ca529ac">2</a> in the series if you have missed them to understand the difference between front-end and back-end code bases, and more about the JAM stack.</p><p>JAM refers to JavaScript, APIs and mark-up (HTML &amp; CSS). APIs are application protocol interfaces, or a way of getting data from the back-end to the front-end, without relying on a server.</p><p>Freed from backend servers, websites run faster with automated deployments of the code you have written.</p><p>Rather than building content at runtime for each request, content is prebuilt and optimised during a build setup using a site generator and other build tools.</p><p>Decoupling the frontend from the backend allows for more modular development.</p><h4><strong>File Set-up on Sublime Text</strong></h4><p>To take advantage of the content in this section, you need to:</p><ul><li>create an account with <a href="https://www.netlify.com/">Netifly</a></li><li>download a code editor — <a href="https://www.sublimetext.com/">Sublime Text</a> is good for beginners</li><li>set up a <a href="https://github.com/">GitHub </a>account</li></ul><p>In case you missed them, here are the links for Parts <a href="https://medium.com/@sumisastri/learning-to-code-part-1-of-5-a117f2c0811c">1</a>, <a href="https://sumisastri.medium.com/learning-to-code-part-2-of-5-f7e93ca529ac">2</a>,<a href="https://sumisastri.medium.com/learning-to-code-part-3-of-5-7c3827c2981a"> 3 </a>and <a href="https://sumisastri.medium.com/learning-to-code-part-4-of-5-38f7e39d5c83">4</a> in the series.</p><p>In Sublime text create a folder and give it a name, for example, <strong>&lt;My portfolio folder&gt;. </strong>If you have not created your own portfolio site go back to <a href="https://sumisastri.medium.com/learning-to-code-part-4-of-5-38f7e39d5c83">Part 4</a><strong> </strong>in<strong> </strong>this series. Once you have your site, continue with this section.</p><p>In this folder open a new file and name it <strong>index.html</strong>. Copy and paste your CodePen HTML-code into this file. This indexes the HTML content for the browser to parse. If you would like to use the code provided in <a href="https://codepen.io/sumisastri/pen/oNBadVp">the Portfolio pen</a> then feel free to do so, and do modify it to suit your needs if you wish.</p><p>Save the file and add another file and name it <strong>styles.css</strong>. Copy and save your CSS-code into this file. Make sure the import in the meta data in the HTML boiler-plate is correct.</p><p>Do the same with the JavaScript code in a file called<strong> scripts.js. </strong>Remember this file is imported as meta data just above the closing body tag<strong> &lt;/body&gt;. </strong>Check the file has been imported correctly.</p><h4><strong>Transfer files to a GitHub repo</strong></h4><p>Git is the version control system from Microsoft. Version control managers allow you to commit your code. Each version gets a unique <em>id</em> to tag each version. Version control, enhances collaborative code writing, peer reviews and maintaining an evolving code base.</p><p>Repositories are created both for personal side projects and for commercial organisations to maintain their code base.</p><p>You can upload your files following the instructions on GitHub with a single click or you can use your computer terminal and connect your laptop to this cloud-based version-control hub.</p><p>Note if you are not already familiar with the Terminal or it gets too much to learn at this stage skip this section and go straight to the section <strong>Deploy over Netifly</strong>.</p><blockquote><strong><em>Optional reading — using the terminal and CLI tools</em></strong></blockquote><p>The Terminal is a Command Line Interface(CLI) that allows you to interact directly with your laptop’s operating system.</p><p>You can use it to run programmes, manage files and folders and install software.</p><ul><li>With a Mac cmd + space — you will get spotlight search</li><li>Type Terminal in the search bar and hit enter</li><li>You will get your mac’s default Terminal</li></ul><p>With Windows window icon</p><ul><li>Type Terminal in the search bar and hit enter</li><li>You will get your Windows’s default Terminal</li></ul><p><a href="https://www.cs.dartmouth.edu/~campbell/cs50/shellcontinued.html"><em>Further reading on the CLI</em></a></p><p><em>Some useful terminal commands (the dollar symbol indicates you must start at terminal leaving no spaces between the first character you type and the terminal file path end)</em></p><ul><li>$ls — (this will list all the files in your computer drive)</li><li>$ls -a — (lists all including hidden files)</li><li>$pwd — (prints the working directory file path)</li><li>$cd —(helps you change directories)</li></ul><p><em>To connect your laptop files to your GitHub repo using the terminal</em></p><ul><li>$cd (type the full file path and name where you have stored your portfolio folder with the HTML, CSS and JavaScript files)</li><li>$git init (initialise with git)</li><li>$git add README.md/ $mkdir README.md — (make a readme file this markdown or .<em>md</em> file documents how you set up your repo and code)</li><li>$git commit -m”initial commit” (make your first commit)</li><li>$git branch -m main (CREATE A NEW MAIN BRANCH TO PUSH CHANGES FROM LOCAL)</li><li>$git remote add origin — <strong>**(use HTTPS URL not SSH)**</strong></li><li>$git push -u origin main — (make the first push and linking remote and local repos)</li></ul><h4><strong>Deploy over Netifly</strong></h4><p>From your GitHub repo, now drag and drop your files into Netifly in the first tab called Site Overview.</p><p>Netifly will ask for permission to install software into your GitHub repo and the specific file you want to deploy.</p><p>Select your portfolio from your GitHub repo and grant Netifly access.</p><p>Click the deploy button at the bottom — ignore all the other sections of the page.</p><p>The files are deployed in less than five minutes. A random URL is generated that you can view your site on.</p><p>I chose my repo spinning snakes to deploy — the random link I was given for this 5 minute deployment is: <a href="https://elastic-minsky-12de5c.netlify.app/">https://elastic-minsky-12de5c.netlify.app/</a></p><h4>If at first you don’t succeed — one for the road,<a href="https://elastic-minsky-12de5c.netlify.app/"> the Spinning Snakes Project</a></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wtXlPswZFouqaJCVWAdghw.png" /></figure><p>This is the most difficult part of the series. Getting to know the Terminal, CLI commands, GitHub and Deployment is a huge amount to learn and get right in the first instance.</p><p>Do not be disheartened if you did not succeed.</p><p>This is the last hurdle and it takes a whole team in an organisation to deploy websites, set-up version control work flows and clean up code with peer-reviews in the real world.</p><p>Just by attempting to set these steps up and familiarising yourself with these tools gives you the destination you are headed for.</p><p>It takes 3–4 months of learning everything else to deploy a site successfully.</p><p>If you got it done after several tries, amazing and good job. It all will get done in due course — enjoy the journey rather than focusing on the destination and keep coding!</p><p>If you didn’t manage to get your site deployed. Persist with the several excellent <a href="https://guides.github.com/introduction/git-handbook/">free tutorials</a> on GitHub that are well worth checking out.</p><p>If you want to look at the source files, for the <a href="https://elastic-minsky-12de5c.netlify.app/">Spinning Snakes Project</a> which I have deployed here, go to my GitHub repo <a href="https://github.com/SumiSastri/javascript-spinning-snakes">link</a> and download the zip-files.</p><ul><li>Check how this project works on CodePen, with Sublime Text. —</li><li>See if you can push these files to your own GitHub repo.</li><li>Try to deploy your version of the project on Netifly.</li><li>Check out CSS animations as the snakes spin not because of JavaScript but because of CSS.</li><li>If you need to navigate back here are the links to Parts <a href="https://medium.com/@sumisastri/learning-to-code-part-1-of-5-a117f2c0811c">1</a>, <a href="https://sumisastri.medium.com/learning-to-code-part-2-of-5-f7e93ca529ac">2</a>,<a href="https://sumisastri.medium.com/learning-to-code-part-3-of-5-7c3827c2981a"> 3 </a>and <a href="https://sumisastri.medium.com/learning-to-code-part-4-of-5-38f7e39d5c83">4</a> in the series.</li></ul><p>Above all have fun!</p><blockquote>Thanks for your time and for making it to the end of this series :-).</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85a61f418a93" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cancer-research-uk-tech-team-blog/learning-to-code-part-5-of-5-85a61f418a93">Learning to Code Part 5 of 5 — How the internet works — deploy your app to the web with Netifly</a> was originally published in <a href="https://medium.com/cancer-research-uk-tech-team-blog">Cancer Research UK Tech Team Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning to Code Part 4 of 5]]></title>
            <link>https://medium.com/cancer-research-uk-tech-team-blog/learning-to-code-part-4-of-5-38f7e39d5c83?source=rss-79bb57ae3dc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/38f7e39d5c83</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Sumi Sastri]]></dc:creator>
            <pubDate>Mon, 26 Apr 2021 18:52:47 GMT</pubDate>
            <atom:updated>2024-08-08T12:51:24.526Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Learning to Code Part 4 of 5-Your own portfolio or website template with HTML, CSS &amp; JavaScript</strong></h3><figure><img alt="Portfolio layouts for tablets, PCs and phones" src="https://cdn-images-1.medium.com/max/640/1*WiKDmLqrBXtJnIO3jWNUfw.png" /><figcaption>Credit: Coffee Bean for Pixabay</figcaption></figure><p>In this article, you have access to <a href="https://codepen.io/sumisastri/pen/oNBadVp">the Portfolio pen</a>, a free template I have created, that you can use and customise. It is designed with HTML, CSS &amp; vanilla JavaScript.</p><p>In 2024 this article has been updated and can be viewed on <a href="https://sumisastri.github.io/dev-blogs/">my personal blog posts pages</a>.</p><p>A word of advice, invest your time learning JavaScript. If this project interests you, do read the documentation and try more exercises from <a href="https://www.w3schools.com/html/">W3 Schools </a>and <a href="https://developer.mozilla.org/en-US/docs/Learn/CSS">Mozilla</a>, both sites have excellent documentation and free tutorials. Google new terms, read and research as much as you can.</p><p>In case you need to go back before you start this section here are the links:</p><p>In <a href="https://medium.com/@sumisastri/learning-to-code-part-1-of-5-a117f2c0811c"><strong>Part 1 — So you want to learn to Code</strong></a> we explore what motivates you and how to go about learning to code.</p><p>In <a href="https://sumisastri.medium.com/learning-to-code-part-2-of-5-f7e93ca529ac"><strong>Part 2 What is a “real” coding language?</strong></a> we explore what code is and isn’t and what are the “real” coding languages.</p><p>In <a href="https://sumisastri.medium.com/learning-to-code-part-3-of-5-7c3827c2981a"><strong>Part 3 Have fun learning to code HTML, CSS &amp; JavaScript with three “pens”</strong></a> we learn by doing, creating and adapting three mini-projects in HTML, CSS and JavaScript on CodePen. You will need to have completed this to feel comfortable with this section, or have prior knowledge of HTML and CSS.</p><p>JavaScript was originally written and designed in 10 days by <a href="https://en.wikipedia.org/wiki/Brendan_Eich"><em>Brenden Eich</em></a> in the 1990s. It has as many exceptions as it has rules. It failed to gain popularity until the early 2000s and now it is the fastest growing language by popularity and adoption.</p><p>The European Computer Manufacturers’ Association, <a href="https://en.wikipedia.org/wiki/Ecma_International">ECMA</a>, acts as a standards body for JavaScript and updates JavaScript design patterns. <a href="https://www.w3schools.com/Js/js_es6.asp">ECMA-6</a>, or ES6, was the first major update to JavaScript. Each year since new updates have been added, part of a developers’ job is to keep abreast of these changes, a list of the revisions up to 2020 are on <a href="https://en.wikipedia.org/wiki/ECMAScript">this link</a>.</p><p>Like CSS, the basics of vanilla JavaScript or JS, is easy to learn but difficult to master. There are no short-cuts except to practice, practice, practice and learn, learn, learn.</p><p>Google new terms and research everything you read to layer and improve your knowledge. Wherever possible, I have added links to make this process easier for you.</p><h4><strong>Start your project with HTML &amp; CSS first</strong></h4><figure><img alt="The Portfolio Pen web template on CodePen" src="https://cdn-images-1.medium.com/max/600/1*pSDofSOMR21DrAM8St335A.png" /><figcaption>The template you can modify with a image slider</figcaption></figure><p>Go back to <a href="https://codepen.io/sumisastri/pen/oNBadVp">the Portfolio pen</a>. Copy and paste the HTML and CSS into your own workspace creating your pen first.</p><p>Personalise both the HTML &amp; CSS to suit your needs. Don’t be afraid it is just text, change the text and see how it looks. Then change the styling.</p><p>Run the analyse HTML chevron to make sure there are no syntax mistakes. Note that two external libraries have been added to the boiler plate. I have commented the file with notes. If you want to write your own notes the syntax for comments is:</p><ul><li><strong>HTML</strong> &lt;! — <em>Write HTML comments here</em> — &gt;</li><li><strong>CSS</strong> <strong>/* </strong><em>Write CSS comments here </em><strong>*/</strong></li><li><strong>JavaScript </strong>// <em>Write JS comments here</em></li></ul><p>In the CSS, I have marked the sections with <a href="https://css-tricks.com/snippets/css/complete-guide-grid/">CSS-Grid </a>and <a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/">CSS-FlexBox</a>, these help in creating flexible layouts, using comments. <a href="https://css-tricks.com/">CSS Tricks </a>is another great resource if you find documentation trying.</p><p>Only when you are happy with how the page looks for you progress to the JavaScript section.</p><h4><strong>How JavaScript uses the DOM-tree to change behaviour of HTML and CSS tags and selectors</strong></h4><figure><img alt="The DOM tree — courtesy FreeCodeCamp" src="https://cdn-images-1.medium.com/max/558/1*VWqydoUVnzVfxhCNp1HQgw.png" /><figcaption>Courtesy: FreeCodeCamp</figcaption></figure><p>JavaScript can target each HTML tag and CSS selector. It can target these tags and selectors because browsers read HTML and CSS and converts these files into a Document Object Model (DOM).</p><p>The DOM, is like a tree is representing every branch of the HTML document and its CSS styling. This DOM-tree is stored in memory or the cache of the computer.</p><p>This illustration from <a href="https://www.freecodecamp.org/">FreeCodeCamp</a> shows how the tree cascades from the head (and the meta-data in the boiler plate) to the body and all the elements within the body tags.</p><p>JavaScript accesses these elements and uses functions — or blocks of code, a set of rules or instructions — to change the behaviour of these elements.</p><p>Go to the <a href="https://codepen.io/sumisastri/pen/zyzPZm">Traffic Light Pen</a> to this function written on Line 15.</p><figure><img alt="Illustration of how code is run in the DOM" src="https://cdn-images-1.medium.com/max/604/1*Vdct--DEUemF91nN-WG2lA.png" /></figure><p>The function called <strong>illuminateGreen(){}</strong> returns two instructions. To clear the lights and to go to the HTML DOM-tree, find the element with the id of “<em>goLight</em>”, access the style attribute, specifically to access the background colour and change it to green.</p><p>The function or set of instructions written here is called declaring the function. Or outlining the set of instructions that you expect the function to perform.</p><p>To make the function work, the function must be called or invoked to get executed — or do what it has declared it will do.</p><p>Go to Line 3, here we are selecting from the DOM-tree the HTML button element by its id. When the user clicks the button, the function is executed, or runs, or is invoked.</p><p><strong>document.getElementById(“goButton”).onclick = illuminateGreen;</strong></p><p>Now look at all the functions written or declared and see where they are invoked. Understand the DOM-tree and the elements that are being selected by JavaScript.</p><p>See if you can figure out what the <strong>clearLights(){}</strong> function’s set of instructions are. See where it is executed, called or run.</p><p>You will be right if you say the function is called within the other functions to illuminate the traffic light!</p><h4><strong>How JavaScript stores different types of data</strong></h4><p>JavaScript stores and changes data with the simple power of functions.</p><p><em>Primitive data or scalar values are:</em></p><ul><li><em>Strings</em> (words and letters), which are recognised by the browser parsers when single or double quotes are used “this is a string of words”, ‘this is also a string of words’. Use either but stay consistent within your code base.</li><li><em>Cardinal numbers </em>(a special characteristic of JavaScript is numerals that are written out as strings are also recognised as numbers). Ordinal numbers (1st/ 2nd/ 3rd) are treated as strings as are Roman numerals (I, II, III).</li><li>Booleans —( true/false statements)</li></ul><p><em>Complex data types are:</em></p><figure><img alt="JavaScript complex data-types — Arrays" src="https://cdn-images-1.medium.com/max/500/1*FUg-jWvug_weAq0DEoE28A.png" /></figure><p><em>Arrays</em> which are recognised by parsers with the square brackets <strong>[] </strong>they are zero-indexed set of elements, separated by commas.</p><p>A zero-index means that the first element is 0 not 1.</p><p>We will be using arrays to store our images in our carousel slider. So look out for them. They can store strings, numbers and booleans. Images are stored as strings. Strange, but true.</p><ul><li><em>Objects</em> which are recognised by parsers with the curly braces<strong> {}</strong>.</li></ul><p>They are an unordered list of key-value pairs.</p><p><strong>{name:’Joe’, age: 5, adult: False, favouriteFood: [‘peas’, ‘beans’, ‘eggs’], {parent: ‘Mr Blog’, phone: 123456}}</strong></p><p>Each key is separated from its value by a colon. The value can be any data type — strings, booleans, numbers and even arrays. While an object can contain an array, an array can not contain an object. An object can even contain another object, making it a very flexible data type.</p><p>Each key-value pair is separated by commas. The last key-value pair — in this case another object — does not have a comma after it.</p><h4><strong>JavaScript in action with a simple image slide show</strong></h4><p>Now go back to <a href="https://codepen.io/sumisastri/pen/oNBadVp">the Portfolio pen</a> and look at the JavaScript.</p><p>I have used a YouTube tutorial by <a href="https://www.youtube.com/watch?v=4YQ4svkETS0">Brad Traversy</a> for this section.</p><figure><img alt="JavaScript image carousel with a 2-column layout" src="https://cdn-images-1.medium.com/max/1024/1*sO2Ajr75bb1SItoRV98ppw.png" /></figure><p>If you want to follow and code along with Brad, I would encourage you to try it. The code has been written in ES6 updates — note how a function now is assigned to a variable to store the <strong>const changeImg = () =&gt; {}.</strong></p><p>The keyword “function” has been dropped and the arrow is used to return the function’s arguments— which are to check the number of elements (in this case the images) in the array.</p><p>A conditional statement runs the code. A conditional statement is a JavaScript design pattern that runs code in this order:</p><figure><img alt="JavaScript conditional statement" src="https://cdn-images-1.medium.com/max/432/1*u1mVNTfS7mCEqXA4glnzPQ.png" /></figure><p><strong>if (some condition is met){do this</strong></p><p><strong>} else{</strong></p><p><strong>do this</strong></p><p><strong>}</strong></p><p>Our code says, check the length of the array by counting the number of elements by their index number.<strong> If </strong>there are elements in the array (the element count stops at <strong><em>-1</em></strong> , indicating the end of the number of elements in the array) do this — add the next element to the index of elements symbolised with the double plus mark<strong> ++</strong>(<em>add 1 more image in this case</em>). <strong>Else</strong> go back to <strong><em>0</em></strong>, the index of the first image.</p><p>The index in an array is notated square brackets or [index] as in the code in <a href="https://codepen.io/sumisastri/pen/oNBadVp">the Portfolio pen</a>. It is often notated with just an i, like so<strong> <em>[i] </em></strong>as you will see in the the <a href="https://www.w3schools.com/js/js_if_else.asp">documentation</a> from W3 schools or <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator">Mozilla</a>.</p><p>The images change every 2000 milliseconds or two seconds, you can speed up the change or slow it down and see how you want the slide-show to function.</p><p>If you are happy with your portfolio site and want to host it on a URL (unique resource locator) <em>Part 5 of Learning to Code</em> concludes this series with instructions of how to deploy your project with<a href="https://www.netlify.com/"> Netifly</a> -&gt; <a href="https://sumisastri.medium.com/learning-to-code-part-5-of-5-85a61f418a93">next</a></p><p><strong>&lt;- Previous</strong></p><p><a href="https://medium.com/@sumisastri/learning-to-code-part-1-of-5-a117f2c0811c">Part 1 — So you want to learn to Code</a></p><p><a href="https://sumisastri.medium.com/learning-to-code-part-2-of-5-f7e93ca529ac">Part 2 What is a “real” coding language?</a></p><p><a href="https://sumisastri.medium.com/learning-to-code-part-3-of-5-7c3827c2981a">Part 3 Have fun learning to code HTML, CSS &amp; JavaScript with three “pens”</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38f7e39d5c83" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cancer-research-uk-tech-team-blog/learning-to-code-part-4-of-5-38f7e39d5c83">Learning to Code Part 4 of 5</a> was originally published in <a href="https://medium.com/cancer-research-uk-tech-team-blog">Cancer Research UK Tech Team Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning to Code Part 3 of 5]]></title>
            <link>https://medium.com/cancer-research-uk-tech-team-blog/learning-to-code-part-3-of-5-7c3827c2981a?source=rss-79bb57ae3dc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c3827c2981a</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <dc:creator><![CDATA[Sumi Sastri]]></dc:creator>
            <pubDate>Mon, 26 Apr 2021 15:11:13 GMT</pubDate>
            <atom:updated>2024-08-08T12:49:54.672Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Learning to Code Part 3 of 5 — </strong>Have fun learning to code HTML, CSS &amp; JavaScript with three “pens”</h3><figure><img alt="A screenshot of HTML code" src="https://cdn-images-1.medium.com/max/640/1*Q0P0esb8mO6Ows3Wtdqi9g.png" /><figcaption>Credit: Pixabay</figcaption></figure><p>In this article, you will need to sign-up to <a href="https://codepen.io/">CodePen</a>, an open source sand-box.</p><p>An updated version of this article in 2024 is<a href="https://sumisastri.github.io/dev-blogs/"> on my tech blog posts</a>.</p><p>You can create your own pens by copying the code and playing with it. Don’t worry if you break your code — it’s part of the process of learning. Just go back and copy my pen and start again!</p><h4><strong>The super-fast HTML crash course pen</strong></h4><figure><img alt="A screenshot of the HTML super-fast crash course pen" src="https://cdn-images-1.medium.com/max/1024/1*L-v9aiwtjadz0ioDQXbNzQ.png" /></figure><p>I demo the basics of how HTML (hyper-text-mark-up language) code runs on<em> </em><a href="https://codepen.io/sumisastri/pen/yLgRpZN"><em>this link </em></a>or as CodePen terms it a pen.</p><p>As a brief guide to understanding this pen, HTML was designed in 1990 to share documents over the world wide web. The current version in use is HTML5 with several enhancements to the original text-mark-up language.</p><p>As it is a programming language, identifying HTML on a browser starts with meta-tags, or data invisible to the reader but read by a browser that is enclosed in <strong>&lt;&gt; &lt;/&gt;</strong> known as opening and closing tags.</p><figure><img alt="Boiler plate of an HTML document — machine readable code" src="https://cdn-images-1.medium.com/max/569/1*ceZWpI-j8ATTbDaQYW4nNQ.png" /></figure><p>Every HTML page, or document, starts with a boiler plate.</p><p>To create your own HTML pen in CodePen, copy and paste the boiler plate from the pen link.</p><p>Look at the tags between the <strong>&lt;body&gt;&lt;/body&gt;</strong> tags to see how front-end-code works.</p><p>Experiment with the views on CodePen to toggle between the code and how it looks to a user. If you have not read<em> </em><a href="https://sumisastri.medium.com/learning-to-code-part-2-of-5-f7e93ca529ac"><em>Part 2 of Learning to Code</em></a>, I briefly outline the difference between learning to code for front-end web and mobile applications is vs. learning to code for the back-end of an app.</p><p>This boiler plate that you copy into your workspace, or pen, is parsed — or read — by the web browsers. If the syntax is wrong and you miss an opening or closing tag, the program breaks and will not run. Each browser has its own JavaScript engine that parses HTML, CSS and JavaScript in a different way.</p><p>The reason why computer code is written according to strict rules (the syntax of the code) or protocols is to ensure that there is a uniform, consistent way of writing code that can be read or parsed by different browsers.</p><p>This is the right moment to talk about clean code. Clean code is important as a browser will parse<em> id</em>, <em>iD</em>, <em>ID </em>differently as computer languages are case-sensitive.</p><p>Typos will make the difference between code working or breaking. So ensure your code is clean and consistent when you are working in your pen.</p><p>There are thousands of HTML tags — the key ones are six h-tags for headings. Search engines will rank a <em>h1 </em>tag the highest in terms of importance and<em> h6</em> the lowest. The semantic tags like <strong><em>&lt;body&gt;&lt;/body&gt; &lt;header&gt;&lt;/header&gt; &lt;section&gt;&lt;/section&gt;&lt;article&gt;&lt;/article&gt; &lt;aside&gt;&lt;aside&gt; &lt;footer&gt;&lt;/footer&gt; </em></strong>are self-explanatory.</p><p>Always check the <a href="https://www.w3schools.com/html/">documentation</a> from W3 schools. I have used different HTML tags for forms and the W3 tutorial was one of the first that I did before I made the decision to go to bootcamp.</p><p>Work on the examples in CodePen and repeat the same examples many times to feel comfortable with HTML as a language and its syntax.</p><p>Don’t forget to have fun and play in the playpen :-)</p><p>Experiment with the chevrons — format HTML, analyse HTML, full page view, edit view. The analyse option helps you check mistakes in your code and correct them with helpful hints.</p><p>Try and make your own HTML pens that are different from the pen you have copied. Experiment with the inline styling tags and then move on to Pen 2 to get a better understanding of how to style with CSS.</p><h4><strong>The CSS Bouncing Balls pen</strong></h4><figure><img alt="A CSS Bouncing Balls Animation project" src="https://cdn-images-1.medium.com/max/712/1*6z6h9uS1kWv0SNCziiwUSw.png" /></figure><p>Here is a project you can truly make your own. Go to<a href="https://codepen.io/sumisastri/full/zYNmWoy"> this pen</a> copy the HTML and CSS (Cascading Style Sheets) to your own work space and change the shape, sizes and animations in the CSS section. Like HTML, CSS has evolved and the current version is CSS3.</p><p>In the HTML pen, you will see the tags used have attributes. Attributes within tags can be used for in-line styling.</p><p><strong>&lt;section style=”background-color:blanchedalmond;”&gt;</strong></p><p>However, this is not best practice. Ideally CSS should be held in a separate file.</p><p>CSS files have a file extension <em>.css</em> just like an HTML page has a file extension <em>.html</em> or a word doc has a file extension<em> .doc</em> to identify the file type.</p><p>In the boiler plate HTML note that the HTML file is linked to the CSS file in the pen <strong>&lt;link rel=”stylesheet” href=”index.css”&gt; </strong>The same background colour attribute now can be coded in CSS.</p><p>CSS is a language that sets rules for the style of an HTML element. Should the heading be bold, what font-size, should the text be aligned to the centre, what should the line-height be. All of these are defined by a set of rules.</p><p>A selector selects the property and gives it a value</p><p><strong>body {</strong></p><p><strong>background-color: green;</strong></p><p><strong>}</strong></p><p>The property selected is the body HTML attribute, and the background colour is green. The syntax is the selector, opening and closing curly-braces, the property is the <em>background-color (note in American spelling) </em>followed by a colon, the code stops when it encounters the semi-colon and closing braces.</p><p>Once again, clean-code and being mindful of the small syntax errors that you make can result in coding running or you having to go back and fix the typo in the syntax.</p><p>It happens all the time, to experienced coders as well so don’t feel bad about it! In the early stages of coding, it is so easy to blame yourself and feel bad. Stay calm — as they say — and keep coding :-).</p><p>In the pen, see how we use a linear gradient and a background image.</p><p>Use <a href="https://www.eggradients.com/linear-gradients">this site</a> to change the background to your pen using the linear gradient effect. There are 300 to choose from and you can add to the six bouncing balls more divs with your own design of how the balls bounce and your own animation.</p><p>Experiment with the shape and size of the six class selector attributes in HTML. Change the class selector to an id selector and experiment with this too.</p><p>Read more <a href="https://developer.mozilla.org/en-US/docs/Learn/CSS">documentation </a>referring to Mozilla’s HTML, CSS and JavaScript sections. Use W3 Schools as well, get to understand what you are doing and why.</p><h3><strong>The Traffic Light Pen</strong></h3><figure><img alt="A traffic light project in HTML CSS &amp; JavaScript" src="https://cdn-images-1.medium.com/max/1024/1*s0C8PZti7pYKkq9pkJ6S1w.png" /></figure><p>To boost your confidence, this small exercise is to help you understand the power of JavaScript animation compared with CSS.</p><p>JavaScript allows you to interact with every single element of HTML. Like CSS you can access each HTML tag and make it do stuff.</p><p><a href="https://codepen.io/sumisastri/full/zyzPZm">This pen</a> is the next step. So check you are comfortable with HTML and CSS first.</p><p>In the HTML section, note we have not imported the JavaScript file in the meta-tags in the boiler plate.</p><p>In the body-tag we now have more semantic tags. We are also using <em>id</em> attributes not <em>class</em> attributes in the HTML elements meta-data.</p><p>In the CSS we are using more selectors, properties and values. We are experimenting with more linear gradients.</p><p>Do the same with when you copy the files to your project. Have fun and get familiar with the new CSS and HTML introduced in the project.</p><p>Now go to the JavaScript file. See how we can select from the document, by selecting the <em>id</em> in the attribute tag, we change the CSS from black to red.</p><p>Note that this change is triggered by the<em> onClick</em> of the button — an action that is referred to as an “event” in JavaScript.</p><p>Note that the JavaScript files are imported just above the <strong>&lt;/body&gt; </strong>closing tag and not in the meta-data in the HTML boiler plate.</p><p>Don’t worry too much about how this works, have fun and read the next section if you want to delve into some of the fundamental concepts of JavaScript.</p><p>To recap, in case you have missed the first two in the series here are the links:</p><p>In <a href="https://medium.com/@sumisastri/learning-to-code-part-1-of-5-a117f2c0811c"><strong>Part 1 — So you want to learn to Code</strong></a><strong> </strong><em>we explore what motivates you and how to go about learning to code.</em></p><p>In <a href="https://medium.com/p/f7e93ca529ac/edit"><strong>Part 2 What is a “real” coding language?</strong></a> <em>we explore what code is and isn’t and what are the “real” coding languages.</em></p><p>In <em>Part 4 of Learning to Code</em>, we will continue to use CodePen and you will get a free pre-written template of a portfolio or website template that you can adapt, change and reuse many times over! -&gt; n<a href="https://sumisastri.medium.com/learning-to-code-part-4-of-5-38f7e39d5c83">ext</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c3827c2981a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cancer-research-uk-tech-team-blog/learning-to-code-part-3-of-5-7c3827c2981a">Learning to Code Part 3 of 5</a> was originally published in <a href="https://medium.com/cancer-research-uk-tech-team-blog">Cancer Research UK Tech Team Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning to Code Part 2 of 5]]></title>
            <link>https://medium.com/cancer-research-uk-tech-team-blog/learning-to-code-part-2-of-5-f7e93ca529ac?source=rss-79bb57ae3dc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7e93ca529ac</guid>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Sumi Sastri]]></dc:creator>
            <pubDate>Mon, 26 Apr 2021 14:28:41 GMT</pubDate>
            <atom:updated>2024-08-08T12:47:48.863Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Learning to Code Part 2 of 5 -What is a “real” coding language?</strong></h3><figure><img alt="Coffee cup with message Talk Code to Me" src="https://cdn-images-1.medium.com/max/640/1*_o63BpH9yYqjjNvepnwSEQ.png" /><figcaption>Jan Alexander for Pixabay</figcaption></figure><p>In this article we explore what code is and isn’t and what are the “real” coding languages you should learn when you are starting from ground zero.</p><p>This article has been update in 2024 in <a href="https://sumisastri.github.io/dev-blogs/">my personal blogs posts</a>.</p><p>There is a view that HTML (hyper-text-mark-up language) &amp; CSS (cascading style sheets) are not “real” computer languages. They are text and styling mark-up. However, they are computer coding languages — just with simpler and more easy to understand rules.</p><p>Computer code is the set of rules — the syntax — of a particular computer language.</p><p>Most computer languages are designed by programmers as a set of rules that are easy to learn and interpret for humans.</p><p>You do not need to know advanced maths, be a “techie” or a “geek” to learn coding. Follow the rules, the syntax of a language or the protocol as the rules are strict but fairly simple especially with HTML and CSS.</p><h4><strong>Which language should I learn if I want to code?</strong></h4><p>Languages wax and wane in favour. The most popular languages are not the same as the most adopted languages on the web.</p><p>If you missed Part 1 in the series, now may be a good time to go back.</p><p>In <a href="https://medium.com/@sumisastri/learning-to-code-part-1-of-5-a117f2c0811c"><strong>Part 1 So you want to Learn to Code</strong></a> <em>we explore what motivates you and how to go about learning to code.</em></p><p>While JavaScript — often abbreviated to JS — is the most popular front-end language, PHP is the still the most used. PHP, originally an acronym for Personal Home Pages, is another scripting language. <a href="https://en-gb.wordpress.org/">WordPress</a> is built on<em> PHP,</em> and initially, so was Facebook!</p><p>JavaScript libraries have replaced vanilla JS. These are<em> j-Query</em>, once again not popular but often used and <em>React.js</em> popular but may not be with the same market share. React was designed by Facebook as a front-end library to improve performance of its user interface which was initially generated using PHP.</p><p>The fundamentals still start with three building block languages that you must learn to code are:-</p><ul><li><strong>HTML</strong></li><li><strong>CSS</strong></li><li><strong>JavaScript</strong></li></ul><p>They form 97% of the code for all apps written on web.</p><p>JavaScript is the entry-point to understanding other JavaScript libraries such as <em>React.js</em>, <em>Vue.js</em> and JavaScript frame-works such as <em>Angular.js</em>. The <em>.js</em> file-extension is often dropped and are referred to as <em>React</em>, <em>Vue</em> and <em>Angular</em>.</p><p>Should you learn<em> PHP</em>? PHP is a server-side HTML pre-processor. What this means is you can inject PHP code into HTML. JavaScript, on the other hand, can be written in the browser as well as in a back-end application.</p><p>The popularity of JavaScript has grown in leaps and bounds over the last decade making it more popular as a language for beginners to learn. However, PHP is still a force to reckon with and its market share is significant. Many boot camps do not offer PHP on the curriculum.</p><p>If you wish to learn PHP you may have to go down the self-taught route with online tutorials like <a href="https://www.w3schools.com/php/">W3 schools </a>and several other resources easily available on the web. Have a browse through the PHP <a href="https://www.php.net/docs.php">documentation</a> and if you want to know why people love to hate PHP, here is a good <a href="https://dev.to/jjsantos/why-some-people-hate-php--55dn">forum</a> to checkout several opinions on the topic.</p><p>To be honest, it is one of the languages I would like to learn — just not immediately as I would like to be confident with the languages I know before taking on a whole new challenge.</p><p>What about <em>Ruby</em>? Some boot camps still offer <em>Ruby</em> and <em>Ruby-on-Rails</em> (the back-end framework for front-end <em>Ruby</em>) but many start-ups find <em>Ruby</em> does not scale well and are migrating out of a <em>Ruby</em>-based stack. There still are a number of jobs where <em>Ruby</em> developers are in demand to maintain existing legacy stacks.</p><p>A tech-stack, or stack, is a configuration of languages that a developer/organisation uses to build web or mobile apps.</p><p>It is worth remembering that while JavaScript is incredibly popular as a language to learn today, when JavaScript was introduced as a programming language for web-browsers in the 1990s, it failed to gain popularity.</p><p>Similarly <em>Ruby</em> was extremely popular in the early 2000s but has fallen out of favour as <em>React</em> and <em>Vue</em> have replaced front-end code initially written in <em>Ruby</em> and back-end code with other languages, frameworks or libraries.</p><h4><strong>Is learning to code a front-end language better?</strong></h4><p>The front-end languages refer to code that writes the front-end of a web or mobile application. The visible part of the app to a user.</p><p>However, the back-end of an application where the data is stored and retrieved for use on the front-end is equally important.</p><p>Learning to code both for the back-end and front-end is more valuable as it enhances your understanding of a code-base.</p><h4><strong>What back-end languages should you learn?</strong></h4><p>Once again, what you can learn in boot camp is limited by what is taught in the curriculum.</p><p><em>Java</em>, a language that is most useful for back-end development is not taught at boot camp.</p><p>It is no relation to JavaScript, except that when<em> </em><a href="https://en.wikipedia.org/wiki/Brendan_Eich"><em>Brenden Eich</em>,</a> who designed JavaScript code as a browser-based scripting language for Netscape. It was called Mocha, LiveScript and then JavaScript only to tag its name to the popular language of the day, which was Java.</p><p><em>C, C++, C Sharp</em> are other back-end languages that are not taught at boot camp.</p><p><em>PHP and Ruby-on-Rails</em> once again are not taught at all boot camps.</p><p>Which of course does not mean you should not learn these languages. It means they are harder to access in short-courses by accredited boot camps.</p><p><em>Python</em> — a scripting, back-end language used for Data Science is taught and is swiftly gaining popularity.</p><p>JavaScript for back-end frameworks is what most boot camps teach —<em> Node.js</em> or <em>Node </em>is an environment where JavaScript works outside the browser and therefore in the backend.</p><h4><strong>What about learning to code for data-bases?</strong></h4><p>Boot camps do run through both relational-databases and non-relational databases.</p><p><em>SQL, MySQL and PostGreSQL</em> are search query languages (SQL) that are used in relational databases. With <em>PostGreSQL</em> being an open source database it is the most easily accessible form of SQL to learn.</p><p>Non-relational databases are also referred to as document-based databases.</p><p><em>MongoDB</em> and<em> DynamoDB</em> are two such databases. <em>MongoDB</em> is JavaScript-based and once again the most easily accessible if you learn JavaScript.</p><h4><strong>Isn’t this a spaghetti tangle of code to learn?</strong></h4><figure><img alt="Spaghetti" src="https://cdn-images-1.medium.com/max/365/1*uvj7kAxmWHBbWT-dgNry_Q.png" /><figcaption>Credit: Pixabay</figcaption></figure><p>Yes and no. Learning HTML, CSS and JavaScript — especially JavaScript will take you a long way.</p><p>Learning one back-end language like <em>Node</em>, and one JavaScript-based database, like <em>MongoDB</em>, will help you quickly spin up small projects for your portfolio.</p><p>If you do not want to go the boot camp route and are comfortable with online learning there are many free training videos on YouTube and <a href="https://www.freecodecamp.org/">FreeCodeCamp</a> . <a href="https://www.w3schools.com/">W3Schools </a>and <a href="https://developer.mozilla.org/en-US/docs/Learn/CSS">Mozilla</a> have their own free online tutorials and accreditations.</p><p>For a small fee there are other resources like <a href="https://www.udemy.com/">Udemy</a>, <a href="https://stackskills.com/">StackSkills</a> and on a subscription basis <a href="https://www.udacity.com/">Udacity</a> and<a href="https://www.linkedin.com/learning/"> Linked-in Learning</a>.</p><p>This is not a comprehensive list but should be enough to get you started.</p><h4><strong>Learn to code the MERN-stack</strong></h4><p>I found that learning the MERN stack —<em> MongoDB</em>, <em>Express.js</em> (or <em>Express</em>) as a server, <em>React</em> and <em>Node</em> — was the easiest way to practice the fundamentals of vanilla JavaScript through the stack.</p><p>It is a stable stack that does not need a cloud architect to configure if you are building side-projects for a portfolio.</p><p>It helps you stay focused to gaining mastery with one language — JavaScript and applying this knowledge through the stack.</p><p>Most of my portfolio is based on the MERN-stack. It’s what helped me in the 18-months after I left boot camp to keep my focus narrow but deep rather than cast my net wide and lose focus.</p><h4><strong>What about learning to code the JAM stack?</strong></h4><p>Even better! JAM refers to JavaScript, APIs and Markup (HTML &amp; CSS). APIs are application protocol interfaces, or a way of getting data from the back-end to the front-end.</p><p>This is Pure JavaScript, HTML and CSS without a server. It is great as a starter for anyone who is looking to build a small project on their with only front-end languages.<a href="https://www.netlify.com/"> Netifly</a> helps you deploy and host this stack in a matter of seconds.</p><p>You don’t need boot camp for this if you are in the research phase and want to dabble.</p><p>If you want to build a JAM-stack app hang-on for Part 3,4 and 5 of<em> Learning to Code</em>, where I will help you build micro-projects.</p><p>It’s a risk free and cost-free way of checking whether coding is for you or not. Or to understand the basic principles of coding with the building block languages HTML, JavaScript and CSS.</p><p>In Part 3 of<em> Learning to Code</em>, I will run through three pens or links from CodePen, a free sandbox that allows you to play with code and see how it works.</p><p><a href="https://codepen.io/sumisastri/pen/yLgRpZN"><em>The super-fast HTML crash course pen</em></a> is adapted from W3Schools tutorials.</p><p><a href="https://codepen.io/sumisastri/full/zYNmWoy"><em>The CSS Bouncing Balls pen</em></a> adds CSS styling and animation. You can copy this pen and change the shape of the coloured balls and the animation and make this project your own.</p><p><a href="https://codepen.io/sumisastri/full/zyzPZm"><em>The Traffic Light pen</em></a> demos the power of JavaScript and the magic it works with a click of a button!</p><p>Get to write your first code <em>Learning to Code Part 3</em>-&gt; <a href="https://sumisastri.medium.com/learning-to-code-part-3-of-5-7c3827c2981a">next</a></p><p>&lt;- Previous <a href="https://medium.com/@sumisastri/learning-to-code-part-1-of-5-a117f2c0811c">Part 1 So you want to Learn to Code</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7e93ca529ac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cancer-research-uk-tech-team-blog/learning-to-code-part-2-of-5-f7e93ca529ac">Learning to Code Part 2 of 5</a> was originally published in <a href="https://medium.com/cancer-research-uk-tech-team-blog">Cancer Research UK Tech Team Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning to Code Part 1 of 5]]></title>
            <link>https://medium.com/cancer-research-uk-tech-team-blog/learning-to-code-part-1-of-5-a117f2c0811c?source=rss-79bb57ae3dc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/a117f2c0811c</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <dc:creator><![CDATA[Sumi Sastri]]></dc:creator>
            <pubDate>Sun, 25 Apr 2021 14:43:02 GMT</pubDate>
            <atom:updated>2024-08-08T12:46:11.956Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This is a jargon-free, plain English series, written to inspire people who are considering learning to code.</em></p><p><em>It will also help non-coders, who work with coders, understand what the process is to get a feature built, into production, deployed and released on a web or mobile application.</em></p><h4><strong>So you want to learn to code?</strong></h4><figure><img alt="JavaScript and how it connects to various devices" src="https://cdn-images-1.medium.com/max/1024/1*BPSx-c--z6r7tY29L19ukQ.png" /><figcaption>Learning to code easier than you think it is</figcaption></figure><p>In this article we explore if you really do want to learn to code: what motivates you and how to go about fulfilling your goal.</p><p>This article has been updated in 2024 on <a href="https://sumisastri.github.io/dev-blogs/">my tech blogs posts</a>.</p><p>Wanting to become a developer and learning to code is a decision. It was a process that, for me, took about 18-months. During this time there were key questions I asked myself.</p><ul><li>Why do I want to become a developer?</li><li>Do I need to have a computer science degree or software engineering degree to learning coding?</li><li>How long will it take me to learn the skills required?</li><li>Will I enjoy it?</li><li>Can I make a living out of it — will I actually be employable?</li></ul><p>After two years, since I retrained at boot camp, the last question is a — yes, but… the full answer is further down the page :-)</p><h4><strong>Why do you want to become a developer?</strong></h4><figure><img alt="Image of a girl reading" src="https://cdn-images-1.medium.com/max/320/1*7SGK3cRi856YpEBRrZIIOg.png" /><figcaption>Credit: Pixabay</figcaption></figure><p>Everyone’s path is different. You need to answer this fundamental question so that you get the best answer that works for you. I started by reading articles like these by other people who had gone through the same decision making process.</p><p>My path was I love gadgets, technology and people — and not necessarily in that order. It started with people — many of my friends were developers.</p><p>I was variously a content-writer/ marketing professional/ product-owner and scrum master. My developer friends seemed to have a supportive community, interests out of the work place, a good sense of humour and minds full of questions.</p><p>As a marketeer I did know some basic HTML (hyper-text-mark up-language) and some vanilla CSS (Cascading Style Sheets). So email-marketing templates and the early development work gave me a basic idea of what HTML did — creates text blocks — and CSS — adds styling on the page.</p><p>It was only when I was responsible for driving digital transformation as a product owner, that I actually was asked by my dev friends to write some of the CSS in the files to speed up the work.</p><p>This happened occasionally when people were off sick, or devs more interested in “real” programming languages. It got me thinking and asking questions like so what’s a “real” programming language?</p><h4><strong>Do you need a computer science or software engineering degree ?</strong></h4><p>I was fortunate to work in technology for ten years and talk to a lot of developers.</p><p>I began to notice a pattern, there were the engineers and the CS (computer Science) guys. But there were a lot of devs that were neither. One was a waiter before he became a programmer. Another was in an advertising agency and retrained. Yet another deciding that he would never become a professional drummer — though he liked to jam on weekends — taught himself with various online video courses.</p><p>It got me thinking.</p><h4><strong>How long does it take learning to code?</strong></h4><p>The answer is three months at boot camp or forever as learning never stops. You have to keep training to keep on top of your game.</p><p>I researched and read as much as I could online.</p><p>I gathered a checklist of links from casual learning to on-line University degrees from my dev friends.</p><p>I sampled and tried JavaScript, the language I was told was the best entry level ‘real’ programming language that would help me on my journey to learn to code.</p><p>I researched companies and the programming languages they were using and found, indeed, JavaScript seemed to be a popular language.</p><p>I set up accounts with<a href="https://stackoverflow.com/"> <em>Stack Overflow</em></a>, <a href="https://stackskills.com/"><em>StackSkills</em></a>,<em> </em><a href="https://www.udemy.com/"><em>Udemy</em></a>,<a href="https://www.linkedin.com/learning/"> <em>Linked-in Learning</em></a>, <a href="https://github.com/"><em>GitHub</em></a> as recommended by the devs (never used any of them till boot camp and after!)</p><p>After 3–4 months I realised learning to code online was not for me.</p><p>I like the environment of a campus and any form of learning with other people.</p><p>The next 3–4 months, in that 6–8 month research period, I asked all the non-engineers, non-computer science graduates what courses they did and got a list of London-based boot camps.</p><p>Most accredited boot camps are three to four months.</p><p>While the fees are between £12,000 and £15,000 (at the time I did the course 2019), you have to save to pay for your rent, transport, living expenses possibly another £15,000 in London (£2,000 and £3,000) for 4 to 6 months as you are unlikely to get a job immediately. I graduated in April-May and was the first in my cohort to get a job which started in July. January to July was a 6-month period and I felt seriously broke at the end of it!</p><p>I sent applications to three accredited boot camps and did all their free-workshops knowing the high cost of making the last and final decision.</p><p>The free workshops are long sales pitches. Every boot camp promises you will get a job at the end of it.</p><p>For anyone who has rose-tinted glasses and thinks this is easy, TechCrunch has a great article I would advise you to read on <a href="https://techcrunch.com/2016/05/10/please-dont-learn-to-code/?guccounter=1&amp;guce_referrer=aHR0cHM6Ly9kdWNrZHVja2dvLmNvbS8&amp;guce_referrer_sig=AQAAALsw3_pchq0NjOi9k6kGJQy9dZBSI1xnhmbAcANlC0YhcpJjKeLzFndwPkn9qasFL9IrmK0ukYh5ZvB0DtplWb0brNtd-c4UAb8PmFbbjrEXVPYOoZCj25OfLEaqTE6ZCd9muyuqC0RpNJZGEkOHYka3fYq23NMtL98Pg7Nj7Ow7">this link.</a></p><p>I wanted to know from my dev friends who were non-engineers and non-computer science degree holders whether I would be able to pay back my fees in a period of 12-months if I got a job. The answer was always yes, depending on if you get a job.</p><p>For me, it was always a question of finding out — albeit an expensive, high-risk route — whether I would enjoy coding.</p><h4><strong>Will you enjoy learning to code?</strong></h4><p>For me the answer was a resounding yes. I came away from boot camp learning more that I thought that I would. We rapidly raced through the fundamentals of some “real” programming languages</p><ul><li>JavaScript — a front-to-back end language</li><li>Python — a scripting back-end language</li><li>PostgreSQL — a relational database</li><li>React.js — a front-end JavaScript component Library</li><li>Node.js — a JavaScript back-end framework</li><li>MongoDB — a document-based database</li></ul><h4><strong>Can you make a living after you have learnt to code?</strong></h4><p>At the end of three months I understood the general concepts of coding. I was fairly terrified. I did not feel confident that what I knew was enough to get a “real” job.</p><p>The key things that everyone recommends bootcamp grads are:-</p><ul><li>Make a portfolio site</li><li>Keep an active GitHub account of your work</li><li>Do coding challenges at least once a day after bootcamp</li><li>Attend workshops, networking milk-rounds</li><li>Keep a copy of your CV and hustle</li></ul><p>I started looking for non-paying internships and mentors.</p><p>I lucked out. The first potential mentor I connected with via Linked-in was looking for interns.</p><p>I did a white-board pair-coding test and I even got paid!</p><p>It was the best three-months of my life after boot camp.</p><p>To learn more about learning to code “real” languages read Part 2 in the series <em>Learning to Code</em> -&gt; <a href="https://sumisastri.medium.com/learning-to-code-part-2-of-5-f7e93ca529ac">next</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a117f2c0811c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cancer-research-uk-tech-team-blog/learning-to-code-part-1-of-5-a117f2c0811c">Learning to Code Part 1 of 5</a> was originally published in <a href="https://medium.com/cancer-research-uk-tech-team-blog">Cancer Research UK Tech Team Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>