teleren/devto huggingface dataset:
Rescript pass React Component.make as a prop
Published: 2021-08-16 07:54:19


```rescript
// --file status.res
module type SComponentType = {
  type data
}
module SComponent = (Config: SComponentType) => {
  type component = {"data": Config.data} => React.element

  @react.component
  let make = (
    ~status,
    ~componentMake: component,
    ~data: Config.data,
    ~errorText: option<string>=?,
    ~errorComponent: option<React.element>=?,
  ) => {
     let actualErrorComponent = switch (errorComponent, errorText) {
    | (Some(errorComponent), None) => errorComponent
    | _ =>
      switch errorText {
      | Some(errorText) => React.string(errorText)
      | _ => React.null
      }
    }

    switch status {
    | "success" => React.createElement(componentMake, {"data": data})
    | _ => <> {actualErrorComponent} </>
    }
  }
}
```

I wish to pass component which is not constructed yet but to be constructed only when the status == "success"

Inorder to do that I need to pass Component.make

Lets say I have component

```rescript
// -- file: name.res
@react.component
let make = (~name: string) => {
  <div>{React.string(name)}</div>
}
```

In order to pass the component as a prop to <Status /> 

I would pass it as 

```rescript
module StatusComponentType = {
  type data = string
}
module StatusFunctor = Status.SComponent(StatusComponentType)

<StatusFunctor
 componentMake={Name.make}
 data=string
/>
```
HNG Internship 8 Task1
Published: 2021-08-16 07:50:21

Hi, I’m Kizito a Mathematics Student and a Full Stack Developer (MERN) Stack. Last year I enrolled for a developer training with start.ng. That’s how I got interested about the main training (HNG). I wasn’t able to apply last year due to some device issues, So I had to postpone it till this year. 

By the end of eight(8)weeks of this program I wish to have the skills/expertise from this internship that I can apply in reality and to build my network of strong people in Tech so we can be able to solve real world problems and make money together 😉
I hope I’ll make it to the final stage and also receive my guaranteed HNGi8 Tee Shirt. 

https://internship.zuri.team
https://cars.ng

Git Beginner Tutorial:
https://cars.ng/tps://youtu.be/USjZcfj8yxE

HTML Beginner Tutorial:
https://youtu.be/pQN-pnXPaVg

Figma Beginner Tutorial:
https://youtu.be/jk1T0CdLxwU

NodeJs Beginner Tutorial:
https://youtu.be/Oe421EPjeBE
Top 5 best YouTube channel for programmers
Tags: codenewbie, webdev, python, javascript
Published: 2021-08-16 07:49:30

Ok so in this blog imma show the top 5 best youtube channel that I personally use to learn. Keep in mind that these all are my suggestions, everyone has a different taste.

##### [Join my discord server and talk with many programmers in there](https://discord.gg/WWFZU96XtM)
##### - First 25 people to join will get special role

### Number 1 - FreeCodeCamp
So FreeCodeCamp is a really good youtube channel for everyone who is learning to code and want to learn to code, they make large, small and video for everything, they also have a forum where you can read blogs. Their videos are one of the best although I have met many people who dont like Free Code Camp.

### Number 2 - Transvercy Media
This is almost same as free code camp, makes great video, of many languages and big or small videos. I dont have watched much videos of Transvercy Media so I dont know what to tell but yeah as far I have a watched its really great. also I havnt met anyone who said anything bad for this channel.

### Number 3 - Programming with Mosh
Mosh Hamedani ( his name ) provides tons of tutorials of trending and emerging web languages and technologies. He also makes large and small videos but mainly cover Python, Javascript, C# etc.

### Number 4 - Dev Ed
Edward Simon who has a great sense of humor, teaches frontend languages and libraries like JavaScript, React and backend runtime environment like Node.js. He also teaches web design, 3D modeling using tools like Figma, Sketch, and Photoshop without getting you bored.

### Number 5 - Web Dev Simplified
This is my personal best, maybe I think DevEd and Web Dev Simplified is draw but yeah. He mainly focus on JavaScript.

Haha comment the next 5 :)
Set Expiration Date for PDF Document Using Java
Published: 2021-08-16 07:30:43

Nowadays, more and more e-books, company contracts/agreement, academic report are in PDF file format. And for some confidential documents, setting expiration date is a very effective way to protect them. After the expiration date, the documents will be automatically destroyed. This article will demonstrate how to set an expiration date for a PDF document using Free Spire.PDF for Java. 

