Chris’ Corner: Fresh SVG Drop

Category Image 052

Lemme show off some cool SVG-related things this week. Gotta love SVG. It’s this graphics language built right into the web platform that has a ton of capability and is always right there waiting for us when we need it. Thanks the web!


Portability is a cool SVG feature. You can copy and paste a bit of SVG right into HTML and that’s not only functional but actually, a pretty good way to do it. That way you can style it freely and no additional network request is made.

Ya know… that’s how our icons feature works here on CodePen.

The Assets panel on CodePen offers one-click SVG icons from Font Awesome.

And it’s a decently common way to deliver UX on a set of SVG icons generally. For example, check out Monika Michalczyk’s Shapes project, where you can just click any of them and get all the code right on your clipboard. They paste into Pens really nicely, of course.

I like how weird they all are. Nothing practical in here, just lovely interesting shapes. I bet they would morph into each other in fun ways.

Or here’s Robb Knight’s Mac 30th Anniversary Icons which are super cool minimalist representations of Macs over the last many decades.

No click-to-copy here, but the downloaded versions you can drag-and-drop into the CodePen editor if you want to play with them there.

You can learn the SVG syntax. I guess that’s kinda obvious but maybe not to everybody as SVG is often the output of tools. You can export SVG from Figma and Illustrator and stuff and you didn’t have to learn the syntax, you just use the output.

Just SVG paths alone are fairly complicated and something of a sub-syntax. I wouldn’t say I know it super duper well, but I know enough that I wrote a guide a while back.

Some of the other attributes of SVG elements are a bit more straightforward like circle essentially has a central point at an X, Y coordinate and then a radius. Sébastien Noël has a new guide on fffuel that helps understand a lot of these syntaxes:

I just love interactive code examples like this.

But leave it to yuanchuan (creator of css-doodle) to Experimenting [with] A New Syntax To Write SVG. It’s centered around the idea that the stylistic SVG attributes can be moved to a CSS-like syntax, which doesn’t just select and style SVG, but creates it.

Check out how easy it is to play with on CodePen.

OK I saved the best for last for you: Draw SVG rope using JavaScript (and it’s not just because there is an excellent CodePen demo) from Stanko Tadić. And not just rope like a line that maybe has some basic physics, but real-looking twisted rope, like the kind that might be holding a large ship to dock. The journey, which is excellently documented, involves really digging into the SVG APIs, doing interesting math, and knowing about fancy algorithms and stuff (see “Chaikin’s method” for rounding). I like it when you can tell someone is clearly captivated by an idea, gets it all figured out, then documents it so well the output and the explanation are equally interesting.

Introduction To OpenSSH

Featured Imgs 23

OpenSSH is a free and open-source suite of secure networking utilities that has become a critical tool for system administrators and developers who need to securely manage and access remote systems over unsecured networks. In this article, we will take a closer look at what OpenSSH is, how it works, and its importance in modern computing.

OpenSSH History

OpenSSH was developed in 1999 as an open-source implementation of the Secure Shell (SSH) protocol. The SSH protocol was developed as a replacement for the older Telnet protocol, which transmitted login credentials and other sensitive data in clear text over the network, making them vulnerable to interception and unauthorized access.

How do I get a button to do what it is supposed to do?

558fe5180e0e8fc922d31c23ef84d240

The button in question is supposed to calculate the cost of a car rental, from inputs for how many months, how many weeks and how many days.
This is the entire code at the moment:

import tkinter as tk
from datetime import *


# Create a tkinter window
window = tk.Tk()
window.title("Car Rental Service")
window.resizable(True, True)

# Define global variables
rental_cost = 0
rental_duration = 0

def submit_form():
    name = name_entry.get()


# Define functions
def calculate_cost():
      # Extract numeric values from label text
    rental_days_text = rental_label_days.cget('text')
    rental_days = 0
    if any(c.isdigit() for c in rental_days_text):
        rental_days = int(''.join(filter(str.isdigit, rental_days_text)))

    rental_weeks_text = rental_label_weeks.cget('text')
    rental_weeks = 0
    if any(c.isdigit() for c in rental_weeks_text):
        rental_weeks = int(''.join(filter(str.isdigit, rental_weeks_text)))

    rental_months_text = rental_label_months.cget('text')
    rental_months = 0
    if any(c.isdigit() for c in rental_months_text):
        rental_months = int(''.join(filter(str.isdigit, rental_months_text)))

    global rental_cost
    # Calculate rental cost based on duration
    if rental_days >= 1:
        rental_cost = 30 * rental_days
    elif rental_weeks >= 1:
        rental_cost = 95 * rental_weeks
    elif rental_months >= 1:
        rental_cost = 270 * rental_months

    # Add VAT to rental cost
    rental_cost = ((rental_days * 36) + (rental_weeks * 114) + (rental_months * 324)) * 1.2
    # Update the cost label
    cost_label.config(text="Total cost: " + str(round(rental_cost, 2)))

