teleren/devto huggingface dataset:
Launching ‘Heroes of Computer Science’
Tags: showdev, projects, newsletters
Published: 2021-05-12 10:01:10

---
title: Launching ‘Heroes of Computer Science’
published: true
date: 2021-05-12 00:00:00 UTC
tags: [showdev, projects, newsletters]
canonical_url: http://blog.gnclmorais.com/heroes-of-computer-science
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ag8bptp6jhylutq68qm.jpeg
---

A few months ago, after learning about the death of [Jean E. Sammet](https://en.wikipedia.org/wiki/Jean_E._Sammet), I realised that there is this huge amount of personalities that pushed the field of Computer Science and that, even though I went through a master’s degree in Computer Engineering, I still didn’t know who most of them were…

This gave me an idea for a project. A short newsletter (with an RSS feed as well, for people with _email fatigue_) that, every fortnight or so, would introduce you to someone that (in some way) propelled Computer Science forward, someone you should know a little about.

This eventually led me to [**Heroes of Computer Science**](heroesofcomputer.science) and I’ve sent three issues so far: [Ada Lovelace](https://www.heroesofcomputer.science/issues/heroes-of-computer-science-issue-1-499264), [Grace Hopper](https://www.heroesofcomputer.science/issues/heroes-of-computer-science-issue-2-567730) and [Alonzo Church](https://www.heroesofcomputer.science/issues/heroes-of-computer-science-issue-3-578033).

I have many more people to go through, but so far, I’m really enjoying discovering about new personalities and re-learning about names I already knew about but not that well.

If you have a suggestion for someone to be spotlighted on this project, let mw know through [this simple form](https://airtable.com/shrzC1ttxMN9cdXFI)! I’d love to get more ideas for future issues. 🤩
How to check if a string is a valid Indian mobile number in JavaScript?
Tags: javascript
Published: 2021-05-12 00:00:00

---
  title: How to check if a string is a valid Indian mobile number in JavaScript?
  published: true
  tags: JavaScript
  date: Wed May 12 2021 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/check-if-string-is-valid-indian-mobile-number-javascript
  cover_image: https://melvingeorge.me/_next/static/images/main-552ff3e52d7e553bdfb883a6e2b31f6e.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/check-if-string-is-valid-indian-mobile-number-javascript)
  
To check if a string is a valid Indian mobile number in JavaScript, we can use a regex expression to match numbers that start with either of number `6`, `7`, `8` or `9` then checks if it has a total of `10` number digits in it.

### TL;DR

```js
// Regular expression to check if string is a Indian mobile number
const regexExp = /^[6-9]\d{9}$/gi;

// String with Indian mobile number
const str = "9207323601";

regexExp.test(str); // true
```

This is the regex expression for matching almost all the test cases for a valid Indian mobile number in JavaScript.

```js
// Regular expression to check if string is a Indian mobile number
const regexExp = /^[6-9]\d{9}$/gi;
```

This will match all the 10 number digits which starts with number `6`, `7`, `8` or `9` and then checks if the remaining numbers are of 9 digits.

Now let's write a string with an Indian mobile number like this,

```js
// Regular expression to check if string is a Indian mobile number
const regexExp = /^[6-9]\d{9}$/gi;

// String with Indian mobile number
const str = "9207323601";
```

Now to test the string, we can use the `test()` method available in the regular expression we defined. It can be done like this,

```js
// Regular expression to check if string is a Indian mobile number
const regexExp = /^[6-9]\d{9}$/gi;

// String with Indian mobile number
const str = "9207323601";

regexExp.test(str); // true
```

- The `test()` method will accept a `string` type as an argument to test for a match.
- The method will return boolean `true` if there is a match using the regular expression and `false` if not.

See the above example live in [JSBin](https://jsbin.com/xidogiquwe/2/edit?js,console).

If you want this as a utility function which you can reuse, here it is,

```js
/* Check if string is a valid indian mobile number */
function checkIfValidIndianMobileNumber(str) {
  // Regular expression to check if string is a Indian mobile number
  const regexExp = /^[6-9]\d{9}$/gi;

  return regexExp.test(str);
}

// Use the function
checkIfValidIndianMobileNumber("9207323601"); // true
checkIfValidIndianMobileNumber("92073236011"); // false
```

That's all! 😃

### Feel free to share if you found this useful 😃.

---
5/11 TIL: JWT, fetch
Tags: todayilearned
Published: 2021-05-11 23:53:11

- JWT
    - guarantees data ownership but not encryption (serialized, not encrypted)
    - [https://blog.logrocket.com/jwt-authentication-best-practices/](https://blog.logrocket.com/jwt-authentication-best-practices/)
- Why not to use JWT and instead use session
    - JWT is just blobs of JSON that have been cryptographically signed; claims are the JSON data inside the JWT
    - JWTs are larger (in bytes), require CPU to compute cryptographic signatures, and you are going to hit the database anyway (for manipulating user data/account)
    - instead of storing a user ID inside of a JWT, then storing a JWT inside a cookie, store the user ID directly inside of the cookie and cache your sssion in a backend like memcached or redis
    - [https://developer.okta.com/blog/2017/08/17/why-jwts-suck-as-session-tokens](https://developer.okta.com/blog/2017/08/17/why-jwts-suck-as-session-tokens)
- fetch credentials: 'include'
    - CORS prevents Cross-Site Request Forgery (CSRF): an attack that forces an end user to execute unwanted actions on a web app
    - setting credentials: 'include' means to send user credentials (cookies, http auth, etc) even for cross-origin calls (by default it is only shared across the same origin)
    - [https://javascript.plainenglish.io/understanding-the-basics-to-fetch-credentials-863b25968ed5](https://javascript.plainenglish.io/understanding-the-basics-to-fetch-credentials-863b25968ed5)
- more about fetch:
    - [https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch)
- preflight request: a small request that is sent by the browser before the actual request. it contains information like which HTTP method is used, and any custom HTTP headers. Do not send credentials in here.
I can't get used to Reselect in React / Redux
Tags: reselect, react, redux, discuss
Published: 2021-05-11 23:49:48

I didn't use Reselect before, and got in the new job. This new project uses `reselect` and I am somewhat puzzled.  It even has the memoized `createSelector()`.  But the manager pretty much hope we finish 1 Jira ticket per day, if not multiple Jira tickets per day, on our first work day after onboarding... so I am overwhelmed... and no, the manager will not take explanation.
I Made a Free-to-Play Games Database API
Tags: showdev, api, webdev
Published: 2021-05-11 23:14:33

Hello everyone, I'm excited to share my Free-To-Play Games Database API (aka [FreeToGame](https://www.freetogame.com/) API)! Everyone can access the API directly for free at [https://www.freetogame.com/api-doc](https://www.freetogame.com/api-doc) (no keys required).

Still work in progress but I hope to improve the API over time. What do you guys think? Feedback is welcome!

###About
[FreeToGame](https://www.freetogame.com/) is a gaming platform that brings all the best Free-to-Play Multiplayer Games and MMO Games into one place while rewarding gamers with free premium loot and exclusive perks.
Instagram RESTful API Clone
Tags: node, javascript, 100daysofcode, express
Published: 2021-05-11 23:12:01

Instagram RESTful API clone made with Node Js & Express Js

REST API with all basic features real Instagram has.

Repo : https://github.com/saidMounaim/instagram-api

Check My #100DaysOfCode Challenge
https://github.com/saidMounaim/100DaysOfCode
7 Statistics That Show Why Data Security Matters
Tags: security
Published: 2021-05-11 23:01:31

#### Data security is a moving target. Understanding these statistics can help you get it right.
## <br>

According to the 2020 edition of the [IBM/Ponemon Institute Cost of a Data Breach Report](https://www.ibm.com/security/digital-assets/cost-data-breach-report/#/), 80% of businesses polled report that customer personally identifiable information (PII) was compromised. At an average cost of $150 per record, this is the most costly data type in the report.  But all data breaches are expensive, both in terms of lost data and in the hit to an organization’s brand reputation.

Numbers are hard to argue with, so we compiled the following seven statistics that show the power of having good data security plans in place in case your business is hit with a breach. Each entry includes the business impact and mitigation techniques you can employ to limit losses should the worst happen.

![Data Security 01](https://images.ctfassets.net/23aumh6u8s0i/5nBOWvv3hx8ld4iXIwnnPy/2fa02bc0e0e349a9f63c68d3a7f1d662/01_B.jpg)

1. Malicious attackers cause 52% of data breaches.
2. Hacking techniques are used in 45% of breaches.
3. Reported cybersecurity breaches are up 300% since the beginning of the COVID-19 pandemic.
4. Lost business revenue alone accounts for nearly half of the financial impact of a data breach at an avg. of $1.5 million.
5. Internal actors are involved in 30% of breaches.


[Read more...](https://auth0.com/blog/7-statistics-that-show-why-data-security-matters/?utm_source=content_synd&utm_medium=sc&utm_campaign=security)
Building the Front-End for SoPlugged (a platform for Black-owned businesses)
Tags: nextjs, javascript
Published: 2021-05-11 22:41:30

Hello! Brief introduction: I'm Benaiah, an Ottawa-based Full-Stack developer. Nice to meet you!

TL;DR: I did some freelance work for SoPlugged (a platform to find black-owned businesses in Canada). Check it out [`here`](https://www.soplugged.com).

I wanted to document how I built this platform, and what tools I used.

##Front-end Library
[`React`](https://reactjs.org/), easy! Being very conversant with React, and enjoying the benefits of easy state management made this an easy choice.
However, when the all-too-familiar [issue of SEO](https://blog.logrocket.com/how-next-js-can-help-improve-seo/) came up, especially for the landing page, I made the executive decision to migrate to [`Next JS`](https://nextjs.org/) (a.k.a Server-side React).

##Styling
Again, for this, choosing what I was familiar with was key. And, that was [`Material-UI`](https://material-ui.com/). I've been using Material UI for a while now, primarily because of the components they provide 'ready-made'. I was a little worried about performance based on certain articles I had come across, but we'll discuss this in a subsequent article.

##Back-end
I didn't have to handle this. A Ruby developer created the API and database using Rails.

##Search Functionality
[`ALGOLIA`](https://www.algolia.com/).
Front-end search can easily be implemented by adding an input and querying your database on every keystroke, or when the user stops typing (to reduce how many times you'd have to hit the database).
This is what I started off with, till I came across Algolia.
Simply put, Algolia is VERY good when it comes to search. When configured, it routinely indexes your database to get all new information, so searches are hitting Algolia instead of your database directly. This results in a faster and more-efficient search experience.
You also get ready-made and easily customizable widgets for your front-end.

##Form Handling
Forms are a critical aspect of a user's experience on a website, and so, should be properly created and easily navigated by the user. 
I usually opt for [`react-hook-form`](https://react-hook-form.com/api) to properly handle form validation (however complex), displaying error messages and handling other events.
But, I had to switch to [`Formik`](https://formik.org/) when I decided to create a multi-step format. Simply because of the limitations I ran into when managing the form's context, and accessing certain methods from child components.
It is possible with React Hook Forms, but much easier with Formik.


-------------------------------------------------------------
These are the major building blocks of the SoPlugged website. Feel free to leave a comment if you have any further questions.

Till next time!
Day 364 : Gas station
Tags: hiphop, code, coding, lifelongdev
Published: 2021-05-11 22:02:49

_liner notes_:
- Professional : Meetings and laptop issues. Pretty much my day. haha Had an all hands meeting that went for a while. A lot of things are happening. Then had another team meeting and my laptop wasn't having any of that. haha Had to use my phone to do the meeting. Maybe I need to delete files. I deleted the screen recordings I made for the video tutorial. Emptied the trash can and it took a while to empty. It said it deleted like 450,000 files! haha Thinking about it, not sure if I ever cleaned out the trash before, but 450,000?! Maybe they were node module folders? haha Not even sure if that helped because Slack was still not opening properly. Had a couple of other meetings. At least the laptop could handle those. Then got added to another Slack channel for a project I'm working on. Couldn't see the channel because again, Slack wasn't opening. haha Restarted a couple of times and finally got in. Spoke with some folks, got some questions answered. Really helpful folks.

- Personal : Last night, worked on my side project. Took way too long to figure out how to pullin an svg file, put it in the background and add opacity, but the opacity couldn't affect the other elements. Positioned some other elements. Made a little progress. Went on to listen to tracks for this week's radio show and then went to sleep.

![An extremely large orange land mass sticking out of the plains in Uluru, Australia](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8efkesn5o9skgim98oip.jpg)

So I went to fill up my van with gas, even though I haven't driven in like a month because a corrupt gas company got their old archaic system hacked. This is the same company whose gas pipeline leaked like last year and caused the 2nd worst leak in a century or something. The leak wasn't even discovered by them or their systems, it was 2 teenagers on motor bikes. Did they clean up the mess they made? Nope, just bought some houses in the area Amazing. So yeah, people of these idiots and corrupt politicians who let them continue to be idiots, there may be a gas shortage which will raise the gas prices. Went to the gas station and there weren't any lines, but it looked like the pumps were getting busier. Going to work on my side project some more. I want to finish up some text and work on the push notification functionality. Maybe go through more tracks, watch an episode of "Yasuke" (missed it last night) and go to bed.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube eTBKoO87L88 %}
Constants, Variables and Data types in C
Published: 2021-05-11 11:36:50

#CONSTANTS
A data item whose value cannot change during the program’s execution.
There are 4 types of constants in C.
1.Integer constants:
An integer constant is an integer quantity which contains a sequence of digits. It should not have a decimal point. Blanks and commas are not allowed within an integer constant. An integer constant can be either +ve or -ve. The constant must lie within the range of the declared data type (including qualifiers long, short etc.).
>Example of valid integer constants:- 976    8987   5   -25  etc.
>Example of invalid integer constants:- 78.43   7-8   89,76  etc.
2.Character constants:
A character constant is a character which is enclosed in single quotes. A character constant is of size 1byte and can contain only 1 character. A character can be an alphabet like a,b,A,C etc or a special character like &,^, $, #,@ etc or a single digit from 0 through 9. It can also be an escape sequence character like space ‘ ‘ or a null character ‘\o’  or  a new line ‘\n’  etc.
>Example: ‘A’       ‘a’     ‘ b’      ‘8’     ‘#’  etc.
3.Real/Floating point constants
They are also known as real constants. A real constant contains a decimal point or an exponent. It can be either +ve or -ve. Commas and blank space are not allowed within a real constant.
>Examples:– 254.175,  -16.47      -0.5e-7     +4.1e8
4.String constants:
A string constant is a collection of characters enclosed in double quotations “”.It may contain alphabets, digits, special characters and blank space.
>Example:-   “Circuits Today123”

#VARIABLES
A variable is a data name that may be used to store a data value. >Eg: name, roll no.
Basically, a variable used to store some form of data. Different types of variables require different amounts of memory and have some specific set of operations which can be applied to them.
Variable Declaration:
A typical variable declaration is of the form:
type variable_name;
or 
for multiple variables:
type variable1_name, variable2_name, variable3_name;
A variable name can consist of alphabets (both upper and lower case), numbers and the underscore ‘_’ character. However, the name must not start with a number.

#DATA TYPES
There are 4 data types in C language. 
They are:-int
          char
          float
          double
-->int – This data type is used to define an integer number. A single integer occupies 2 bytes. 
Format Specifier:- %d 
Date Range : 0 to 255
-->char – Used to define characters. A single character occupy 1 byte. 
Format Specifier:- %c
Date Range : -128 to +127
-->float – Used to define floating point numbers (single precision). Occupies 4 bytes. 
Format Specifier:- %f
Date Range: -3.4e38 to +3.4e38
-->double – Used for double precision floating point numbers(double precision).Occupies 8 bytes. 
Format Specifier:-%lf
Date Range : -1.7e38 to +1.7e38
*Primitive data types are the first form – the basic data types (int, char, float, double).
*Derived data types are a derivative of primitive data types known as arrays, pointer and function.
*User defined data types are those data types which are defined by the user/programmer himself.
Instagram Clone with Vue.js 1/3
Tags: vue, javascript, scss
Published: 2021-05-11 21:42:04

## TODOS

- [x] The difference between Vue and React. Project setup with vue-cli
- [x] CSS infrastructure and typography. preparing the icons in the project (svg)
- Let's create [x] pages. Let's create a Master-Page
- [x] Let's create layout for Header design and Homepage
- [x] Vercel.com deploy configuration for hosting projects
- [x] Post component in Homepage
- [ ] Api and infinite-scroll for homepage
- [ ] Stories area on homepage
- [ ] API and implementation for Post Comment
- [ ] Options modal component and animation usage
- [ ] Api and layout design for Discover page
- Implementing [] post modal component and discover page
- [ ] Route setting for profile page and tabs.

https://github.com/cihat/instagram-clone
https://cihat.github.io/instagram-clone/
V.0.8
Published: 2021-05-11 21:38:00

**La secte mais en meilleurs !**
1. modification des skins des npc
2. modification des quêtes

nous vous invitons a enquêter ! cette secte a bien des choses a cacher !

**StoryMode chapitre 1**

Désormais suivez des histoires palpitante ! Aider des habitants et comprenez le lore de notre beaux monde !

DISPONIBLE LE 01/06/2021 soyez patient, vous serez récompensé !

**Journaliste**

Devenez journaliste gagner de l'argent a chaque poste ! 

CANDIDATURE DANS LES MPS DE MYDEVZONE !
Setting up a .NET service on Linux
Tags: dotnet, linux
Published: 2021-05-11 20:58:23

This is another "I don't want to have to google this anymore" kind of post.

Quick sidenotes:

- I use .NET 5
- I didn't create the example *.service* file; I couldn't find the original author, as it probably was from Stack Overflow, but this is the file I use on my VPS.
- This completely doesn't cover setting up nginx or writing actual code - just creates a service which runs your .NET app

### Create .service file

My *.service* files are stored in **/etc/systemd/system/**

Sample *.service* file:

```bash
[Unit]
Description=Sample Description

[Service]
# systemd will run this executable to start the service, has to be specific file
ExecStart=/srv/AppDir/AppExecutable

# to query logs using journalctl, set a logical name here
SysLogIdentifier=SampleName

# use your username to keep things simple
#make use user you chose has the correct permissions to run the app
User=username

#this environment variable is neccessary when dotnet isn't loadeed for the specified user. 
#to figure out this variable, run 'env | grep DOTNET_ROOT' when dotnet has been loaded into your shell
#Environment="DOTNET_ROOT=/opt/rh/rh-dotnet31/root/usr/lib64/dotnet"

[Install]
WantedBy=multi-user.target
```

- Description - this will be shown as a description when you run systemctl status ServiceName.service, useful in order to identify the service
- ExecStart - This has to be a direct path to the executable file of your app. Make sure you made it executable using **chmod +x**!
- SysLogIdentifier - Name of the app used in syslog - again, useful to identify your app later
- User - Username of the user who "runs" the app. Preferably use your own, but you can use any as long as specified user has the correct permissions

### Register the service

1. First, check if systemctl command properly sees your .service file:

    ```bash
    sudo systemctl status ServiceName.service
    ```

2. If results seems okay (Description is shown, and it seems like everything is okay), start your service

    ```bash
    sudo systemctl start ServiceName.service
    ```

Aaand that's it! From this point on, you just have to make sure your code is good, and test if your app works!

Have a great day ;)
Mock static methods with Mockito - Java Unit Testing
Published: 2021-05-11 20:46:52

One of the most frustrating element when I am doing the Unit tests in Java is to not be able to mock static methods. 

Sure, during a long time we got PowerMock. But, since JUnit5, PowerMock wasn't compatible and we were unable to continue with it.

---

But now, we have this feature included in Mockito! 

## Dependencies
First, you have to add the **mockito-inline** library. *(You can use any version up to 3.4.0)*

*Here is an exemple with Maven*
```xml
<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-inline</artifactId>
    <version>3.9.0</version>
    <scope>test</scope>
</dependency>
```


---

## Writing test

To mock a static method, you have to create a **mockStatic** of the class with the static method, and declare the event you want to apply to your mock.

*example*
```java
@Test
public void test() {

try (MockedStatic<LoggerFactory> loggerFactoryMock = Mockito.mockStatic(LoggerFactory.class)) {
            loggerFactoryMock.when(() -> LoggerFactory.getLogger(any(Class.class))).thenReturn(loggerMock);

...
            verify(loggerMock, times(1)).error("Err message test");
...
        }
    }
```

Then, you just have to run your tests!

---

I hope it will help you!