teleren/devto huggingface dataset:
parseInt() For Beginners
Tags: javascript, beginners
Published: 2022-07-14 02:36:50


This is for anyone that's newly immersing themselves in the world of coding. If you are a beginner-level coder like me, you've looked into `parseInt()` and became completely lost when it came to the "radix" part. Here is my simplest explanation of what the function `parseInt` does. 

## What is `parseInt`?
`parseInt` is a function that can take 2 arguments and it can either return an integer or a NaN (not a number). 

This is the syntax:

``parseInt(string)``
or 
``parseInt(string, radix)``


Assuming you know all the different data types, for example: 

1. numbers
2. strings
3. booleans
4. symbols
5. objects
6. null
7. undefined

Then you already know that JavaScript will perform addition to a _number_ data type. 

```
1 + 2 + 3;
//6
```

Adding a _string_ to a _number_, Javascript will pair them together and will return a _string_. It cannot perform addition.

```
'1' + 2 + 3
// '123'
```

Now consider this example:


![before parseInt](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fugpmwzxavu3n2vsa0m8.png)
What's happening above is JavaScript does not see '5' as a number but as a _string_. We're asking the _string_ to add 1 but instead of creating a new value, it will add the 1 next to the _string_. If your goal is to convert a _string_ into a _number_, that's when you'd use `parseInt`.
![parseInt function](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bxfassoenvtte0ltd16m.png)

`parseInt` will remove the quotes from the string before performing the addition or any form of operation. Thus resulting in a whole integer. 
If ever you need a floating integer (a number with a decimal) to convert into a whole number, `parseInt` can arrange that for you as well. 

```
const num = 10.03
console.log(parseInt(num));

//  10
```


## `parseInt(string, radix)`

Traditionally, `parseInt` should take 2 arguments. The function parses (analyzes) a string and returns an integer of the specified radix. 
######What is a radix?
A radix is the base in mathematical numeral systems. When using `parseInt`, you will want to work with the base 10  because it uses the ten digits from 0 through 9. This is called the decimal system. 

```
parseInt("4", 10)
// 4

parseInt("4.444", 10)
// 4

parseInt("Jerry is 9", 10)
// NaN

```
The last thing you need to know is **NaN**. This function can only read the first value starting the string. If it's not a number, it will return as **NaN**.

_Source_:
“Radix.” Wikipedia, Wikimedia Foundation, 23 June 2022, https://en.wikipedia.org/wiki/Radix. 

“Parseint() - Javascript: MDN.” JavaScript | MDN, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt.
Poll 1 : Favorite social media platform ?
Tags: discuss, community, poll
Published: 2022-07-14 01:52:45


## Which social media platform you like most as a Developer ?

1. Twitter
2. YouTube
3. Reddit
4. Other (Comment Down 👇)

Click here 👇 to answer and comment below 🤔 why you think so ❓