def rent_car():
    # Get customer details
    name = name_entry.get()
    dob = dob_entry.get()
    nationality = nationality_entry.get()
    licence_duration = licence_entry.get()
    # Display rental details
    rental_label.config(text="Thank you, " + name + ". You have rented a " + category_var.get() + " car for " + str(rental_duration) + " " + duration_var.get_name() + ".")
    # Disable form fields
    name_entry.config(state="disabled")
    dob_entry.config(state="disabled")
    nationality_entry.config(state="disabled")
    licence_entry.config(state="disabled")
    category_small.config(state="disabled")
    category_medium.config(state="disabled")
    category_large.config(state="disabled")
    one_day.config(state="disabled")
    one_week.config(state="disabled")
    one_month.config(state="disabled")
    # Enable the checkout button
    checkout_button.config(state="normal")

def validate_age():
    dob = dob_entry.get()
    age = calculate_age(dob)
    if age < 24:
        tk.Label(text="You must be aged 24 or over to complete this rental form.")
        submit_button.config(state="disabled")
    else:
        tk.Label(text="")
        submit_button.config(state="normal")

def checkout():
    # Display checkout message
    checkout_label.config(text="Thank you for your custom. You have been charged " + str(round(rental_cost, 2)) + ".")

def calculate_age(dob):
    # Calculate age from date of birth
    # Assuming dob is in the format "dd/mm/yyyy"
    dob_list = dob.split("/")
    dob_day = int(dob_list[0])
    dob_month = int(dob_list[1])
    dob_year = int(dob_list[2])
    today = date.today()
    age = today.year - dob_year - ((today.month, today.day) < (dob_month, dob_day))
    return age

small_car_img = tk.PhotoImage(file="small-car (1).gif")
medium_car_img = tk.PhotoImage(file="mid-size-car.gif")
large_car_img = tk.PhotoImage(file="large-car (1).gif")

def update_image():
    if category_var.get() == "Small":
        image_label.config(image=small_car_img)
    elif category_var.get() == "Medium":
        image_label.config(image=medium_car_img)
    elif category_var.get() == "Large":
        image_label.config(image=large_car_img)

# Create form fields
name_label = tk.Label(window, text="Name:")
name_label.pack()
name_entry = tk.Entry(window)
name_entry.pack()

dob_label = tk.Label(window, text="Date of birth (dd/mm/yyyy):")
dob_label.pack()
dob_entry = tk.Entry(window)
dob_entry.pack()

validate_age_button = tk.Button(window, text="Validate Age", command=validate_age)
validate_age_button.pack()

nationality_label = tk.Label(window, text="Nationality:")
nationality_label.pack()
nationality_entry = tk.Entry(window)
nationality_entry.pack()

licence_label = tk.Label(window, text="How long have you held your licence for? (years):")
licence_label.pack()
licence_entry = tk.Entry(window)
licence_entry.pack()

label = tk.Label(window, text="Select a car category:")
label.pack()

category_var = tk.StringVar()
small_button = tk.Radiobutton(window, text="Small", variable=category_var, value="Small")
medium_button = tk.Radiobutton(window, text="Medium", variable=category_var, value="Medium")
large_button = tk.Radiobutton(window, text="Large", variable=category_var, value="Large")

image_label = tk.Label(window)
image_label.pack()

small_button.pack()
medium_button.pack()
large_button.pack()

small_button.config(command=update_image)
medium_button.config(command=update_image)
large_button.config(command=update_image)

rental_label_months = tk.Label(window, text="How many months do you plan on renting the car for?:")
rental_label_months.pack()
rental_label_months_entry = tk.Entry(window)
rental_label_months_entry.pack()

rental_label_weeks = tk.Label(window, text="How many weeks do you plan on renting the car for?:")
rental_label_weeks.pack()
rental_label_weeks_entry = tk.Entry(window)
rental_label_weeks_entry.pack()

rental_label_days = tk.Label(window, text="How many days do you plan on renting the car for?:")
rental_label_days.pack()
rental_label_days_entry = tk.Entry(window)
rental_label_days_entry.pack()

cost_label = tk.Label(window, text="Your Total Cost Is: ")
cost_label.pack()
print(cost_label)
cost_label.config(text="Total cost: " + str(round(rental_cost, 2)))

rental_cost_button = tk.Button(window, text="Calculate Cost", command=calculate_cost)
rental_cost_button.pack()

submit_button = tk.Button(window, text="Submit Form", command=submit_form)
submit_button.pack()

window.mainloop()

10 Things to Know When Using SHACL With GraphDB

Featured Imgs 23

Today I have one of those moments where I am absolutely sure if I do not write this down, I will forget how to do this next time. For one of the projects I am working on, we need to do SHACL validation of RDF data that will be stored in Ontotext GraphDB. Here are the 10 things I needed to learn in doing this. Some of these are rather obvious, but some were less than obvious to me.

