Author: Valerie Lynn

  • URL Shortener AI-Generated RoadMap

    For sometime, I’ve wanted to write a URL Shortener. I need a little help getting started and I think ChatGPT can provide the direction I need.

    Because I also want to keep a Coding Journal, I should probably take a stab at solving my problem first before I ask ChatGPT or Bard to lay out a roadmap for me. I believe stating, in plain language, what I will want a script to do will help me understand the discrete steps that need to be taken.

    I will then compare what I think needs to be done with what ChatGPT suggests and lookup what I don’t understand in Flavio Copes PHP Handbook – Learn PHP for Beginners on FreeCodeCamp.com.

    I want to create a URL Shortener.

    So, in plain words, what should my URL Shortener do?

    1. The script should take a URL and create a shortened version of it,
    2. storing both the original URL and the shortened version.
    3. When the short URL is used, somehow, magically, some kind of lookup must be done
    4. to figure out what the short url stands for.
    5. I would also like the script to count the number of times a url shortener has been used.
    6. I think I’ll need a text file to read and write to.

    I queried ChatGPT for a starting point. At this point, I will learn what ChatGPT’s code instructions mean by reading Flavio

    What follows below is ChatGPT‘s response to my query: what are the steps to create a url shortener in php?

    ChatGPT-Generated URL Shortener Roadmap

    Here are the general steps to create a URL shortener in PHP:

    1. Create a MySQL database to store the original and shortened URLs.
    2. Create a PHP script to generate a shortened URL based on the original URL.
    3. Write a PHP script to insert the original and shortened URLs into the MySQL database.
    4. Create a PHP script to redirect the shortened URL to the original URL.
    5. Create a web form where users can enter the original URL and get the shortened URL.

    Here’s an example of how you can implement each step:

    Step 1: Create a MySQL database to store the original and shortened URLs.

    You can use phpMyAdmin or any other database management tool to create a database. Here’s an example SQL query to create a table to store the original and shortened URLs:

    CREATE TABLE urls (
        id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
        original_url VARCHAR(255) NOT NULL,
        short_url VARCHAR(20) NOT NULL
    );

    Step 2: Create a PHP script to generate a shortened URL based on the original URL.

    Here’s an example PHP function to generate a shortened URL:

    function generateShortURL($originalURL) {
        $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        $shortURL = "";
        for ($i = 0; $i < 7; $i++) {
            $randNum = rand(0, strlen($chars)-1);
            $shortURL .= $chars[$randNum];
        }
        return $shortURL;
    }

    This function generates a random string of 7 characters that can be used as a shortened URL.

    Step 3: Write a PHP script to insert the original and shortened URLs into the MySQL database.

    Here’s an example PHP function to insert the original and shortened URLs into the MySQL database:

    function insertURL($originalURL, $shortURL) {
        $conn = mysqli_connect("localhost", "username", "password", "dbname");
        $sql = "INSERT INTO urls (original_url, short_url) VALUES ('$originalURL', '$shortURL')";
        mysqli_query($conn, $sql);
        mysqli_close($conn);
    }

    This function uses the mysqli extension to connect to the MySQL database and insert the original and shortened URLs into the urls table.

    Step 4: Create a PHP script to redirect the shortened URL to the original URL.

    Here’s an example PHP script to redirect the shortened URL to the original URL:

    $shortURL = $_GET['url'];
    $conn = mysqli_connect("localhost", "username", "password", "dbname");
    $sql = "SELECT original_url FROM urls WHERE short_url='$shortURL'";
    $result = mysqli_query($conn, $sql);
    $row = mysqli_fetch_assoc($result);
    mysqli_close($conn);
    header("Location: ".$row['original_url']);
    exit();

    This script retrieves the original URL associated with the shortened URL from the urls table and uses the header() function to redirect the user to the original URL.

    Step 5: Create a web form where users can enter the original URL and get the shortened URL.

    Here’s an example HTML form to allow users to enter a URL and get a shortened URL:

    <form action="shorten.php" method="post">
        <label for="url">Enter a URL:</label>
        <input type="text" name="url" id="url">
        <input type="submit" value="Shorten URL">
    </form>

    This form submits the original URL to a PHP script called shorten.php that generates a shortened URL and inserts the original and shortened URLs into the MySQL database. The script then displays the shortened URL to the user.


  • Toward a Working URL Shortener or, My Saga of Woe

    Maybe one day I’ll tell the story of how I got to the point of wanting to write a URL shortener but doing so right here and right now will only detract from actually getting down to writing a URL shortener in PHP. Instead, I’ll go off on a different tangent…

    Why I Haven’t Written a URL Shortener

    Most people would be happy to explain why they wrote a URL shortener. Many other people would probably want to know why anyone would bother to do something that has been done over and over again ad nauseum (think bit.ly).

    Yet ANOTHER URL Shortener?

    Instead, please allow me to tell you why I haven’t written a URL shortener, although I have wanted to for years.

    I am a Person Who Needs Her Routines

    When I was first struck by this idea, I thought I would use the Python programming language to write my dream URL shortener.

    But before I got started, I signed up for FreeCodeCamp’s Responsive Web Design course and the 100 Days of Code Challenge to brush up on my rusty late early 2000’s HTML and CSS skills (when you fly airplanes for a living, you don’t need HTML and CSS ).

    Halfway through Free Code Camp’s course, I was struck by the thought that I really needed to take that online CS50 course everyone was raving about. Surely that would put me on the path to programming greatness.

    I signed up, paid for the certification and dove in. No sooner had I started Harvard’s CS50 class when my laptop slid off my bed and onto the floor, cracking the LCD screen beyond repair. What a disaster.

    The CS50 class and the Free Code Camp course were extracurricular activities. They were something I wanted to do to get back into Web Development. The laptop meant I could learn and have fun anywhere.

    But my regular work activity depended on that laptop since I was away from my desktop most of the time.

    By the time I got another laptop and got situated again, I was trying to catch up with things that had fallen through the cracks and my routines were disrupted. CS50, Free Code Camp and 100 Days of Code fell by the wayside.

    Some people move in and out of routines easily. They appear to go with the flow when things get disrupted. For me, changes to routines feel like crises. I like plans and schedules. Knowing what I am going to do and when may seem boring, but I thrive in this space. Shifting gears unexpectedly is definitely not my preference.

    But wait, there’s more…

    Dependencies and Standards are the Bane of My Existence

    If ever you need someone to build you a house of cards, I’m your person. I create dependencies like noone else and, sometimes, those dependencies become roadblocks to doing what I want to do. It is as if I cannot move forward until that optimal dependency is in place.

    So, while I decided I would write my URL shortener in Python, somehow taking CS50 became a dependency. Fast forward three years (CS50 Course, Free Code Camp and 100 Days of Code unfinished) and I got it in my head that I needed to move my individual websites (in various states of disarray) into a WordPress MultiSite installation.

    “Okay, fine,” you say, “get on with it and set up a WP Multisite!”

    But wait! WPEngine, where I host some of my sites, does not support WordPress Multisite. So I have to find another host. Fear of the unknown sets in. So, which host is best for a multisite install?

    Now, it isn’t enough to find any ol’ MultiSite host – no, I have to find the right WordPress Multisite host. Down the rabbit hole I went and when I came back up a year had passed and still no host.

    Somehow, the dependency (find a WordPress MultiSite Host) became a standard with a mandate: find THE BEST WordPress Multisite Host and then, of course, learn all about everything before you do anything.

    Oh. My. GAWD.

    Dependencies, particularly needless dependencies waste time. I have to remember what my Dad used to say:

    When your standards are too high, lower your standards.”

    Finally, I am having issues with Focus

    Everything looks interesting. And apparently, I have a Fear of Missing Out on Learning.

    There is so much that I want to learn and do. So much that I actually start many new things but have a difficult time finishing them not because I lose interest. I don’t. I don’t finish projects because before one project is finished, I’ve started another oh-that-looks-like-fun, shiny object, interesting project.

    Over the past five years I learned enough about Eleventy to build a small website, I bought a few books and a bunch of glass and taught myself stained glass making. I took a two-part ceramics class and briefly joined a studio, learning enough to make small wedding favors for my daughter’s wedding. Along with my Husband, we gutted and remodeled our kitchen. I sold an aviation business and went to work for the new owner. We had a global pandemic. And, as if that wasn’t enough, I started a Real Estate course to become a licensed Real Estate Sales Associate in Florida.

    You know what this is called? Easily Distractiable. Too many irons in the fire! Not enough FOCUS!

    Frankly, one of the best things about flying airplanes was that my entire mind and body were engaged in that gravity-defying activity. There was no room for anything else because flying filled my head: FAA regulations, understanding weather, aircraft performance and limitations, airspace, instrument flying, weight and balance and teaching others how to fly.

    Perhaps because I am not flying much anymore, there is a void in my psyche that, in some weird way, I am trying to fill and excelling at that.

    But if I am ever going to get that URL Shortener written, I’m going to have to stop stuffing my head and to do list with tasks that don’t move me toward that goal.


  • Keeping a Programming Journal: Coding and Writing

    When I was learning to fly, and long after I earned my pilot certificates, there were occasions that demanded I process what I just learned. Writing is the best way for me to process. When I write, I can describe something I may not fully understand and hone in on its meaning or relevance by choosing my words carefully.

    When something isn’t working or when I know a procedure or behaviour is wrong (like not having a plan and landing long and fast on a short runway), it isn’t enough for me to say, “oh just don’t do that again.” No.

    I have to tease out in excruciating detail what was wrong, how it went south, what could have happened and what should have been done.

    After I’ve done so, I usually feel better. And usually because there was a lesson learned.

    Patterns and Positives

    Things don’t have to go wrong to make it into my journal though. Capturing positives like “aha” moments can refocus what seemed like a wasted effort into a more positive victory. Surely one good things happened, right?

    Things I need to know more about can be captured also. When you don’t know what you don’t know, well, write it down, describe it, give it form so you have a starting point.

    And so it will be with this Coding Journal.

    Programming is not my passion. Making stuff is my passion. 

    Pieter Levels, Maker of Nomad List

    Resources

    Programmer’s Pyramid: A work-at-your-own-pace overview of programming concepts.

    Patterns and Positives: If you can’t see a good reason to keep a coding journal but still want to another person’s opinion, Amy Haddad’s post about keeping a programming journal may help you see things differently.


  • The Birth of the Web

    By Valerie Lynn

    This article originally appeared in print in the Cypress Creek Business and Professional Women’s Newsletter in 1999. It was then published on Balamara.com and is reprinted here.


    Not a day goes by when I am not assailed with news on the latest and greatest development occuring on the World Wide Web. My mailbox – never sacred ground – passively accepts printed junk touting the newest web site of a business that I never cared for in the first place. The food I purchase from the grocery store comes packaged in advertising material listing the lucky company’s URL (Uniform Resource Locator) along with a perky request to “visit” their site. Even my television set acts as a hawker for some “cool site” that I must, without a doubt, “check out” if I am to remain up with the times. Indeed. It may appear to us that the Web sprung up out of nowhere, sunk its teeth into our wallets and refuses to go away. Only part of this is true. The World Wide Web is exists as a component of a much larger infrastructure known as the Internet. This Internet has, comparatively speaking, been a long time in the making.

    In 1957, the Russians launched Sputnik and the U.S. found itself in the unenviable position of “second place” in the race for space. Fueled by cold war concerns, President Eisenhower created the Advanced Research Projects Agency (ARPA) which was charged with improving the military’s use of computer technology. Twelve years later, the Agency produced ARPANET. ARPANET was the first Wide Area Network (WAN) and consisted of “links” between computers in California and Utah. Designed for the military, this experimental network is largely responsible for developing the technology upon which our current Internet is based. One example of this technology is TCP/IP (Transmission Control Protocol/Internet Protocol), which grew out of ARPANET.

    It should be noted that while ARPANET was developed for the U.S. Military, many of its designers and developers were from the academic community. Use of ARPANET was restricted to the Military, and its designers found themselves lacking an effective means of communication. Fifteen years after the start of ARPANET, the National Science Foundation, in conjunction with IBM, MCI and the University of Michigan, launched NSFNET. Access to NSFNET was granted to Military, Academic and Government Agencies with the sporadically enforced restriction that use be limited to educational endeavors and non-commercial research. By 1988, the NSFNET was the preferred network – the Internet had arrived. ARPANET, slow and cumbersome, hobbled along for two more years and quietly shut down.

    Commercial use of NSFNET began in 1991. It wasn’t until 1993, however, that the general public had access to the software of the World Wide Web. By this time, the Internet supported Email, as well as File Transfer (FTP). Telnet – the ability to use a remote or distant machine – was in full swing and people were “chatting” in real time using a program called Internet Relay Chat (IRC). Netnews was available, and the “Web” made its debut. The Internet, on its NSFNET “backbone” supported all of these functions which contributed to data “traffic.” In June 1993, approximately 43% of the “traffic” on the Internet was due to the transfer of files (FTP); netnews, email and telnet accounted for the second largest percentage of traffic. With only 130 Web Sites, Web traffic comprised a mere 0.5% of backbone usage. When the National Science Foundation stopped running the backbone in June, 1995, these figures were drastically different. Vying for first place in the traffic war was FTP and the Web. The transfer of files accounted for 24% of backbone traffic while the use of the Web accounted for 23%. The number of Web Sites had climbed to 23,500. Email, telnet, IRC and netnews collectively comprised the balance of the traffic figures.

    It is estimated that at least half of the Web sites on the Internet are commercial sites. The number of Internet users, approximately 40 million strong, has doubled every year for the past eight years. It is expected to double again this year. I sometimes wonder what President Eisenhower would say if he could see the spawn of ARPANET. Perhaps his only response would be, “Come visit my homepage at www.eisenhower.gov!”

    REFERENCES

    The Quintessential History of the Internet *** makes history come to life with his engaging writing style, humour and grasp of the subject matter. Be forewarned: the article is lengthy. Bookmark it – it is well worth it.

    An Internet Timeline Albeit a bit technical for the novice, Robert Zakon presents a well-organized and well-linked timeline.

    Internet Background and Basics A good, well-rounded site consisting of links to Search Engine basics and reviews, a History of the Internet, Communications Protocols, Internet Service Providers and more.

    6th Georgia Institute of Technology Graphics, Visualization and Usability Center WWW Survey Offers raw data, text summaries and graphs of Internet demographics.

    Matthew Gray of the Massachussetts Institute of Technology has compiled statistics on backbone usage over the last several years.