Beyond Compliance: Fable’s Mission to Improve Digital Accessibility

It's time we recognize that the way we build digital products is broken. That's because the products we use today represent the people who build them more than the people who use them.

There is a digital divide between the experiences of people with disabilities and people who are able-bodied. Bridging this divide is about more than compliance or checking a box.

Pairwise distance

Is there any way I can calculate pairwise distance matrix in python (not biopython) from a file containing 3 rows as:

ACCGGT-TAACA
ACCGT--AACCG
ACCGTGCCTAG

Using Cursors and Loops in MySQL

Dolphins image.

If you've ever wanted to learn how to write a MySQL cursor or a MySQL loop, you've come to the right place. Let's iterate!

Consider loops in general programming. They help you execute a specific sequence of instructions repeatedly until a particular condition breaks the loop. MySQL also provides a way to execute instructions on individual rows using cursors. Cursors in MySQL will execute a set of instructions on rows returned from SQL queries.

Properties of MySQL Cursors

  • Non-Scrollable: You can only iterate through rows in one direction. You can't skip a row; you can't jump to a row; you can't go back to a row.
  • Read-only: You can't update or delete rows using cursors.
  • Asensitive: MySQL cursors point to the underlying data. It runs faster than an insensitive cursor. Insensitive cursors point to a snapshot of the underlying data, making it slower than the asenstive cursors.

Creating a MySQL Cursor

To create a MySQL cursor, you'll need to work with the DECLARE, OPEN, FETCH, and CLOSE statements.

Use Cases for Apache Kafka in the Public Sector

The public sector includes many different areas. Some groups leverage cutting-edge technology, like military leverage. Others like the public administration are years or even decades behind. This blog series explores how the public sector leverages data in motion powered by Apache Kafka to add value for innovative new applications and modernize legacy IT infrastructures. Life is a stream of events. Therefore, examples include a broad spectrum of use cases across smart cities, citizen services, energy and utilities, and national security deployed across the edge, hybrid, and multi-cloud scenarios.

Blog Series: Apache Kafka in the Public Sector and Government

This blog series explores why many governments and public infrastructure sectors leverage event streaming for various use cases. Learn about real-world deployments and different architectures for Kafka in the public sector:

What BDD Is and Why You Need It: Java and Behavior Driven Development

Is Behavior Driven Development Just Another Religion?

You might hear about BDD but still don't have a clear understanding of what it is. Here I'll try to simplify the main ideas and provide clear examples. This article is useful not only for developers but all people involved in the development process like analysts, product owners, and even guys from the business.

BDD Makes Application Logic More Transparent

Low Transparency in Application is a very known problem in IT. Quite often domain knowledge belongs only to the development team. As a consequence, to get even a simple answer you have to ask the developer to explain.

Reimagine Atomic CSS

I’m not the biggest fan of Atomic CSS myself. I don’t like all the classes. I like to express my styles in CSS because I find CSS… good. But I appreciate that a lot of people seem to like it, and it does have some clear advantages, like the fact that the generated stylesheet is generally smaller than hand-rolled CSS authored other ways—plus, the available classes are like guardrails that ensure more consistent usage in a design system.

I also appreciate that innovation is happening in this space. It seems to have gone from:

Here’s a billion classes you can use, but hey, at least the CSS is still fairly small and won’t change!

To:

Yes, that, but we’re going to strip away the ones you aren’t using.

And now:

We’re going to generate the stylesheet on the fly based on what you do use.

Anthony Fu breaks down this history nicely in “Reimagine Atomic CSS” where he then throws his hat in the ring taking things one step further with UnoCSS. I can’t say I fully understand it all, but it looks like it can do anything that its predecessors can do but more, largely via rule configurations. It’s also fast (based on vite), and I’m always a fan of fast tools—especially where the goal is a tightly authored feedback loop.

It looks rather complex to me and seems to have limited integrations. I’m not a fan of the bit that turns styles into arbitrary HTML attributes. If they were, like, JSX props, that’s fine. But I think HTML attributes that go all the way to the DOM are dangerous and should be data-* scoped.