Number 1: To be able to do SHACL validation, your repository needs to be configured for SHACL when you create your repository. This cannot be done after the fact.

Matter vs. Thread – A Head-to-Head Comparison!

Featured Imgs 23

Modern technology has made communication easier than ever before. From smartphones to other smart devices, we can use a single gadget to accomplish a lot. However, have you ever wondered what makes it all possible? It's the microscopic chip circuits supported by powerful protocols and standards.

Over the past two decades, the technology industry has revolutionized the way we see the world. Today, we use IoT devices that can communicate not only with us but also with other smart devices. This is all thanks to the continuous improvement of communication and networking protocols such as WiFi, Ethernet, Matter, Thread, etc.

React Email

Featured Imgs 23

Only in the last year have I started switching us over to MJML here at CodePen to help craft our HTML emails. Aside from a few minor rough edges, it’s been a nice upgrade from hand-writing the email HTML. Not only was that tricky and time-consuming, but it was also error-prone. The switch-over was in part inspired by some Microsoft Outlook bugs with our CodePen Spark email which MJML helped resolve.

But I have been eying up React Email recently. It’s really just JSX Email as React features are largely irrelevant here. It’s just a nice templating language abstraction. I feel fairly comfortable in JSX so that’s appealing, but so is the modern take on things including a hot module reloading preview and all that.

We don’t really need the sending integrations, but I like how there are basic components available, you can render them to HTML strings for porting elsewhere fairly easily, they didn’t forget about plain text output, and it looks actively developed with a sensible roadmap.

In taking another look recently, I was surprised to see they re-created our CodePen Challenges email!

I guess if we decide to switch someday, they’ve already done a good amount of the work for us. 😍

What “The Rings of Power” Taught Me About a Career in Tech

Featured Imgs 23

Call to me, call to me, lands far away,
For I must now wander this wandering day.
Away I must wander this wandering day.

 – Poppy Proudfellow, “The Rings of Power”

It’s no secret that I derive a special kind of joy from finding lessons for my life and work in tech within pop culture — and specifically “geeky” movies, tv series, books, and more. With Amazon’s “The Rings of Power” season one reaching its conclusion, there was zero chance I wasn’t going to dig into it with zeal to see what this Tolkien (or at least Tolkien-inspired) work might hold.

How to Use AVIF WordPress Images (Easy Method)

Category Image 061
avif WordPressAdding images is an easy way to make your webpages more engaging. However, large file sizes can slow down your site, creating a poor user experience (UX) for your visitors. That's why an alternative image format, such as using AVIF WordPress images, is worth trying. In this post, we'll look at the pros and cons of AVIF images and show you how to use them in WordPress.

How We Solved an OOM Issue in TiDB with GOMEMLIMIT

Featured Imgs 23

A database Out Of Memory (OOM) error can be challenging to deal with. It can have a number of different causes, and without a thorough analysis, it can be difficult to determine the root cause of the error. Some typical causes of an OOM error in a database include insufficient memory, memory leaks, poorly optimized queries, and large result sets.

To troubleshoot an OOM error in a database, it is important to monitor the database’s memory usage over time, profile the database to identify any potential bottlenecks or inefficiencies and optimize queries and indexes as needed.

How Does Augmented Reality (AR) Differ From Virtual Reality (VR)?

Featured Imgs 23

In the current fast-paced environment, both AR and VR are becoming more and more useful. Both technologies have a lot in common with each other, but they are also very different. So, in this article, we'll explain the difference between augmented reality and virtual reality.

What Is AR vs. VR?

AR is a digitally enhanced version of reality in which users can communicate with graphical interfaces that look like a mobile phone or an app. Augmented reality is the technology that connects digital data like text, images, and 3D Models in a real-world atmosphere.

IP address removed automaticlly in windows 8.1

Category Image 041

when I insert ip address by clicking Network connections---> and click on Ethernet properties and change properties of IPv4--> select "use the following ip" and put ip address but as I click "ok" ip address automatically removed and the option "obtain the ip automatically " selected.
when I use ipconfig command from command prompt it shows the ip I put. I can ping other devices like printer, other PC but cannot able to give print command from my PC.

Master C# Arrays: The Basics

Featured Imgs 23

C# Arrays tutorial has related videos. Watch this C# arrays tutorial with both related videos and written material for a step-by-step explanation with code examples. Videos will reduce your learning curve and deepen your understanding where you’re uncertain.

What Is an Array?

An array is a data structure that stores multiple values of the same type in a single variable. You access each individual value through an integer index with an array name. Arrays can be of different dimensions like single-dimension, multi-dimension, or jagged array. The simplest of all is the single dimension, so you’ll start learning how to declare, initialize, and use a single-dimensional array.