**Import jar dependency (2 Methods)**
● Download the [free API](https://www.e-iceblue.com/Download/pdf-for-java-free.html) and unzip it. Then add the Spire.Pdf.jar file to your project as dependency.
● Directly add the jar dependency to maven project by adding the following configurations to the pom.xml.
```xml
<repositories>
    <repository>
        <id>com.e-iceblue</id>
        <name>e-iceblue</name>
        <url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>e-iceblue</groupId>
        <artifactId>spire.pdf.free</artifactId>
        <version>4.3.0</version>
    </dependency>
</dependencies>
```

**Code Snippet**
```java
import com.spire.pdf.FileFormat;
import com.spire.pdf.PdfDocument;
import com.spire.pdf.actions.PdfJavaScriptAction;

public class ExpiryDate {

    public static void main(String[] args) {

        //Create a PdfDocument object
        PdfDocument doc = new PdfDocument();

        //Load a PDF file
        doc.loadFromFile("C:\\Users\\Administrator\\Desktop\\Moon.pdf");

        //Set expiration date and warning information,and close the document through JavaScript
        String javaScript = "var rightNow = new Date();"
                + "var endDate = new Date('June 30, 2021 23:59:59');"
                + "if(rightNow.getTime() > endDate)"
                + "app.alert('This document is no longer valid, please contact us for a updated one.',1);"
                + "this.closeDoc();";

        //Create a PdfJavaScriptAction object based on the javascript
        PdfJavaScriptAction js = new PdfJavaScriptAction(javaScript);

        //Set PdfJavaScriptAction as the AfterOpenAction
        doc.setAfterOpenAction(js);

        //Save to file
        doc.saveToFile("ExpirationDate.pdf", FileFormat.PDF);
    }
}
```

![ExpiryDate](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yl8frmcpohebjlays9kn.jpg)
HNG 8.0 INTERNSHIP: My Front-end Development Journey
Tags: career
Published: 2021-08-16 07:28:13

I applied for the HNG 8.0 Internship and got in. Someone might ask, what is the HNG Internship? This is a remote internship program for developers and designers that focuses on the post-training phase therefore, you get to work on real-world projects and challenges during the program. You can get more information about the program [here](https://internship.zuri.team).

### My goals for the internship
I am on the Front-end Development track therefore one of my goals is to be able to put my skills into practice, connect and learn from other developers. 

### What I want to achieve at the end of the internship
I want to improve my collaboration skills and also learn new skills.

If you are a beginner or getting started on your development journey, here are a few resources to get you started.
- Design track
[Figma Crash Course](https://www.youtube.com/watch?v=Gu1so3pz4bA)

- Version control using Git
[Git and Github for beginners](https://www.youtube.com/watch?v=3RjQznt-8kE&list=PL4cUxeGkcC9goXbgTDQ0n_4TBzOO0ocPR)

- JavaScript Course
[Modern JavaScript](https://www.youtube.com/watch?v=iWOYAxlnaww&list=PL4cUxeGkcC9haFPT7J25Q9GRB_ZkFrQAc)

Happy coding!
How to use Luos with Python? Step 1 - Install and config Pyluos
Tags: embedded, opensource, python, luos
Published: 2021-08-16 07:25:30

[Testing the new dev.to video feature]

🎥 Here is a "quick and dirty" video tutorial showing how to install and config Pyluos to use Luos with Python. 🎓 Luos is an open-source project working on "how to bring modularity and flexibility to embedded systems", like @SpaceX, @Tesla, or @Dyson do. Luos is a kind of "Docker" dedicated to embedded systems.
Zuri Internship.
Published: 2021-08-16 07:17:48

The coronavirus pandemic and the Asuu strike nudged me to build myself with a skill. I knew little about web development but thanks to a friend, I started my trip with HTML, CSS, and bootstrap. I am passionate about being a complete stack developer, knowing perfectly well that it might take some time. Unfortunately, my growth has been tethered by resumption and of the bulky studies. I came across the Zuri internship through a friend which I was intrigued by it. Zuri Internship is an 8week program centered on equipping individuals with design operations as well as cutting you through tasks, missions, and similar operations. I take this opportunity as a learning opportunity to improve myself, meet more experienced personnel and become better. It might be a challenge but I hope to have a wonderful experience during this period.

https://www.youtube.com/watch?v=RGOj5yH7evk
https://www.youtube.com/watch?v=jk1T0CdLxwU
https://www.youtube.com/watch?v=pQN-pnXPaVg
https://www.youtube.com/watch?v=W6NZfCO5SIk	

register at 
https://zuri.team https://internship.zuri.team
My HNG Internship Goals
Tags: hng, internship, tech, training
Published: 2021-08-16 02:14:10

Phew! Here We go. Or, Here I go!

My first ever blog post. This is something I have been yearning to do, albeit in the very near future. But now I have to do it, way before I am mentally prepared. Or so I thought,
Thanks to Zuri, the organizers of the HNG internship.

In case you are oblivion to it, the HNG internship is a virtual internship for tech people who want to improve their skills, get better at their chosen track, and know what it means to work as a team, with a deadline in mind. 
You might say, under pressure, trust me you won't be wrong(roll eyes).  This is the 8th cohort, HNG8.

Nevertheless, I am excited to be a part of it, Excited to be writing this. 

## My Goals For The Next 8 Weeks
The cohort would be for 3 months or a little less. But my short term goal, for the next 8 weeks to be precise, is.....to be honest? Don't get thrown out of the internship, lol.

To be realistic, HNG is tough, it's demanding. things are being done at an extremely fast pace and one has to do a lot to keep up. If the 'testimonies' of interns from the past cohorts are to be believed. 

So I think it's reasonable if my goal for the next 8 weeks is to remain in the program. And of course, get to the final phase. 


## A Few Useful Links
And because this post is a task from HNG, we were asked to add a few links too. So......
Here's a link to a Figma beginner's tutorial, it's a [Youtube video](https://www.youtube.com/watch?v=Fcvt9MSUylU&list=PL-XH0r9ri_4xR4hqQ8LJs1sI3M-U-GYLP&index=1).

Here's another link, a Git and Github tutorial from [W3schools](https://www.w3schools.com/git/default.asp). I personally love this one, because it is well explained, easy to follow and you end up doing something real, practical. 
I have a special spot for this because they accepted my pull request. Lol. 

Also, an  HTML tutorial, I started my tech journey with HTML at W3schools so I think it makes sense if I add a link from them. [Wschools HTML tutuorial](too..https://www.w3schools.com/html/default.asp).

And lastly, one on [Python](https://www.programiz.com/python-programming). just because I'm a Python programmer.

## Signing Out
To end my first ever blog post(sincerely elated about this), here's a link to their website https://internship.zuri.team. 

I'll surely do this again, and again. Rinse, repeat!
Edabit challenge 2 | strings | very easy | Return Something to Me!
Tags: javascript, challenge, codenewbie, webdev
Published: 2021-08-16 07:14:32

 Write a function that returns the string "something" joined with a space " " and the given argument a.
 giveMeSomething("is better than nothing") ➞ "something is better than nothing"

 giveMeSomething("Bob Jane") ➞ "something Bob Jane"

 giveMeSomething("something") ➞ "something something"

// solutions
```javascript
// method 1

// with regular
function giveMeSomething(str) {
  return `Something ${str}`;
}

// with arrow
const giveMeSomething = (str) => `something ${str}`;

// method 2

// with regular
function giveMeSomething(str) {
  return "Something " + str;
}

// with arrow
const giveMeSomething= (str) => "something " + str;


// conclusion
// always use template literal to concat a string, since its easier to use, so use the below code

function giveMeSomething(str) {
  return `something ${str}`;
}

// with arrow
const giveMeSomething= (str) => `something ${str}`;
```
How To Use Docker To Generate Let's Encrypt Free Wildcard SSL
Published: 2021-08-16 07:11:39

---
title: How To Use Docker To Generate Let's Encrypt Free Wildcard SSL
published: true
---

First you have to make sure that you are familiar with using unix terminal (if you use Mac you can just play around with default terminal, if you use windows my recommendation is use ubuntu wsl). Also make sure that Docker is installed in your system. You can use Docker for Mac / Docker for Windows / Native Docker installation in Linux.

You should have access to DNS administration access for the domain that you want to generate SSL certificate. I'd recommend you use Cloudflare for DNS administration if you have a domain but the registrar do not give free access to DNS administration. You will need to change TXT record of your domain using this service later.

This is the source code of the shell script that you need to run to generate the ssl:

```sh
#!/bin/sh

docker run -it --rm --name certbot \
    -v "$PWD/letsencrypt:/etc/letsencrypt" \
    certbot/certbot certonly --manual \
    --preferred-challenges=dns \
    -d "*.example.com"
```

Save this shell script with .sh extension (i.e. **run-certbot.sh**) and make sure it is executable (by using chmod +x). Place it in the directory where you want to store your ssl certificate, make sure to remember this directory since it will be used in the future when you want to renew the certificate (the certificate will active for 90 days). Don't forget to change example.com with the domain name that you own. Then just run the script and follow the on screen instructions.

After generating those ssl, you need to change the owner of the letsencrypt folder (folder that has been generated when you run the docker script) to your current user & group so you will have access to the folder. You will need to have elevated privilege to run this chown command (use sudo). Then you can access the certificate in this location:

- **./letsencrypt/live/example.com/fullchain.pem** (if you use nginx this will be used as ssl bundle / ssl_certificate file)
- **./letsencrypt/live/example.com/privkey.pem** (if you use nginx this will be used as private key / ssl_certificate_key file)

Few things to take note:

- Every 3 months, you need to extend your SSL, you have to use same directory or else you will generate new SSL instead.
- Change example.com to your owned domain name and make sure you are ready to add TXT record on that domain. The SSL will be generated after the TXT record has been verified by the certbot.
- Since this is wildcard certificate, this certificate is valid for one level of subdomain so i.e. it will be active for these domains: example.com, www.example.com, dashboard.example.com. But it can't be used for two level subdomain like: auth.dashboard.example.com.
Edabit challenge 1 | strings | very easy | how edabit works? 
Tags: javascript, codenewbie, challenge, webdev
Published: 2021-08-16 07:07:46

 This is an introduction to how challenges on Edabit work. In the Code tab above you'll see a starter function that looks like this:

 function hello() {

 }

 All you have to do is type return "hello edabit.com" between the curly braces { } and then click the Check button. If you did this correctly, the button will turn red and say SUBMIT FINAL. Click it and see what happens.

solutions
```javascript
// solution 1:
function hello() {
  return "hello edabit.com";
}

// solution 2
function hello() {
  let msg = "hello edabit.com";
  return msg;
}

// solution 3
const hello = () => "hello edabit.com";

// conclusion
// 1. always write very less number of code
// 2. use solution 1 or solution 3 to solve this type of problems
```
Design Pattern: Singleton - Probably the easiest explanation!
Tags: programming, php, architecture, beginners
Published: 2021-08-16 07:03:07

### Table of Contents

1. What is Singleton?
2. Implementation.
3. When to Use?
4. An Anti-pattern?

# What is Singleton?

Singleton is a design pattern that falls under the category of creational design patterns. Creational design patterns are associated with the simple creation of objects.

Singleton itself ensures that at any given point during the software's runtime, there should be only one instance of an object. Usually, this object is available to the software, globally.

# Implementation

Before we talk about when to use it, let's quickly implement it and then we can try to understand the nitty-gritty details.

```php
class Database {
  private static $instance;

  private function __construct() {
    // Connect to database
  }

  static function get_instance(): Database {
    if (is_null(self::instance)) {
      self::instance = new self();
    }

    return self::instance;
  }
}
```
If you look at the implementation, you see that the constructor is made private in order to prevent you from creating new instances of the class because database connections in a large system may be expensive.

We use private and static variable `instance` to store the instance of the Database class.

Using the `get_instance` static method, we access the instance of the Database class, if in case the instance does not exist, we make sure that it does and then return the instance of the class.

# When to Use?

Use the singleton pattern only when you need an object to have a single instance throughout your software's runtime. From the example above, you can see that a connection to database is usually required only once.

Any other such expensive operations or global configurations should use singleton but beware that singleton is also called, "An Anti-pattern." It should be almost always be avoided.

# An Anti-pattern?

Singleton is one of the patterns that is easy to understand and use. Thus, it may encourage engineers (at least new ones) to overuse it. It should be used only if there is no alternative solution.

Singleton also encourages the use of global variables. For any engineer to keep track of global variables, it increases cognitive load for them. Such cognitive load may lead to poor software. More on cognitive load and psychology later.

Besides, singleton is more or less, a unique instance of a global variable. It can introduce unnecessary restrictions, make unit tests a pain since they may rely on inheritance among other things.

Some call singleton pattern an "evil pattern." Design patterns in general are agreed upon solutions to commonly recurring problems. Systems may use it when there is a good reason to do so, thus knowing this pattern is essential.
4 packages to generate UUIDs in JavaScript
Tags: node, javascript, codenewbie, programming
Published: 2021-08-16 06:47:06

## Generating UUIDs
UUIDs are Universally Unique Identifiers. They are also known as GUIDs (Globally Unique Identifier). It is basically unique IDs. Below is an example
```javascript
00630208-fe51-11eb-9a03-0242ac130003
```
Let's take a look at 4 different ways to generate UUIDs in JavaScript

## [UUID](https://www.npmjs.com/package/uuid) 11.4k+⭐️
First, we will need to install it 
```bash
npm install uuid
```
Below is the code-snippet to generate an UUID
```javascript
const uuid = require('uuid')

// Generates a version 4 uuid
console.log(
  uuid.v4()
)
// 01a8fc1c-81ff-4337-82af-c4bc64121851

// Generates a version 1 uuid
console.log(
  uuid.v1()
)
// 01a8fc1c-81ff-4337-82af-c4bc64121851
```

## [NanoID](https://www.npmjs.com/package/nanoid) 13.7k+ ⭐️
This is useful to generate URL friendly UUIDS. 
Let's install the package
```bash
npm install nanoid
```
Below is the code snippet
```javascript
const nanoid = require('nanoid')

// Generate a random UUID
console.log(
  nanoid.nanoid(size = 32)
)
// QbM9RUrdJTfQjhRb_lK3oP0hPaqdmoMz

// Generate an uuid using specific characters
console.log(
  nanoid.customAlphabet('abcd#',32)()
)
// b#bdacc#dd#acdcdccacd#bd#bdacddd
```

## [Short-UUID] (https://www.npmjs.com/package/short-uuid) 239 ⭐️
To install the package
```bash
npm install short-uuid
```
Below is the code snippet
```javascript
const shortUUID = require('short-uuid')

// Generate an UUID
console.log(
  shortUUID.generate()
)
// 1B8f2uLpYVj454zycCjLB1

// Generate an UUID using specific characters
console.log(
  shortUUID(
    'b$a#c.*9'
  ).generate()
)
//$9c$.b$*b*#$*$ca$$c##9$c.a9.*9#$a..b*b##c#c
```
 
## [UUIDV4](https://www.npmjs.com/package/uuidv4) 110 ⭐️

Install it
```bash
npm install uuidv4
``` 
Below is the code snippet
```javascript
const uuidv4 = require('uuidv4')

console.log(
  uuidv4.uuid()
)
// 67bf5875-cda6-45a7-bd2b-c5142956b786
```
My HNG Journey
Published: 2021-08-16 06:41:19

Early 2020, i was on micro blogging platform Twitter and i saw a Tech Bro(or let me say 'sis') celebrating her wins, she just got employed by Goggle and she was telling her story of how the journey started, she traced her way back to a particular program called HNG internship(i cant remember the particular cohort), reading through her story i was impressed and wanted to have an amazing story as hers. 


I searched through the web and wanted to get more information about HNG, my search led me to Zuri(https://zuri.team ), i subscribed to their newsletter and i was patiently waiting for the big announcement. On the 7th of August i got a mail from the Program Manager, Zuri Team(Seyi Onifade) and he was inviting me to apply for the Zuri/HNG internship(https://internship.zuri.team)

I applied for the Mobile development track, and i can't wait to use my programming knowledge to start providing solutions. I see this internship as a part of the journey to becoming a world class developer. At the end of this internship, i hope to have achieved the following.
1. Meet with other Developers and learn from them
2. Improve my discipline and ability to work under pressure.
3. Learn programming best practises
4. Meet with mentors and experienced Kotlin programmers.
5. Improve Team work and collaboration
6. Add more projects to my portfolio


Want to use this opportunity to give a Shout out to the Zuri team and HNG internship, this guys are amazing. They are providing world class training at zero cost and the only thing they demand from us is Hard-work. I am grateful for such a wonderful opportunity.

Learning software development is all about having the right tools and learning materials. Below are links to beginners learning resources to get you started on this path to success.

Learn the basic and designing with Figma
https://www.youtube.com/watch?v=c9Wg6Cb_YlU 

Learn how Git work.
https://www.youtube.com/watch?v=dI_CUlVKrFw&list=PLxuUHF3OiqfVlhMh2XaA7gx_NaavKM7C9

Getting started with Kotlin
https://www.youtube.com/watch?v=nzbNC22XWC0&list=PLxuUHF3OiqfUXOtjDM5n06a8NMPFrB-LV

It is often said that “Journey of a thousand miles, starts with a single step”
My first step is this and hope to refer back to this at the end of the internship with goals achieved.