At the same time, I always like it when people think through problems and share their thought processes for solving them like Anthony has done here. Plus, there is a playground and that’s fun.

To Shared LinkPermalink on CSS-Tricks


The post Reimagine Atomic CSS appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.

How to Explain Kubernetes to a Business Team

Kubernetes gets a lot of attention in the tech world. But it is almost completely unknown to anyone in the business world. This situation isn’t unusual. Technology is moving so fast the business teams are less and less familiar with the systems they rely on.

This makes it much harder when you need to talk to the business about a particular technology. So how do you explain something like Kubernetes to a business team?

Thinking of Models as Graphs

The first step in any big data visualization and analysis process is to ingest your data. In the past, most developers thought of models as rows with attributes and references to other row identifiers. In keeping with that mentality, Perspectives pulled data from a relational database into its session-scoped model.

Relational social network data file.
Relational social network data are shown in rows of elements and attributes.

Modern graph visualization developers tend to conceptualize data differently. While many users still pull data from an RDBMS, an increasing number use graph-based data storage and think about their data in graph-like ways.

Level up your data Visualization With Charts in 7.0.2 Couchbase

If a picture is worth a thousand words, data visualization is worth a thousand data points. The 7.0.2 Couchbase Query Workbench (and the Analytics Workbench) introduces the charts tab, which allows users to create charts based on the results of the query.

A Closer Look at Charts

Internally we use D3 to render the charts themselves. Each individual value can be seen using the hover tooltip, and the legend (colors and what they represent) for the multicolored charts are seen in the right-hand corner of the canvas. The charts can also be downloaded as an SVG using the button on the right-hand side of the canvas. Sizing the canvas or the screen itself auto-adjusts the charts to fit. 

Add data to table –

I'm trying to modify a web script.
Currently, upon uploading a video, in the upload Form, among other things, the uploader chooses a sub-category and enters tags
and then submits/uploads. I'd like the sub-category that is selected, to also be searchable as a keyword.

