teleren/devto huggingface dataset:
Introduction to PHP
Published: 2023-06-11 13:15:06

---
title: Introduction to PHP
published: true
date: 2023-06-11 13:04:53 UTC
tags: 
canonical_url: 
---

If you started your career in the tech space in the past few years as a programmer, you'd have come across a lot of programming languages, **C, C++, C#, Java, Python, JavaScript, PHP, Ruby, Golang, Swift, Kotlin** and the likes, and if you were like me, you'd have probably been confused as to which of these programming languages to learn

![A confused GIF](https://media.giphy.com/media/RLUyfJnogtXK44pm9t/giphy.gif)

but one thing I'm sure of is that PHP might not have been on your mind, Why? because there are loads of people out there on Twitter, Facebook, YouTube, and other social media channels claiming that PHP is "dead", and I honestly believed them for a while until [Segun](https://twitter.com/dreal_olusegun/) opened my eyes, the funny thing is that most of them saying PHP is dead have not used PHP before.

# What is PHP?

PHP which initially stood for Personal Home Page and is now known as Hypertext Processor is a server-side scripting language which was initially created in 1994 by Rasmus Lerdorf, subsequent versions have been released since then, and the latest at the time of writing is PHP 8.2. According to this [article](https://w3techs.com/technologies/details/pl-php) by W3Techs, PHP is used by **77.4%** of all websites whose server-side language is known, which proves that PHP isn't dead.

Popular sites like **Facebook, WordPress, Yahoo, MailChimp, Wikipedia, Slack, Tumblr** etc, all use PHP as their server-side language. Check out this [article](https://developer.mozilla.org/en-US/docs/Learn/Server-side/First_steps/Introduction) by **Mozilla Docs** for the meaning of server-side.

# Basic Syntax

The PHP syntax is similar to programming languages like JavaScript, C and Java, therefore if you have any experience in those languages, PHP would be relatively easier for you to learn, Here is an example

```
<?php 
   echo "Hello; world";
?>

```

The code above is a simple PHP program that displays the word " Hello; world ", the opening and closing tags **"<?php"** and **"?>"** must be included for the code to run, and the **"echo"** word there is a **PHP** keyword that is used to output a string or a variable. I'd be talking about other basic syntax in my subsequent articles

# Conclusion

PHP is still a really popular programming language to learn, although it has its downsides just like every other programming language out there, it's also important to note that there is no perfect programming language to learn as a beginner, you have to choose one to learn based on your interest.

Until next time, **PEACE.**

![](https://media.giphy.com/media/BoHCeLmEKytt7oFxyR/giphy.gif)
Advanced Next.js challenges
Tags: nextjs, webdev, javascript, react
Published: 2023-06-11 11:23:57

At our Design Agency [Design Agentur Form und Zeichen in Graz](https://www.formundzeichen.at/), we are passionate about leveraging Next.js for our programming needs. We thrive on the opportunity to address and overcome even the most specialized customer requirements, thanks to the abundance of powerful libraries available. In this article, I will share a curated summary of fascinating challenges we have successfully tackled using modern techniques.

## The perfect hosting provider
As an EU-based company, we understand the significance of GDPR compliance for our customers. Many clients specifically request EU-based hosting to ensure their data remains within the region. However, finding an EU-based hosting provider that matches the exceptional quality of [Vercel](https://vercel.com/) can be a challenge. 

We have written a blog article that ranks and reviews the top EU-based hosting providers. In this article, you will find a comprehensive summary of each provider's features, enabling you to choose the one that best suits your needs while ensuring GDPR compliance. Link to the article: [Next.js hosting in the EU](https://www.formundzeichen.at/en/development/next-js-hosting-in-the-eu/)

## Achieving Exceptional Performance in Complex Logical Programs
In the realm of Next.js programming, we occasionally encounter intricate logical challenges that demand innovative solutions. When faced with requirements of a logical nature, complexity can rise rapidly. For instance, envision the task of developing a bicycle configurator for a webshop, where various components such as the brake, wheel, and bicycle size have to be compatible.

To address these complexities effectively, our blog article offers a comprehensive, [step-by-step tutorial on harnessing the power of SAT solvers](https://www.formundzeichen.at/en/development/nodejs-sat-solver/). By leveraging SAT solvers, we unlock a robust approach to tackling such tasks.

## Conclusion
There are many interesting challenges for web projects. I am curious to learn more about solving complex tasks and provide perfect solutions for our customers. You can find some ideas for modern web development on my [profile page](https://dev.to/christofkarisch/). If you want to read comprehensive tutorials for modern web development, have a look at our [development blog](https://www.formundzeichen.at/en/develpment-blog/).
The Secret to High-Performance React Applications !
Tags: webdev, javascript, react, interview
Published: 2023-06-11 11:10:37

Have you ever wondered how React manages to update the user interface so seamlessly, only rendering the necessary changes without reloading the entire page?
That's where React Reconciliation and DOM Diffing come into play!🌟

⚡ **React Reconciliation:**
React Reconciliation is the powerful algorithm behind React's virtual DOM, making it lightning-fast and incredibly efficient. When a component's state or props change, React uses Reconciliation to analyze the difference between the previous and new virtual DOM representations.

💡 **DOM Diffing:**
DOM Diffing, a key part of Reconciliation, is the process of determining the minimum set of changes required to update the actual DOM based on the changes in the virtual DOM. Instead of re-rendering the entire UI, React identifies the specific parts of the DOM that need updating, reducing unnecessary computations and optimizing performance.

🔬 **How does it work?**
React compares the old and new virtual DOM trees, identifying the differences or "diffs" between them. It then applies only those specific changes to the actual DOM, resulting in efficient updates and minimal rendering. This approach eliminates redundant operations, dramatically improving performance even in complex UIs.

It allows for a smooth user experience, even with large-scale applications, as updates are intelligently handled without disrupting the entire UI. Understanding these concepts empowers developers to write cleaner, more efficient code.

[Source](https://www.linkedin.com/feed/update/urn:li:activity:7072148578101526528/)
how you can create custom API routes using Next.js
Published: 2023-06-11 11:08:42

As of my knowledge cutoff in September 2021, Next.js version 12 was the latest release, and it did not support decorators for API routes. However, if Next.js 13 introduces decorator support for API routes, I may not be aware of it.

The file-based naming convention is an integral part of Next.js API routes, where each file in the `pages/api` directory represents an API endpoint. For example, `pages/api/users.ts` would correspond to the `/api/users` endpoint.

If you want to have more control over the routing logic, you could consider using a framework like Express.js alongside Next.js. With Express.js, you can use decorators or middleware to define custom routes and handle API requests. However, keep in mind that combining Next.js with an external server framework like Express.js may require additional configuration and might not be the recommended approach.

I recommend referring to the official Next.js documentation, release notes, and community discussions to stay up to date with the latest features and changes in Next.js, including any updates regarding decorator support for API routes in Next.js 13.

Certainly! Here's an example of how you can create custom API routes using Next.js and Express.js:

First, you'll need to install the required dependencies:

```bash
npm install next express
```

Next, create a custom server file called `server.js` in the root of your Next.js project:

```javascript
// server.js
const express = require('express');
const next = require('next');

const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();

app.prepare().then(() => {
  const server = express();

  // Custom API route
  server.get('/api/users', (req, res) => {
    // Handle the API logic here
    const users = [{ name: 'John' }, { name: 'Jane' }];
    res.json(users);
  });

  // Default Next.js request handler
  server.all('*', (req, res) => {
    return handle(req, res);
  });

  server.listen(3000, (err) => {
    if (err) throw err;
    console.log('> Ready on http://localhost:3000');
  });
});
```

In this example, we're creating a custom API route for `/api/users` using Express.js. When a GET request is made to this route, it responds with a JSON array of users.

To start the server, you can update your `package.json` file with the following scripts:

```json
{
  "scripts": {
    "dev": "node server.js"
  }
}
```

Now, when you run `npm run dev`, the custom server will be started, and you can access the API route at `http://localhost:3000/api/users`.

Remember that this approach combines Next.js with an external server framework (Express.js). It gives you more control over routing and allows you to use decorators and other features provided by Express.js. However, it's important to consider the implications and trade-offs of introducing an external server framework to your Next.js project.
Improving Website SEO: Best Practices for Boosting Search Engine Rankings for nextjs routing
Published: 2023-06-11 11:06:31

In Next.js, you can achieve similar routing functionality using the file-based routing system. Each page in Next.js corresponds to a file in the `pages` directory. Let's go through how you can implement the routes you mentioned in your React Router code:

1. Create a file named `index.js` (or `index.tsx` for TypeScript) in the `pages` directory for the Home page:

```jsx
// pages/index.js
import Home from '../components/Home';

export default Home;
```

2. Create a file named `search.js` (or `search.tsx` for TypeScript) in the `pages` directory for the search page:
```jsx
// pages/search.js
import { useRouter } from 'next/router';
import Home from '../components/Home';

const SearchPage = () => {
  const router = useRouter();
  const { search } = router.query;

  // You can use the 'search' query parameter here

  return <Home />;
};

export default SearchPage;
```

3. Create a file named `top_sold.js` (or `top_sold.tsx` for TypeScript) in the `pages` directory for the top sold page:
```jsx
// pages/top_sold.js
import Home from '../components/Home';

export default Home;
```

4. Create a file named `recent_added.js` (or `recent_added.tsx` for TypeScript) in the `pages` directory for the recent added page:
```jsx
// pages/recent_added.js
import Home from '../components/Home';

export default Home;
```

5. Create a file named `faq.js` (or `faq.tsx` for TypeScript) in the `pages` directory for the FAQ page:
```jsx
// pages/faq.js
import { useRouter } from 'next/router';
import FAQ from '../components/FAQ';

const FAQPage = () => {
  const router = useRouter();
  const { section } = router.query;

  // You can use the 'section' query parameter here

  return <FAQ />;
};

export default FAQPage;
```

6. Create a file named `client.js` (or `client.tsx` for TypeScript) in the `pages` directory for the profile page:
```jsx
// pages/client.js
import { useRouter } from 'next/router';
import Profile from '../components/Profile';

const ProfilePage = () => {
  const router = useRouter();
  const { username, type, search } = router.query;

  // You can use the 'username', 'type', and 'search' query parameters here

  return <Profile />;
};

export default ProfilePage;
```

By creating these files, you define the different routes and corresponding components in the `pages` directory of your Next.js project. Next.js will automatically handle the routing based on the file structure.

Note that the code examples assume you have separate components (`Home`, `FAQ`, and `Profile`) that correspond to the different pages.

With this file-based routing approach, you can achieve similar functionality to the React Router code you provided. Remember to import and use the necessary hooks (`useRouter` from `next/router`) to access the query parameters and implement the logic as needed in each page component.
Old man decides to try tech for a new career...
Published: 2023-06-11 11:00:14

Hi all,
I'm Chris..
Back in the early 80's I got a ZX81 for christmas and was instantly hooked on programming..
Messed about for a few years whilst at school and wrote my entire classes O level computer studies project on an acorn electron
Spent the next 35 years in either manufacturing or construction with little connection to tech and now, at 51 years old I decide to get back into it and see if I can forge a career that I can rely on for the next 20 years as construction isnt really for me anymore..
Started on a bootcamp with Northcoders, Manchester Uk studying Javascript, express for backend, react for frontend and am hoping to be in a position to get an actual paid job at the end of it.
Ended up here on a sunday morning after going looking for a headless cms I could actually understand and set up and so far I've decided on Strapi.. just about to have a mess about and see if I can connect it to a couple of basic [webpage](https://cmwilson.co.uk)[s ](https://louisaparr.com) Ive managed to create using react, just playing around really.. wish me luck and if anyone has any suggestions they are very very welcome..
In short, Hi, and thanks for having me!
I built 3 Apps using Spotify API and Python
Tags: python, opensource, programming
Published: 2023-06-11 11:00:12

I made Three apps using Spotify API. 

## Spotify to YouTube playlist converter
A simple python script to convert your Spotify playlist into YouTube playlist.

- GitHub: [Spotify to YouTube Playlist Converter] (https://github.com/yogeshwaran01/spotify-playlist-to-youtube-playlist)
- Blog Post: [From Spotify to YouTube: How I Built a Python Script to Convert Playlists] (https://dev.to/yogeshwaran01/from-spotify-to-youtube-how-i-built-a-python-script-to-convert-playlists-2h89)

## Update my Spotify playlist
Automatically update your Spotify playlists with tracks of your favorite artists and genres using this Python script powered by the Spotify Web API and GitHub Actions.

- GitHub: [Update My Spotify Playlist] (https://github.com/yogeshwaran01/update-my-spotify-playlist)
- Blog Post: [Effortlessly Update Your Spotify Playlists Daily with This Simple Tool] (https://dev.to/yogeshwaran01/effortlessly-update-your-spotify-playlists-daily-with-this-simple-tool-1kaa)

## Spotify stats App
Simple Spotify stats app

- GitHub: [Spotify Stats App] (https://github.com/yogeshwaran01/spotify-stats)
- Live App: [Experience the Simple Spotify Stats App] (https://simple-spotify-stats.onrender.com)

Thank you; Give star ⭐ to my repos
Generating a GPG key to your GitHub
Tags: gpg, git
Published: 2023-06-11 10:53:17

---
title: "Generating a GPG key to your GitHub"
published: true
description: 
tags: ["GPG","Git"]
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-06-11 10:50 +0000
---

## What is GPG

> GPG (GNU Privacy Guard) is an open-source software used for encrypting and signing data. GPG uses asymmetric encryption technology where the cryptographic keys are divided into two parts: a public key and a private key. The public key is used to encrypt data and only the user holding the private key can decrypt it. The private key is used for digital signature which proves that the data indeed comes from a specified sender and has not been tampered with.

## Why recommend to use GPG to protect your git commit

There is a risk of Git commit being impersonated because it does not have default authentication mechanisms. If someone knows your name and email address, they can impersonate your commits in the Git repository, which can damage your reputation or lead to improper behavior in your name.

To avoid this, you can use GPG signatures to authenticate Git commits.


## Setup GPG in mac

### Install GPG

```
brew install gnupg
```

### Generate key pair

All step set to default

```
gpg --full-generate-key --expert

Please select what kind of key you want:
   (1) RSA and RSA
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
   (7) DSA (set your own capabilities)
   (8) RSA (set your own capabilities)
   (9) ECC (sign and encrypt) *default*
  (10) ECC (sign only)
  (11) ECC (set your own capabilities)
  (13) Existing key
  (14) Existing key from card
Your selection?
```

## Export key

### Check the exiting key

```
gpg --list-secret-keys --keyid-format LONG

gpg: checking the trustdb
gpg: marginals needed: 3  completes needed: 1  trust model: pgp
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
[keyboxd]
---------
sec   ed25519/XXXXXXXXXXXX 2023-05-28 [SC]
      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
uid                 [ultimate] SpiffyEight77
ssb   cv25519/XXXXXXXXXXXX 2023-05-28 [E]
```

### Export the public key

```
gpg --armor --export XXXXXXXXXXXX
```

And then past it into GitHub `SSH and GPG keys` setting.

### Setting the environment to the shell

```
echo 'export GPG_TTY=$(tty)' >> ~/.zshrc && source ~/.zshrc
```

### Allow git to use the GPG key for signing

```
git config --global user.signingkey XXXXXXXXXXXXX

git config --global commit.gpgsign true
```

## Export for backup (optional)

To export the public and secret key for backup and please keep it in a safe place

```
gpg --armor --output gpg_sec_key.gpg --export XXXXXXXXXXX
gpg --armor --output gpg_sec_key.gpg --export-secret-keys XXXXXXXXXXX
```
CSS Modules
Tags: css
Published: 2023-06-11 10:40:25

---
title: CSS Modules
published: true
date: 2023-06-11 10:39:15 UTC
tags: css
canonical_url: https://blog.nicm42.co.uk/css-modules
---

I wanted to try out new CSS things and in the [State of CSS survey 2022 CSS](https://2022.stateofcss.com/en-US/css-in-js/) Modules was pretty high up on the list.

I used it in a Vue project using Vite and I found it anticlimatic. Partly because Vite works with it without any extra work, and partly because it was a really simple project. But the only difference between using CSS and CSS Modules is that the file name ending was .module.css, rather than .css. That's it.

So it was very easy to use, but hard to see the point. What makes CSS Modules good is the ability to locally scope the styling. But with Vue you can do that with CSS, as you just import the CSS file you want to use with your component, then it's only used with that component.

So I didn't pick the best thing to use it on. But at least now it's not a total mystery and I know it's easy to use.
I have a question. What are freelance platforms missing for developers & designers?
Published: 2023-06-11 10:39:04

For the past few days i have been looking through fiverr.com & freelancer.com. I was going through the forums to be a freelancer. But there is so much information they want you to input. I just gave up. I'm wondering if others had this experience & if there was another freelance platform what would you want from that specific platform?
Perl Weekly Challenge #220 - I've Seen These Characters 'Round These Parts
Tags: perl, perlweeklychallenge, grep, regex
Published: 2023-06-11 09:46:52

Hi everybody, just a quick one this week. Again it's been a very busy week, so I wrote this one quick to print the sorted list of all common characters in all the words provided. That's the simple explanation of this week's challenge.

Here's the code:

    my @results;
    my $first_word = shift;
    for my $letter (split(//, $first_word)) {
        push(@results, lc($letter)) if (grep {$_ =~ /$letter/i} @ARGV) == @ARGV;
    }
    @results = sort @results;
    say $_ foreach @results;

So, for how it works. We take the first word, split it up into its letters, and look through it. All common characters have to appear in the first word, so we can just limit ourselves to those letters. We loop through each letter in the word, and do a regex grep to find any words containing the letter. If every word matches, we add the letter to the resulting list, then sort and print each one.

I got to learn more about grep this week, so that will help me be more idiomatic with it.

Stay safe and I'll hopefully see you next week!
Deploying services on Windows
Tags: discuss
Published: 2023-06-11 10:15:14

Services are also often headless daemons, that is, they have no user visible ui, and are meant to be running all the time. While I used to write very highly portable code for telephony services, I have been writing services (often in C++) only for posix and embedded targets for at least a decade now.

It's hard for me to find a use case for running windows as a services platform. But I was never closed to the idea of running telephony services on windows if a plausible use case can be suggested. For my own code, in most cases, it would be changing my main.cpp to conditionally compile as a windows system service rather than just managed thru posix signal handlers. Other changes are probably much smaller.

My current telephony applications build with the eXosip library. This does build and runs on windows, and I vendor it in my packages so it can build locally without trying to get it to externally build in something like vcpkg, so it's easy to carry and build that too.  Actually, I also use eXosip for client telephony applications for this reason, too, but those I tend to build with Qt, which already is fully portable.