teleren/devto huggingface dataset:
Checking if an Object has a Property
Tags: javascript, devops, tutorial, beginners
Published: 2021-05-12 14:40:38

* Now we can add, modify, and remove keys from objects. But what if we just wanted to know if an object has a specific property? One way of doing so used the `hasOwnProperty()` method. 
* We've created an object, `users`, with some users in it and a function `isEveryoneHere`, which we pass the `users` object to as an argument. Finish writing this function so that it returns `true` only if the `users` object contains all four names, `Alan`, `Jeff`, `Sarah`, and `Ryan`, as keys, and `false` otherwise.
```
let users = {
  Alan: {
    age: 27,
    online: true
  },
  Jeff: {
    age: 32,
    online: true
  },
  Sarah: {
    age: 48,
    online: true
  },
  Ryan: {
    age: 19,
    online: true
  }
};

function isEveryoneHere(obj) {
  // Only change code below this line

  // Only change code above this line
}

console.log(isEveryoneHere(users));
```
* Answer:
```
let users = {
  Alan: {
    age: 27,
    online: true
  },
  Jeff: {
    age: 32,
    online: true
  },
  Sarah: {
    age: 48,
    online: true
  },
  Ryan: {
    age: 19,
    online: true
  }
};

function isEveryoneHere(obj) {
if (
  users.hasOwnProperty("Alan") &&
  users.hasOwnProperty("Jeff") &&
  users.hasOwnProperty("Sarah") &&
  users.hasOwnProperty("Ryan")
) {
  return true;
} else {
  return false;
}
}
```
```
console.log(isEveryoneHere(users)); //console will display true
```
* Checks whether object contains all users by using the `hasOwnProperty` method for each name with the `&&` operator to return a `true` or `false` value.
Blockchain with Solidity: What to Learn First
Tags: blockchain, beginners
Published: 2021-05-12 14:34:49

Getting started in a blockchain development environment can feel completely foreign, especially if you are coming from web development.

Here is an overview of some key items I had to learn about in my first few days with Solidity:

### Web3
[Web3](https://web3.foundation/) is a term you will see often. In broad terms, it refers to certain interfaces and tools that make it easy to integrate with crypto wallets (like Metamask) and other blockchain-related functionality. There are a growing number of libraries that expose Web3 functionality in different dev environments.

### Metamask
[Metamask](https://metamask.io/) is currently the standard browser-based wallet to use while learning blockchain development. It has built-in integration with IDE and Testnet environments (more on this below) which makes it easy to acquire and use test Ether.

### Gas
* You have to pay gas (ether) to "change" the blockchain. This includes making a payment transaction, updating the state of a smart contract, or deploying a smart contract.
* Consider your gas payment to be the transaction fee paid to the miners running the network
* Your Solidity code should be optimized to [reduce gas cost](https://medium.com/@tyguyo/efficient-ethereum-smart-contract-storage-361e4f126bbd).

### Remix and Hardhat
* [Remix](https://remix.ethereum.org/) is an online IDE for compiling and deploying contracts written in Solidity. It is the quickest way to start working with smart contracts. 
* [Hardhat](https://hardhat.org/) is a framework for doing blockchain development in a local environment. It can also deploy to live and testnet environments.

### Testnets and Testnet Faucets
* Testnets are test blockchain environments. Use them to deploy and test smart contracts without having to spend real crypto on gas.
* Testnet Faucets will send cryptocurrency to your Metamask wallet which can be used on the Testnet environments.
  * [Kovan](https://faucet.kovan.network/)
  * [Ropsten](https://faucet.ropsten.be/)
  * [Rinkeby](https://faucet.rinkeby.io/)

### ERC-20
This is a spec for implementing fungible tokens. [Read about it here](https://ethereum.org/en/developers/docs/standards/tokens/erc-20/)

### ERC-721
This is a spec for implementing non-fungible tokens. [Read about it here](https://ethereum.org/en/developers/docs/standards/tokens/erc-721/)

---

I hope this list can save some time for anyone else out there learning Solidity. Let me know in the comments if there is something you think I should add.
Some Custom React Hooks I've used so far.
Tags: react, javascript, hooks
Published: 2021-05-12 14:34:36

Hi there,
As we all know, ReactJS is currently the most popular front-end framework. Some years back, a powerful feature was introduced by React devs - **React Hooks**, where they moved from class-based programming approach to function-based, which turned out to be a game changer! 

In addition to the in-built hooks from React's, like useState, useEffect, useContext etc., devs can write their own hooks - termed as Custom Hooks.

In this post, I'm gonna mention my favorite custom hooks, which I found useful for my projects.

##useLocalStorage:

The usage is similar to **useState**, but instead of storing the value in virtual state, we store it in browser's local storage and the value is persisted on page refresh.

Example:
If your site has dark theme mode, you can use the hook to persist theme's switch. So, whenever user returns to your site, it'll apply the theme automatically.

**[Source code & usage](https://usehooks.com/useLocalStorage/)**

---


##useMediaQuery

If you're aware of media queries from CSS, you'll get the usage info. from the name itself. Basically, you can use this when you want to conditionally render something according to device-screen's width.

Example:
Without using CSS, you can un-render mobile menu component, whenever screen size exceeds 768px.

**[Source code & usage](https://www.30secondsofcode.org/react/s/use-media-query)**

---


##useClickOutside

With this hook, you can detect click events outside of a particular element.

Example:
If you have a modal/dialog component, you want it to close whenever user clicks outside of the main element.

**[Source code & usage](https://usehooks.com/useOnClickOutside/)**

---

##useScrollDown

This hook will return true, if the scroll hits the specified value.

Example:
If you have a floating button for scroll up, but you only want it to show when your page is scrolled down a bit from initial position.

**Source Code:**
```
import { useState, useEffect } from 'react';

const useScrollDown = (height) => {
  const [boolean, setBoolean] = useState(false);

  const handler = () => {
    if (window.pageYOffset >= height) {
      setBoolean(true);
    } else {
      setBoolean(false);
    }
  };

  useEffect(() => {
    window.addEventListener('scroll', handler);
    return () => window.removeEventListener('scroll', handler);
  }, []);

  return boolean;
};

export default useScrollDown;
```

**Usage:**
```
const isScrollDown = useScrolldown(90);

return (
  <div>
    {isScrollDown ? "It's down!" : "Initial position."}
  </div>
)
```
---
Figuring out my path through Python
Tags: python, codenewbie, coderdads
Published: 2021-05-12 14:32:13

When I started my journey into programming last year, I quickly fell in love with the ease and functionality of Python. I paid for a Python mastery course from Mosh Hamedani and took my time going through the tutorials. I hit a roadblock when the course was over and I didn’t know what to do next. 

I wanted to have a base knowledge of HTML, CSS and JS, as I wasn’t sure if I wanted to go the front end or back end route to programming. So I began taking a @teamtreehouse front-end dev course and I got quite far into it before my life got busy. 

I had just got a new puppy, my wife and I sold our old camper and bought a new one, and we were preparing for our summer full of camping. I set the programming aside for a while. 

Recently I was able to do some programming at my day job, see a previous post of mine, and decided I was going to start fresh with Python again. 

At this time I am retaking the Python mastery course and things are making so much more sense now, and I am excited again at what I might be able to do with the Python language. 

I hope to soon write about my very first Program I created, a Secret Santa name generator. Stay tuned!
Using the delete Keyword to Remove Object Properties
Tags: javascript, devops, tutorial, beginners
Published: 2021-05-12 14:29:53

* Now you know what objects are and their basic features and advantages. In short, they are key-value stores which provide a flexible, intuitive way to structure data, and, they provide very fast lookup time.
* In earlier posts, we have both added to and modified an object's key-value pairs. 
* Here we will see how we can remove a key-value pair from an object. Let's revisit our `foods` object example one last time. If we wanted to remove the `oranges`, `plums`, and `strawberries` keys, we can remove it by using the delete keyword like this:
```
let foods = {
  apples: 25,
  oranges: 32,
  plums: 28,
  bananas: 13,
  grapes: 35,
  strawberries: 27
};

delete foods.oranges;
delete foods.plums;
delete foods.strawberries;
```
```
console.log(foods); // console will display 
{ apples: 25, bananas: 13, grapes: 35 }
```
NPM debug style logging in Go
Tags: go, debug, npm, logging
Published: 2021-05-12 14:28:59

I have always appreciated the [debug](https://github.com/visionmedia/debug) logging pattern commonly used within NodeJS projects. As I worked more with go, I wanted to bring that logging pattern to the language.

[kemba](https://github.com/clok/kemba) is a simple logging library that is a reimplementation of the npm [debug](https://github.com/visionmedia/debug) module in hopes of bringing that capability to the language.

The `kemba` logger reads the `DEBUG` and `KEMBA` environment variables to determine if a log line should be output. The logger outputs to `STDERR`.

When it is not set, the logger will immediately return, taking no action.

When the value is set (ex. `DEBUG=example:*,tool:details` and/or `KEMBA=plugin:fxn:start`), the logger will determine if it should be `enabled` when instantiated.

The value of these flags can be a simple regex alternative where a wildcard (`*`) are replaced with `.*` and all terms are prepended with `^` and appended with `$`. If a term does not include a wildcard, then an exact match it required.

[![Mentioned in Awesome
Go](https://awesome.re/mentioned-badge-flat.svg)](https://github.com/avelino/awesome-go)
Contentful Updates: Tags and Tag Based Permissions
Tags: contentful
Published: 2021-05-12 14:27:55

Every month Shy from the Contentful Dev Rel Team will share his favorite changes from the [Contentful Changelog](https://www.contentful.com/developers/changelog/). 


This month is so jam packed he's made two videos. For this one he's sharing all of the details about [Tags and Tag based Permissions](https://www.contentful.com/developers/changelog/#tags-and-tag-based-permissions). 


Tags are user-defined keywords, consisting of an editable label and a permanent ID, that can be used to create arbitrary content collections within a given environment.

The workflow for using tags requires a space admin (or other authorized roles) to create a list of tags within the space. After that, users can apply tags to individual entries/assets or bulk tag multiple entries/assets.
Gradient Custom Scroll Using HTML & CSS
Tags: html, css, webdev, beginners
Published: 2021-05-12 14:26:49

Hello, 

Today I created an Amazing Gradient Custom Scroll Using HTML & CSS. I hope you like this also comments about your thoughts.

For more content follow me on Instagram  [@developer_nikhil27](https://www.instagram.com/developer_nikhil27/).

Thank you!

{% codepen https://codepen.io/NikhilBobade/pen/KKWVmZr %}
Accessing Property Names with Bracket Notation
Tags: devops, tutorial, beginners, javascript
Published: 2021-05-12 14:24:41

* In the first object challenge we mentioned the use of bracket notation as a way to access property values using the evaluation of a variable. For instance, imagine that the `foods` object is being used in a program for a supermarket cash register. We have our function, 'checkInventory', which receives a scanned item as an argument. We've return the current value of the `scannedItem` key in the `foods` object. You can assume that only valid keys will be provided as an argument to `checkInventory`. We want to check our `foods` object for the presence of that food. This might look like:
```
let foods = {
  apples: 25,
  oranges: 32,
  plums: 28,
  bananas: 13,
  grapes: 35,
  strawberries: 27
};

function checkInventory(scannedItem) {
   return foods[scannedItem];
}

console.log(checkInventory("apples")); //console will display 25
```
Sync GitHub Labels across repos
Tags: github, devops, go, tooling
Published: 2021-05-12 14:20:08

Work across many of Repos? Manage an Org with hundreds of Repos? Ever wanted to have consistent Labels for Issues and PRs? This tool has you covered. 

[ghlabels](https://github.com/clok/ghlabels) is a simple CLI tool to help manage Labels across Repos. It has built in defaults that can be added to or overwritten via custom configuration.

This tool has proved valuable in synchronizing Labels across 300+ repos within the [GoodwayGroup](https://github.com/GoodwayGroup) resulting in a more efficient SDLC and consistent communication across all PRs.
The Future of Indian Crypto Exchange and banks
Published: 2021-05-12 14:19:53

The previous few days had established a tragedy of payment failures and failed to prevent orders, frequently program crashes for lots of the Indian crypto exchanges. The majority of people were clueless and so were wondering exactly what exactly was going wrong with all the cryptocurrency exchanges in India. That left an enormous meltdown for most of the favorite Indian exchanges to migrate into another partner bank and incorporate new payment options with all the brand new banks. Does not seem to be a simple job in any way, particularly in the previous month of April 2021, India's most widely used crypto exchange added inch Million brand new users and is still really a huge number thinking about the slow-paced growth thus far.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x5x9sigqi6e57dnnhuya.png)

In accordance with the accounts, NPCI doesn't have any issue using UPI getting used for cryptocurrency traders, but, the majority of the Indian banks appear to get an issue using UPI getting used by most users in shifting their savings on their own banking accounts to crypto exchanges. Very obvious that banks won't be pleased with money moving from banks into crypto exchanges, a robust cause of banks to receive angrily and so they did exactly what they can do and that causes an enormous catastrophe on most the crypto exchanges.

Lots of popular exchanges fell their drama store program evaluation from 4.2 celebrities to 3.1. And it's really very sad to see a lot of the start-ups that cared about the consumers and built a massive standing one of the user-base looked into being an unreliable application immediately.

Being a contented user of WazirX, I have never experienced any problems with them previously and the past week proved to be a nightmare for me personally to enjoy the majority of the additional shareholders. I have done lots of investigating to comprehend what's going wrong and realized that this can be a frequent problem for several exchanges in India along with the exchanges that have been in reality victims, so the offenders would be the banks that played dreadful movements here.

I attribute banks for many of those neglected trades, blocked obligations, significant losses for investors as opposed to attributing the exchanges.

https://www.techbuy.in/wazirx-referral-code/

Taxies do not like Uber,

Hotels do not like Airbnb.

Cinemas do not like Netflix.

The publication does not like Amazon.
STRUCTURES AND UNIONS
Published: 2021-05-12 14:16:21



##Structures##

A structure is a user-defined data type in C and C++. with this structure, we can combine different data types. It helps us to create complex data type which can be easily understandable and much more meaningful. Basically, we can group different data types into a single data type by using structure. In structure, we can store data in the form of records.

##Using structure in a program##

 We can define the structure in a C or C++ program by using the command struct.

 Example syntax for structure is 
**struct address
{
char name[100];
int roll_no[100];
float marks[100];
};**

 Structure cannot be initialized if there is a declaration. For example.
**struct address
{
   int x = 1; // COMPILER ERROR: cannot initialize members here
   int y = 0; // COMPILER ERROR: cannot initialize members here
};** 
When a data type is declared, no memory is allocated for it. Memory is allocated when variables are created.

 We can also declare arrays in structure

 We can also declare a pointer in a structure.
An example of this is 

**struct person per;
struct person *ptrA
ptrA=&per**

In the first two lines, we are declaring a structure pointer, and in the last line, we are initializing it.






#Unions#

Union is a user-defined data type in C language. In the same memory location, it can store different data types. It provides an efficient way of using the same memory location for multiple purposes. It is kind of similar to a structure, but there are differences between structure and unions. In C, we use unions to save memory. In unions, only one member can contain the value.


##Using union in a program##

l we can define union in a program by using the command union

l The example syntax for union is 
**union [union name]
{
Data type variable;
Data type variable;
…
Data type variable;
};**

l We can create an array of the union just like an array of structures. For example
**union example
{
char name[10];
int roll no[10];
};**

l We can have pointers to unions just like structures.
**union number n;
Union number *ptr=&n;**
In the first line,n is the variable to number. In the second line, ptr is the pointer to the union, and it is assigning with the address of the union variable n.

##Some differences between structures and unions##
Structure
1) It can access individual members at a time
2) Each member within a structure is assigned a unique storage area of location.
Union
1) It can access only one member at a time
2) Memory allocated is shared by individual members of the union.
Modifying an Object Nested Within an Object
Tags: javascript, devops, tutorial, beginners
Published: 2021-05-12 14:15:20

* Now let's take a look at a slightly more complex object. Object properties can be nested to an arbitrary depth, and their values can be any type of data supported by JavaScript, including arrays and even other objects. 
* Ex:
```
let userActivity = {
  id: 28802695164,
  date: 'December 31, 2016',
  data: {
    totalUsers: 99,
    online: 80,
    onlineStatus: {
      active: 67,
      away: 13,
      busy: 8
    }
  }
};
```
* `userActivity` has three properties: `id`, `data`, and `data` (value is an object with its nested structure). We can still use the same notations to access the information we need.
* To assign the value `18` to the busy property of the nested onlineStatus object, we use dot notation to reference the property:
```
nestedObject.data.onlineStatus.busy = 18;
```
* Now it will look like this:
```
let userActivity = {
  id: 28802695164,
  date: 'December 31, 2016',
  data: {
    totalUsers: 99,
    online: 80,
    onlineStatus: {
      active: 67,
      away: 13,
      busy: 18
    }
  }
};
```
Convert string to camel case CodeWars Kata
Tags: codewars, programming, challenge
Published: 2021-05-12 14:14:43

# Codewars

[Codewars](https://codewars.com) is a platform that helps you learn, train, and improve your coding skills by solving programming tasks of many types and difficulty levels. Here is the first Kata I've solved here, and I would like to share my solutions here in DEV.

# What is a Kata?

On Codewars, kata is code challenges focused on improving skill and technique.

❓ Here is my first Kata:

[Link to the Kata](https://www.codewars.com/kata/517abf86da9663f1d2000003/)

> Write a method/function so that it converts dash/underscore delimited words into camel casing. The first word within the output should be capitalized only if the original word was capitalized (known as Upper Camel Case, also often referred to as Pascal case).
>
> Examples
>
> "the-stealth-warrior" gets converted to "theStealthWarrior"
> "The_Stealth_Warrior" gets converted to "TheStealthWarrior"

💡 We can use [Regex](https://en.wikipedia.org/wiki/Regular_expression) to perform a search and replace in almost all programming languages.

{% wikipedia https://en.wikipedia.org/wiki/Regular_expression %}

I used [`preg_replace_callback`](https://www.php.net/manual/en/function.preg-replace-callback.php) function in PHP which performs a regular expression search and replace using a callback to find `"_\w"` or `"-\w"` patters like `_a` or `-b` and replace them with the equivalent uppercase character. like `_b` => `B` so `the-stealth` will be `theStealth`.

💻 So, my solution in PHP is:

```php
function toCamelCase($str){
    return preg_replace_callback('/(\-|\_)([a-z])/i', function ($match) {
        return strtoupper($match[2]);
    }, $str);
}
```

You might ask what is that `$match[2]`, well here is the `var_dump($match)` output:

```php
array(3) {
  [0]=>
  string(2) "_s"
  [1]=>
  string(1) "_" 
  [2]=>
  string(1) "s" 
}
```

as you see inside of each iteration this array contains, the matched string beside regex groups! in our case here we can access that group by $match[2]`.

## **Thank You** ❤️

I wish my posts to be useful to anyone who's new to the world of programming or anybody who's curious 🧐!
If you find the content useful to you, please comment your thoughts, I would love to learn from you all.

Thank you for your loving directions.
Adding Key-Value Pairs to JavaScript Objects
Tags: javascript, devops, tutorial, beginners
Published: 2021-05-12 14:09:06

* At their most basic, objects are just collections of key-value pairs. In other words, they are pieces of data (values) mapped to unique identifiers called properties (keys).
* Ex:
```
const tekkenCharacter = {
  player: 'Hwoarang',
  fightingStyle: 'Tae Kwon Doe',
  human: true
};
```
* The above code defines a Tekken video game character object called `tekkenCharacter`. It has three properties, each of which map to a specific value. If you want to add an additional property, such as "origin", it can be done by assigning `origin` to the object:
```
tekkenCharacter.origin = 'South Korea';
```
* This uses dot notation. If you were to observe the `tekkenCharacter` object, it will now include the `origin` property. Hwoarang also had distinct orange hair. You can add this property with bracket notation by doing:
```
tekkenCharacter['hair color'] = 'dyed orange';
```
* Bracket notation is required if your property has a space in it or if you want to use a variable to name the property. In the above case, the property is enclosed in quotes to denote it as a string and will be added exactly as shown. Without quotes, it will be evaluated as a variable and the name of the property will be whatever value the variable is. Here's an example with a variable:
```
const eyes = 'eye color';

tekkenCharacter[eyes] = 'brown';
```
* After adding all the examples, the object will look like this:
```
{
  player: 'Hwoarang',
  fightingStyle: 'Tae Kwon Doe',
  human: true,
  origin: 'South Korea',
  'hair color': 'dyed orange',
  'eye color': 'brown'
};
```