Presently, the 'videos' table has a 'sub-category' column, but only the 'sub_category' ID is stored there (upon a video being uploaded), not the actual searchable name of the 'sub_category'. (All of the sub-category names and related sub_category ID's are stored in another table).

I'd like to modify the script code so that when the sub_category ID gets stored in the VIDEOS table, the corresponding sub_category name also populates in that table, upon a video being uploaded (so that I can add the 'sub_category' name as a searchable keyword).

I believe this code from the script's submit.php file is where the VIDEOS table gets populated (in the data_insert = array):

if (!empty($_POST['category_id'])) {
                if (in_array($_POST['category_id'], array_keys(get_object_vars($pt->categories)))) {
                    $category_id = PT_Secure($_POST['category_id']);
                }
            }
            $video_privacy = 0;
            if (!empty($_POST['privacy'])) {
                if (in_array($_POST['privacy'], array(0, 1, 2))) {
                    $video_privacy = PT_Secure($_POST['privacy']);
                }
            }
            $age_restriction = 1;
            if (!empty($_POST['age_restriction'])) {
                if (in_array($_POST['age_restriction'], array(1, 2))) {
                    $age_restriction = PT_Secure($_POST['age_restriction']);
                }
            }
            $sub_category = 0;

            if (!empty($_POST['sub_category_id'])) {
                $is_found = $db->where('type',PT_Secure($_POST['category_id']))->where('lang_key',PT_Secure($_POST['sub_category_id']))->getValue(T_LANGS,'COUNT(*)');
                if ($is_found > 0) {
                    $sub_category = PT_Secure($_POST['sub_category_id']);
                }
            }

            $publication_date = 0;
            if (!empty($_POST['date']) && !empty($_POST['hour'])) {
                $publication_date = strtotime($_POST['date']." ".$pt->config->hours[$_POST['hour']]);
                $video_privacy = 1;
            }
            $data_insert = array(
                'video_id' => $video_id,
                'user_id' => $user->id,
                'title' => PT_Secure($_POST['title']),
                'description' => PT_Secure($_POST['description']),
                'tags' => PT_Secure($_POST['tags']),
                'video_location' => '',
                'category_id' => $category_id,
                'thumbnail' => $thumbnail,
                'time' => time(),
                'registered' => date('Y') . '/' . intval(date('m')),
                'converted' => '2',
                'size' => $filesize,
                'privacy' => $video_privacy,
                'age_restriction' => $age_restriction,
                'sub_category' => $sub_category,
                'embedding' => $embedding,
                'publication_date' => $publication_date
            );

Can you provide some insight/guidance as to when the video title, description, tags and sub_category ID, etc. gets added to VIDEOS table
how I can also add sub_cat name that corresponds with the populated sub_category ID?

As stated above, all of the sub-category ID's and related sub_category names are stored in another table.

I look forward to any assistance.

Practical API Security: The OWASP API Security Top Ten

API security is on everyone’s mind: After all, APIs always opens up network-accessible interfaces that previously may not have been exposed. Making sure that this is not creating new risks means that securing APIs is an essential aspect of API management.

API security has always also been a technical issue, but it starts much earlier than when just “securing an API.” It needs to be part of the general API mindset and of how an organization manages APIs throughout its lifecycle.

History of SRE: Why Google Invented the SRE Role

If you know anything about the origins of Site Reliability Engineering, or SRE, you know that the concept was born at Google.

But why did Google establish the SRE role? And how did SRE spread from the search giant to companies of all types -- including but not limited to Web-scale businesses with massive reliability needs?

age calculator with C++

Write a program that predicts your age in 25 years from now so that the program receives the year of your birth and then prints the expected lifeWith C++

Next.js Wildcard Subdomains

A “wildcard”? What in the world? Great question, these types of domain stem from Wildcard DNS Records which look like this:

*.example.               3600     TXT   "Wild! You have found a wildcard."

When used, this DNS record will cause any subdomain that matches with the wildcard to hold a TXT value of: “Wild! You have found a wildcard.”

For example, if this was set on the domain smashingmagazine.com, apples.example.smashingmagazine.com and oranges.example.smashingmagazine.com would both return the above TXT value. The same principle can be applied to CNAME & A records as well.

Wild Use Cases For Wildcards

Wildcards can be used for a wide range of things. For now, let’s focus on where they can be applied in combination with Next.js:

  1. Providing Hosted Services
    The most common use of wildcard domains is to provide users of hosted services their own space with a unique subdomain. For example, if I was building a platform for restaurants to host digital ordering platforms with the domain menus.abc, I would be able to offer Dom’s Pizzeria domspizzeria.menus.abc and Magical Prata the domain magicalprata.menus.abc. The benefit of this is that it gives each of these establishments their enclosed space which they can customize and build out. This space can act as its own website — not tied to anything.
  2. Hosting Content And Personal Portfolios
    Wildcards can also be used as a space for hosting content in portfolios, giving a sense of individuality to these portfolios, an example of this would be how Medium provides subdomains for the authors.
  3. Wilder More Creative Use Cases
    You can’t define these use cases, but there are many creative use cases of these styles of domains. For example, later in this article, we’ll be developing a web toy that flips a webpage upside down making it readable for Australians.
The Caveats Of Wildcards With Next.js

Sigh. Unfortunately, using wildcards isn’t perfect there are a couple of drawbacks:

  • No More Static-Site Generation (and ISR)
    Unfortunately, there aren’t any special systems to provide custom statically generated pages for different wildcard subdomains like you may with dynamic routing for example (where you have [slug].js files).
  • Difficulties with Development
    When developing locally, it can be a pain to simulate wildcard domains and we’ll be touching on this a fair bit later on in this article but it is something important to keep in mind.
  • Limited Deployment Platforms
    Vercel supports Wildcard Domains, however, other Jamstack oriented platforms do not all support wildcard domains. For example, Netlify limits the feature to a select group of users on the Pro plan.
Building With Wildcards

With all this talk, let’s look at building with these domains. We’ll be focusing on three places where you can get the wildcard:

  1. Server Side In getServerSideProps,
  2. Client Side With useEffect,
  3. Server Side On API Routes And Edge Functions.

Server Side In getServerSideProps

This is the most commonplace in which you will need to extract the wildcard, you can use this on pages where you need to render completely different content for different wildcards. As discussed above, this can not be done through static site generation so we must do it on server-side rendered pages.

The getServerSideProps is passed a context object, in this object you can access the HTTP request object using context.req. In this request object, you can access the hostname at headers.host, which will return a string such as example.yourdomain.com. We can split the string into an array across each period and then access the first item in said array. In code, that looks like this:

export async function getServerSideProps(context) {
  let wildcard = context.req.headers.host.split(".")[0];
  wildcard =
    wildcard != "yourdomain"
      ? process.env.NODE_ENV != "development"
        ? wildcard
        : process.env.TEST_WILDCARD
      : "home";
  return { props: { wildcard } };
}

As you can see in this piece of code, we do an extra set processing on the wildcard if it’s the base domain we set the wildcard to home (if taking user input, this is a case you will need to handle) and if we are testing on localhost we can test out other wildcards. In our default export function, which renders our page we can use a switch statement to handle the wildcards:

export default function App(props) {
  switch(props.wildcard) {
    case "home":
      return <div>Welcome to the home page!</div>;
      break;
    default:
      return <div>The wild card is: {props.wildcard}.</div>;
  }
}

Client Side With useEffect

If you only want to make small modifications to each page on a different wildcard, you can avoid using server-side rendering by using the useEffect hook on the client-side. This approach will be rather similar to how we did it in getServerSideProps, except we will be relying on window.location.hostname. Using window means that the initial server render won’t be able to access the information, so we must wrap it within a useEffect hook that runs on the client-side. Here’s how that code looks like:

// useEffect and useState must be imported from 'react'

const [wildcard, setWildcard] = useState("")
  useEffect(() => {
    setWildcard(window.location.hostname.split(".")[0])
  }, [])

This approach, however, is far from perfect as there is a delay between the page’s first render and the wildcard being available. Therefore, if you are making drastic changes based on the wildcard then the changes will be jarring for your user. This may also hurt your cumulative layout shift measure on your web vitals. With this in mind, I highly recommend limiting your use of this approach to adaptations that would be off-sight from the viewer on the initial load. An example would be a branded footer, on a technical documentation page. It is, of course, still handy to know.

Server Side On API Routes And Edge Functions

API routes are another area where you may want to access a wildcard from. Fortunately, the same request object we discussed in the above section on getServerSideProps is also available when using a Node.js API route with Next.js. We can access it like this:

export default (req, res) => {
  let wildcard = req.headers.host.split(".")[0];
  wildcard =
    wildcard != "yourdomain"
      ? process.env.NODE_ENV != "development"
        ? wildcard
        : process.env.TEST_WILDCARD
      : "home";
  res.json({ wildcard: wildcard })
}

Following this, we can then take certain actions such as fetching different data from your database depending on the wildcard and return that from the API.

This same logic can be applied to Next.js’ new Edge Functions / Middleware. This enables you to use wildcards in more than one route without duplicating code as well as speeding up the processing as code execution happens on the edge. Whilst the functionality is still in beta, it’s certainly something to keep an eye on.

// _middleware.js
export function middleware(req) {
  let wildcard = req.headers.get("host").split(".")[0];
  console.log(wildcard);
  wildcard =
    wildcard != "yourdomain"
      ? process.env.NODE_ENV != "development"
        ? wildcard
        : process.env.TEST_WILDCARD
      : "home";
  console.log(process.env.TEST_WILDCARD);
  return new Response(JSON.stringify({ wildcard: wildcard }), {
    status: 200,
    headers: { "Content-Type": "application/json" },
  });
}
The 🦘Aussie-izer

Now that we’ve explored the theory of this strategy, let’s explore how we put it into practice. In this section, we’ll be taking this approach to build a project that flips websites upside down (well, websites that are using a .com domain and aren’t subdomains) called the 🦘Aussie-izer.

To get started, we’re going to want to run yarn init and then yarn add next react react-dom, and finish up by adding these standard scripts to our package.json:

"scripts": {
  "dev": "next dev",
  "build": "next build",
  "start": "next start",
  "lint": "next lint"
}

As soon as we’ve got a standard Next.js project set up, we’re going to want to create the only code file we’ll need for this project: pages/index.js.

First, we’ll want to add the getServerSideProps function in which we’ll extract the wildcard (as I’ll be hosting this at aussieizer.sampoder.com) that’s what I’ll be evaluating to home as:

export async function getServerSideProps(context) {
  let wildcard = context.req.headers.host.split(".")[0];
  wildcard =
    wildcard != "aussieizer"
      ? wildcard != "localhost:3000"
        ? wildcard
        : process.env.TEST_WILDCARD
      : "home";
  return { props: { wildcard } };
}

We’ll then be using that wildcard, to render an iFrame to fill that page (by flipping iFrame over to create the effect), with our src being set to {`https://${props.wildcard}.com`}. We’ll use a switch case, as we discussed above, to render a small helper page if they visit the home page:

export default function App(props) {
  switch (props.wildcard) {
    case "home":
      return (
        <div>
          Welcome to the Aussie-izer! This only works for .com domains. If you
          want to Aussie-ize{" "}
          <a href="https://example.com">https://example.com</a> visit{" "}
          <a href="https://example.aussieizer.sampoder.com">
            https://example.aussieizer.sampoder.com
          </a>.
        </div>
      );
      break;
    default:
      return (
        <iframe
          src={https://${props.wildcard}.com}
          style={{
            transform: "rotate(180deg)",
            border: "none",
            height: "100vh",
            width: "100%",
            overflow: "hidden",
          }}
          frameBorder="0"
          scrolling="yes"
          seamless="seamless"
          height="100%"
          width="100%"
        ></iframe>
      );
  }
}

And we’re ready to go! The live version is available at https://aussieizer.sampoder.com and the source code can be found at https://github.com/sampoder/aussie-izer/.

Hosting/Deployment

If you’re hosting on a custom server, wildcard domains will be a breeze to set up through DNS. However, a great part about using Jamstack is being able to host on services such as Vercel or Netlify; these services have their own domain management systems.

Vercel

Vercel supports wildcard domains out of the box — for all accounts. To use them, first visit the Domains section of your deployment’s Settings tab. Next, you’ll want to enter your domain by using a * to signify the wildcard.

For the above example, I entered:

*.aussieizer.sampoder.com

You most likely will also want to add your root domain (aussieizer.sampoder.com, in my case) to be able to provide a homepage or some instructions, however, that could also be a separate codebase.

Netlify

Netlify limits their wildcards feature to Pro accounts; if you have a Pro account, you will need to email their support staff for them to then enable the option on your account. It will show up in the domain settings page once enabled.

Render

Render also offers wildcard domains to all users. Simply enter a domain with a * (signifying your wildcard) in the Add Custom Domain input on the custom domains section of your site’s settings page which will enable the wildcard. Please note that Render will require you to add additional records to your DNS so that they can issue a LetsEncrypt SSL certificate (exact instructions will be shown to you when you input your wildcard domain).

That’s It!

Wildcard domains often go under the radar — I hope you enjoyed exploring them with me. Thank you!

Also: FYI Australians do not actually see upside down.

Further Reading On Smashing Magazine

Siashmed – The Healthcare Platform

Siashmed is a global platform to ensure enhanced accessibility of medicines, healthcare products, and services to people from the local pharmacy stores, clinics, hospitals, and other healthcare domains. The founder of Siashmed Mr. Ashish Kumar believes that developing and strengthening the traditional pharmacy stores will be a part of the next upcoming stages of the e-commerce revolution in India. He aims to deliver quality medical products, medicines, and healthcare products at economical, affordable, and competitive prices with easy availability of digital e-commerce technology to the customers. On Siashmed you can order available medicine & healthcare products present at a pharmacy shop in the surrounding region based on the doctor's prescription. Download the Siashmed app and avail a new exposure of obtaining any medical product at a fast pace as well as effective customer experience.