[![Poll of the Week](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j93zhjr9hnupdc8dncsj.png)](https://twitter.com/heydrdev/status/1546066015422976000)

---

Let's connect together 🤝, post your favorite dev article and tag me on twitter. I will retweet and give you my honest opinion 😇

[![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hi9jmkirwc9g9ppwbc1o.png)](https://twitter.com/heydrdev)
Today i found out : optional typescript function props
Tags: typescript, react, javascript, programming
Published: 2022-07-14 01:32:58

While writing a custom table component for react i ran into an interesting issue .

The table takes in props like and array of objects that define the header and column of the table and an array of objects for the rows , with those props the component is able to render a table . 

But the point of writing a custom table is to add features not available in a regular html table , so i needed to pass in functions to handle the editing which are optional since they'd only need to be used when the table is in edit mode

Normally in typescript when you have a possibly undefined variable yon can use

```ts
interface Types{
person?:{name: string , age: number}
}


const age = person?.age
```
&nbsp;

This helps you avoid the cannot access .age of undefined error that normally breaks your code. This implementation won't try to access the variable if it's undefined 

&nbsp;

Something like that exists for functions enabling you to have possibly undefined functions without the function cannot be undefined error 

```ts
interface Types{
person?:{name: string , age: number}

sayHello?:(name: string)=>void
}
// Then execute the function like this

sayHello.?(person?.name)
```


check out the table at [repo](https://github.com/tigawanna/table-for-react)
Semver: The unknown buildMetadata
Tags: discuss, npm, semver, versioning
Published: 2022-07-14 01:30:39

I was reading [semver's spec](https://semver.org/) and I noticed something weird in the regex:

![Screenshot of semver spec saying "And one with numbered capture groups instead (so cg1 = major, cg2 = minor, cg3 = patch, cg4 = prerelease and cg5 = buildmetadata)"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dyn2hb56xwjex3cyd6hr.png)
 
This is the 1st time that I ever encountered the mention of `buildmetadata`.

### Let's deconstruct that a bit

When you read the regex, it mentions at the beginning the required `major`, `minor`, and `patch`: a valid semver version needs to be at least `MAJOR.MINOR.PATCH`, for instance `1.2.3`.

Then the version can contain an option `prerelease` tag starting with a **`-`**, for instance `1.2.3-hello` and this prelease tag can be anything made of alpha numerics (0-9 or a-z or A-Z), `.` and `-`.

But what surprised me is the last one: the `buildmetadata` prefixed with a **`+`** (same thing as the prerelease so any alpha numerics, or `.`, or `-`).
So for instance `1.2.3+build` is valid, and so is `1.2.3-beta.1+build.linux`

### Verification

Just to be sure, I run this in runkit, and indeed it can properly parse `1.2.3-pre.release.4+build.meta.5.6` as:

```json5
{
  major: 1,
  minor: 2,
  patch: 3,
  prerelease: ["pre", "release", 4], // here 4 is even a number
  build: ["build", "meta", "5", "6"], // but here 5 and 6 are strings
  version: "1.2.3-pre.release.4",
  raw: "1.2.3-pre.release.4+build.meta.5.6"
}
```

See for yourselves:

![semver properly parses `1.2.3-pre.release.4.5+build.meta.6.7`](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/niejqzhlppdlxyaj1tez.png)
 
### Discussion

I've seen plenty of times the prerelease being used (and I used it myself a few times too).

For instance, React uses it a lot:

![Sample of React versions on NPM with a lot of prereleases](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p00o9cthqgf0s4dlhymu.png)

My topic for a conversation with you is: Have you ever seen this used anywhere on NPM (or else where)? And if so, for what purpose?
Next.js（TypeScript）のプロジェクト作成 ESLint+Prettier（＠2022-06-29）
Tags: nextjs, eslint, prettier
Published: 2022-07-14 01:24:46

ちょっと色々変わってないか確認がてらプロジェクトの作成をまとめなおします。  
この辺は気がついたら推奨設定が変わってたりするのでちょいちょい見直したいところです。

## プロジェクトの作成
nodeがインストールされた環境を想定しています。まずはプロジェクトを作成しておきます。

```
npx create-next-app [プロジェクト名] --typescript
```

必要最低限は上記のコマンドで準備されます。
個人的に頻繁に触りそうなファイル群は`src`というディレクトリにいれときたいので、`pages`、`styles`は`src`というディレクトリを作成して入れておきます。
Next.jsではデフォルトで`src`というディレクトリが存在すればそちらを`pages`が含まれているディレクトリとして認識してくれるので、これで動作します。
とはいえ、絶対パスに"@"を利用したい（いちいちパスを記載するのが面倒）ので、`tsconfig.json`に`baseUrl`の設定を追加します。

```json
    "incremental": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    }
```

これで相対パスを省略して記載できます。  
一応動作を確認しておきたいので、`src/pages/index.tsx`の4行目を下記のように変更してみます。

```typescript
import styles from '@/styles/Home.module.css'
```

動作チェックです。

```
yarn dev
```

問題無く表示されればOKです。

### Voltaでnodeとyarnのバージョン固定
自分はnodeのバージョン管理にVoltaを利用しています。  
ある程度よしなにしてくれるのでほっといてもいい気はしますが、トラブルに巻き込まれた際に面倒になるのでnodeとyarnのバージョンをプロジェクトで固定しておきます。

```
volta pin node@16
volta pin yarn@1.22
```

## ESLint+Prettier
### ESLint
create-next-appで作成していれば必要最低限の準備は既に出来ています。
試しに、`.eslintrc.json`を次のように書き換えて、セミコロンの警告を出します。
```
{
  "extends": "next/core-web-vitals",
  "rules": {
    "semi": ["error", "never", {"beforeStatementContinuationChars": "never"}],
    "semi-spacing": ["error", {"after": true, "before": false}],
    "semi-style": ["error", "first"],
    "no-extra-semi": "error",
    "no-unexpected-multiline": "error",
    "no-unreachable": "error"
  }
}
```
index.tsxなどのどこかにセミコロンを記入して
```
yarn lint
```
すると警告が表示されると思います。
この時点で
```
yarn lint --fix
```
で修正まで入るようになります。

### Prettier
整形は例にならってPrettierで行います。よって、先ほど追加したセミコロンのルールは削除してしまって構いません。（ESLint -> Prettierの順番で実行しようと考えているのでどうせ上書きされる）
PrettierとESLintのプラグインをインストールしておきます。
```
yarn add -D -E prettier
yarn add -D eslint-config-prettier
```

`eslint-config-prettier`の設定を適応させるために、`.eslintrc.json`を書き換えておきます。

```
{
  "extends": ["next/core-web-vitals", "prettier"],
  "rules": {
    "semi": ["error", "never", {"beforeStatementContinuationChars": "never"}],
    "semi-spacing": ["error", {"after": true, "before": false}],
    "semi-style": ["error", "first"],
    "no-extra-semi": "error",
    "no-unexpected-multiline": "error",
    "no-unreachable": "error"
  }
}
```

`package.json`に書いてもいいんですが、既に`.eslintrc.json`も生成されてますので、`.prettierrc.json`を作成してそこにPrettierの設定を書いておきます。
とりあえず自分の必要最低限のモノだけ書いています。
```
{
  "trailingComma": "all",
  "tabWidth": 2,
  "semi": false,
  "singleQuote": true,
  "jsxSingleQuote": true
}
```
Prettierでプロジェクト全体を整形したい場合用に、`package.json`の`scripts`に`format`というコマンドを追加しておきます。
```
    "format": "prettier --write ./**/*.{js,jsx,ts,tsx,json,css} --ignore-path .gitignore"
```

とりあえず上記までで
```
yarn lint --fix
yarn format
```
で全体を解析＋フォーマットできるようになりました。
ここから先はお好みで、ローカルで解析やテストを回すなら「husky+lint-staged」、コミット先でやるなら「Github ActionsでESLint+Prettier+テスト」という構成などが考えられると思います。


## 参考
https://qiita.com/mysticatea/items/9da94240f29ea516ae87
Creating an online blog with NextJS, Sanity, and Vercel
Tags: nextjs, tutorial, react
Published: 2022-07-14 00:21:43

I recently came across **Sanity**, a CMS that seems to have a lot of potential. Except for 1 problem, it's updating to **v3**, at the moment, which breaks everything and turns old guides obsolete.

I stumbled through forums and docs to try and figure it out myself so why not document what I found?

The styling will be minimalistic (_styled components_) and the content will be sparse because I'm more focused on showcasing how to get a project like this up an running.

## In the end you will have a...

- Homepage that will display all of the blog posts.

- Template page to display an individual post when clicked

- Link to Sanity Studio so you can create your posts

- Blog hosted on your own Vercel domain


## There are a few problems that will arise with trying to use v3 of Sanity.

- There is no current way (that I know of) to redeploy your Vercel site when you create a new post, you have to do this manually

- There are only a few plugins that currently work with v3, so options are limited

So because of this, I wouldn't recommend building anything large with this yet. But when v3 is fully released and stable (with better plugin support), you will already know how to get started.

**Let's get started.**
Static methods and member variables
Tags: java, beginners, programming
Published: 2022-07-14 00:13:23

_**What are parameters for?**_
Before we get to the meaning of parameter, let's start by talking about methods.

A method is a collection of instructions, also known as a block of code, which is designed to perform tasks and operations. In order for us to make the method execute these instructions, it is necessary to pass the necessary information for the method's action to take place. This necessary information is captured through parameters.

In technology, we can say that parameters are the characteristics that the user adds. By defining a parameter we also specify the way in which it can be used.

It is worth paying attention to the difference between parameters and arguments, where parameter is the variable that will receive a value in a method while an argument is the value.


_**Some points to differentiate parameters and arguments**_
**Parameters**
- Are defined in the method declaration (signature);
- They receive arguments;
- A tip to avoid confusion is to think of the "P" for parameter is like the "P" in Placeholder, which is for a Potential value.


**Arguments**
- They represent the current values/variables passed to the parameters of the function when it is called;
- Each argument corresponds to one parameter (position);
- Tip: Argument = current value.



_**What is the difference between formal parameters and actual parameters?**_
Still talking about parameters, we have these two types, which are formal parameters and actual parameters. The main difference between them is how they are executed where:

We can say that actual parameters are those values that we pass to the method when it is called.

Formal parameters, on the other hand, are the variables defined by the method that are given values when the method is called.


**Reference**
Oracle. (n.d.). Defining Methods (The JavaTM Tutorials > Learning the Java Language > Classes and Objects). Docs Oracle. Retrieved July 5, 2022, from Java documentation
Control structures
Tags: java, programming, beginners, discuss
Published: 2022-07-14 00:06:36

Lets talk about the advantages and disadvantages of each looping structure...

I could be wrong, but I wouldn't use the word "disadvantage" in concepts like loops. We have different types because they can all work in different cases, but sometimes they are not suitable for it. So it is important to have a lot of knowledge of this concept because it makes it easier for us to understand, simplifies the code, and becomes a more fluid program.

Now, citing advantages of loops:


`while`: will repeat the proposed block of code, until the condition is true

`do`-`while`: will do something while a condition is true. I see people calling it a "control repeat structure"

`for`: already in this loop, we have a repetition structure with iteration, where we iterate a defined value in each repetition, reaching a limit.

I confess that I always get confused with repeat structures and, sometimes, with conditionals. But they are very important concepts, as I mentioned before.

What are your thoughts?
Syntax error x semantics error
Tags: java, beginners, programming, discuss
Published: 2022-07-14 00:00:08

If we stop and look around, we will notice that languages (in general) have rules.

In the English language, if we want to be good speakers, we must be good at grammatical rules. When we think about coding, when we want to create a utile program, we must follow the "rules" of the programming languages to see it work.

Syntax and semantics are to programming languages as grammar rules are to languages.


**Syntax of a programming language**
In the software development world, we can apply our logical understanding anywhere, but not syntaxes of programming languages. Why? Because each one has its particularities. In other words, syntax is one of the "rules" of programming languages that we have to follow.

For example, when we see that Java requires semicolons after statements, this is part of the Java syntax.

If we do not align the syntax of our program to the programming language, our program will not run. Here is where we see the importance of following rules.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7bamwd4p7vffx8d9rm7h.jpeg)


**The semantics of a programming language**
In a dictionary, one of the definitions of semantics is:
"The study or science of meaning in language." In other words: study, signs, and interpretation of words. In the end, it helps to understand, to comprehend (and a little more) clearly.
Semantics works to describe structures in a programming language. We have to write our program in the correct format to run the program.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q3yfh24ix7elxvwqgxow.jpeg)

How would you simplify this concept?

**Reference**

semantics. (n.d.) American Heritage® Dictionary of the English Language, Fifth Edition. (2011). Retrieved June 18 2022 from The Free Dictionary.
#JulyOT 14: AMA: IoT, cows, AI and poop - Jim discusses IoT in farming with Bryn Lewis
Tags: julyot, iot, ai, edge
Published: 2022-07-14 02:00:48

---
title: #JulyOT 14: AMA: IoT, cows, AI and poop - Jim discusses IoT in farming with Bryn Lewis
published: true
date: 2022-07-14 00:00:00 UTC
tags: julyot,iot,ai,edge
canonical_url: https://JulyOT.dev/blog/14-iot-cow
series: JulyOT 2022
cover_image: https://JulyOT.dev/assets/images/JulyOT-banner-14-iot-cow-2128acc83e23e4a5d01496834a83428a.png
---

_Join in the conversation and ask out IoT experts about digital agriculture._

## AMA: IoT, cows, AI and 💩 - Jim discusses IoT in farming with Bryn Lewis[​](#ama-iot-cows-ai-and----jim-discusses-iot-in-farming-with-bryn-lewis "Direct link to heading")

Digital agriculture is a massively important use case for IoT. From simple solutions monitoring soil moisture levels to control watering, to complex AI solutions for animal health, IoT is helping farmers bring food to the tables of the growing world.

In this session, Jim is joined by Bryn Lewis, a Microsoft MVP and IoT expert who is working with farms in New Zealand to implement solutions using AI and IoT. Jim and Bryn will dive into some of the cool projects that Bryn is working on, discussing how AI and IoT can improve cow health, make milking easier, and even reduce water usage for cleanup, all within a hostile environment with wide temperature variances throughout the year, and way too much poop.

Join us for this AMA style conversation, and bring your own questions on digital agriculture to get answered by our Kiwi expert.

Register to watch this event live at 3pm PT on Tuesday July 19th, or catch the recording!

[![AMA - Ask Me Anything at Reactor: Azure IoT, Thursday July 14th, 9am Pacific Time](https://www.meetup.com/_next/image/?url=https%3A%2F%2Fsecure-content.meetupstatic.com%2Fimages%2Fclassic-events%2F505401361%2F676x380.webp&w=3840&q=75)](https://www.meetup.com/microsoft-reactor-redmond/events/287072771/) 

[Register on MeetUp](https://www.meetup.com/microsoft-reactor-redmond/events/287072771)

[Watch on YouTube](https://www.youtube.com/watch?v=EkCygi4o2rM)
SSO and MFA for Oracle JD Edwards (JDE) via Datawiza | Microsoft 365, Azure AD, Okta, Duo...
Tags: azure, cybersecurity, oracle, jde
Published: 2022-07-13 23:52:04

https://youtu.be/xJiBe2lVAEA


Setup Datawiza to enable SSO and MFA for users to login to Oracle JD Edwards (JDE) in minutes! Datawiza integrates with any identity provider and MFA service, like Microsoft 365, Azure AD, Cisco Duo, Okta, AWS, Google, Auth0, Ping, ForgeRock, OneLogin, ADFS. 

Follow these step-by-step instructions to configure Azure AD Single Sign-on (SSO) and MFA for Oracle JDE. 

For more information, visit: https://www.datawiza.com/enable-sso-mfa-for-oracle-jd-edwards-jde-in-minutes/

You can try our freemium service here: https://console.datawiza.com.

Join our discord server: https://discord.com/invite/Sn3nbc83Up. Or contact us directly: support@datawiza.com.
Python: logging in colour
Tags: python, pip, cmd, log
Published: 2022-07-13 23:44:01

If you use logging module, you should use helpful module for coloured command line.

https://pypi.org/project/coloredlogs/

Install:
```
pip install coloredlogs
```

It's really easy-to-use:

```python
import coloredlogs, logging

# Create a logger object.
logger = logging.getLogger(__name__)

# By default the install() function installs a handler on the root logger,
# this means that log messages from your code and log messages from the
# libraries that you use will all show up on the terminal.
coloredlogs.install(level='DEBUG')

# If you don't want to see log messages from libraries, you can pass a
# specific logger object to the install() function. In this case only log
# messages originating from that logger will show up on the terminal.
coloredlogs.install(level='DEBUG', logger=logger)

# Some examples.
logger.debug("this is a debugging message")
logger.info("this is an informational message")
logger.warning("this is a warning message")
logger.error("this is an error message")
logger.critical("this is a critical message")
```

That's all ;-)
Event Choreography for Loosely Coupled Business Processes
Tags: architecture, microservices, api, eventdriven
Published: 2022-07-13 23:27:00

What's Event Choreography? Let's back up a bit to answer that. Event Driven Architecture is a way to make your system more extensible and loosely coupled. Using events as a way to communicate between service boundaries. But how do you handle long-running business processes and workflows that involve multiple services? Using RPC is going back to tight coupling, which we're trying to avoid with Event Driven Architecture. So what's a solution? Event Choreography

{% embed https://www.youtube.com/watch?v=TA12e2ZJcGg %}

## Join!

Developer-level members of my [YouTube channel](https://www.youtube.com/channel/UC3RKA4vunFAfrfxiJhPEplw/join) or [Patreon](https://www.patreon.com/codeopinion) get access to a private Discord server to chat with other developers about Software Architecture and Design as well as access to source code for any working demo application that I post on my blog or YouTube. Check out the [YouTube Membership](https://www.youtube.com/channel/UC3RKA4vunFAfrfxiJhPEplw/join) or [Patreon](https://www.patreon.com/codeopinion) for more info.


## Follow CodeOpinion
[Twitter](https://twitter.com/codeopinion)
[YouTube](https://www.youtube.com/channel/UC3RKA4vunFAfrfxiJhPEplw/)
Q3. What are the different types of Error Name values in JavaScript?
Tags: javascript, webdev, programming, career
Published: 2022-07-13 23:09:34

Ans. There are 5 types of Error Name values. Each one of them is briefly explained as follows:

- **Range Error** – Generated when a number outside the specified range is used
- **Reference Error** – It comes into play when an undeclared variable is used.
- **Syntax Error** – When the incorrect syntax is used, we get this error
- **Type Error** – This error is thrown when a value outside the range of data types is tried to be used.
- **URI Error** – Generated due to the use of illegal characters


3 Of 20 Js [Interview Questions](https://dev.to/saiarlen/series/18866)🙂
Any comments or examples would be appreciated🙃
Q2. Explain what a callback function is and provide a simple example.
Tags: javascript, webdev, programming, career
Published: 2022-07-13 22:55:36

Ans. A JavaScript callback is a function which is to be executed after another function has finished execution.

Below is an example of a simple callback function that logs to the console after some operations have been completed.

```javascript
function modifyArray(arr, callback) {
  // do something to array here
  arr.push(250);
  // then execute the callback function that was passed
  callback(); 
}

var arr = [1, 2, 3, 4, 5];

modifyArray(arr, function() { //calling function
  console.log("array has been modified", arr);
});

```


2 Of 20 Js [Interview Questions](https://dev.to/saiarlen/series/18866)🙂
Any comments or examples would be appreciated🙃