teleren/devto huggingface dataset:
What is a Flatlist? How we use Flatlist in react-native:
Published: 2022-01-10 12:36:58

Rather than showing the list of items using the map function on an array and returning some JSX for each item in that array and then embedding that inside a scrollview so we can scroll up and down in that list.
Another way of showing a list that is better to use in any condition is Flatlist. In Flatlist, we don’t need to use scrollview because Flatlist comes with the ability to scroll up and down the list so we will get rid of that instead of importing.

## How to use:
First of all, we need our Flatlist components. We don’t have an opening and a closing tag. Flatlist is a self-closing component. And here we have different numbers of props that control how our list works. So first props are:

**1. Data:**
 Data props specify the data that we want to show. We have to pass data as an array. e.g. <Flatlist. data={people} />

**2. Render Item:**
 This prop is going to be a function. Now this function return some jsx with some item in the array that we are iterating we have to destructure it because it is not just the item 
`e.g. <Flatlist. renderItem={({item})=>(
return(<Text>{people.name}</Text>)
       )} />`

**3. numColumns:**
 numColumns props are used to show data in multiple columns.

**4. Horizontal:**
 If this prop is true, then data will be displayed horizontally.

**5. KeyExtractor:**
 It is used to specify the unique value in the given lists of items.

**6. ListHeaderComponent:**
 This prop render at the top of the item

**7. ListFooterComponent:**
 This prop render at the end of the item

**8. Refreshing:**
 Set true while waiting for new data to refresh


**Implementation:**

```
import React from "react";
import { StyleSheet, Text, View, FlatList } from "react-native";
const Person = [
  {
    id: "1",
    name: "Alex"
  },
  {
    id: "2",
    name: "Michel"
  },
  {
    id: "3",
    name: "Robert"
  },
  {
    id: "4",
    name: "William"
  },
  {
    id: "5",
    name: "James"
  }
];
 
const Item = ({ title }) => {
  return (
    <View style={styles.item}>
      <Text>{title}</Text>
    </View>
  );
};
 
export default function App() {
  const renderItem = ({ item }) => (
    <Item style={styles.text} title={item.name} />
  );
  return (
    <View style={styles.container}>
      <FlatList
        data={Person}
        renderItem={renderItem}
        keyExtractor={(item) => item.id}
      />
    </View>
  );
}
 
const styles = StyleSheet.create({
  container: {
    marginTop: 30,
    padding: 2
  },
  item: {
    backgroundColor: "green",
    padding: 20,
    marginVertical: 8,
    marginHorizontal: 16
  },
  text: {
    color: "red"
  }
});
```

## Code Output:

![code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/otwhn2r21jd6o230p6dz.png)
Book review "Advanced Perl programming"
Tags: perl, books
Published: 2022-01-10 12:33:56


![Advanced Perl Programming](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fbiqenfto5d5vh6g43o6.jpg)

[Advanced Perl Programming](https://www.oreilly.com/library/view/advanced-perl-programming/1565922204/) is a book from **Sriram Srinivasan** published in 1997 (ouch!).

It's old, if you're a Perl *newcomer*, don't read such old books (in addition that this book is not adapted to your level).

There is a [second edition](https://www.oreilly.com/library/view/advanced-perl-programming/0596004567/) of this book but it seems a totally different book (different author). Also the [Advanced Perl Programming: From Advanced to Expert](https://www.oreilly.com/library/view/advanced-perl-programming/9781484258637/) from **William Bo Rothwell** seems a completely different book.

**Advanced Perl Programming** is old but interesting... but I have to admit that it is not consistent in quality.

I think this book is for "hardcore Perl programmers" :grinning:

## Start of the book
The first chapters talk about Perl internals from a Perl developer point of view: references, symbolic refs, reference counting, symbol table, anonymous subs and closures. 

It continues with advanced Perl topics (eval and modules).

These chapters give an overall feeling of cleanliness and deep research from author. Each notion is compared to other programming languages (Java, C++, Tcl) which is VERY interesting. In short I loved these chapters.

It makes me think the author is a senior developer and has made a nice research work :)

## Middle of the book
I really less appreciated this part, it's about Object Oriented Programming, interfaces, persistence, templating... But if topics seem cool, it has flaws, it's based often on big pieces of imaginary code (not on CPAN) and/or old technologies. I can't say it's bad, but I definitely less enjoyed this part because also the style. Overall I think it's harder to follow because the ordering where code snippets are introduced is rough (e.g. The tetris chapter). 

There are still interesting things to pick up in the middle of this, e.g. I enjoyed the chapter about "Tie" (chapter 9) and Persistence (chapter 10).

## End of the book
Starting chapter 18, we are back to Perl internals (perl *interpreter* internals this time). Personally I'm interested in this and I found this part really great. 

## Interesting bits in bulk
* "Variable suicide"
* I discovered there was a ".plc" initiative (to pre-compile perl scripts "a la" python .pyc)
* I heard for the first time the word "Impedance mismatch" (OOP)
* When you give a reference as parameter of a function, it is not an optimization
* Symbolic references only works for global variables
* Symbolic references does not increase ref count

## Citations
* Perl is an highly idiomatic language (and it is both good and bad)
* Don't sit here and complain, do something! (yet another Perl motto)
* It would be an ideal world if we never had to worry about fatal bugs, power failures or end users (Byte Mag)
* A good tool is one that is used in ways its developers never thought of (Brian Kernighan)
My crazy idea
Published: 2022-01-10 12:31:05

Hello everyone! Share your opinion on how closely engineering is related to outer space.
And do you think it would be cool if everyone could afford [Dragonfly smallsat cameras](https://dragonflyaerospace.com/smallsat-cameras/)?
That is, each person could afford to purchase a satellite and observe space on their own.
What pros and cons do you see in this?
I would be glad to receive your feedback.
Leetcode diary: 1387. Sort Integers by The Power Value [DP]
Tags: javascript, algorithms, devjournal, motivation
Published: 2022-01-10 12:31:02

This is a new series where I document my struggles of leetcode questions hoping seeing however small of an audience I get gives me the motivation to continue.  

[Problem Link](https://leetcode.com/problems/sort-integers-by-the-power-value/)

This problem is rather easy, a good out-out-entry-level DP problem. 

My thought process is this:
1.) getPower() is easy to understand: I just run a while loop to decrease the number via the rule listed by the problem.
2.) we now memoize. This can be achieved simply by remembering how many steps is necessary for a particular number. We can return this memoized number whenever the while loop reaches this number. 
3.) we create the [lo ... high] then just sort based on the their power number and return the k-1th element by the sort (honestly though, why didn't the stupid problem just give k-1th number instead of k?).

Below is the code:

```
var getKth = function(lo, hi, k) {
    let nums = [];
    for (let i=lo; i<=hi; i++) {
        nums.push(i);
    };
    
    nums.sort(function(a,b){
        const powerA = getPower(a);
        const powerB = getPower(b);
        if(powerA === powerB) return a > b ? 1 : -1;
        return powerA > powerB ? 1 : -1;
    });
    
    return nums[k-1];
};

const memo = {}
function getPower (number) {
    const numberHolder = number;
    let step = 0;
    while (number >1) {
        if (memo.hasOwnProperty(number)) {
            step += memo[number];
            break;
        }
        
        if(number % 2 === 0) {
            number = number /2 
        }
        else {
            number = number * 3 + 1
        }
        step++;
    }
    
    memo[numberHolder] = step;
    return step;
}
```

Let me know anything on your mind after reading through this, THANKS!
Arrays management using JS
Tags: javascript, beginners, tutorial, webdev
Published: 2022-01-10 12:28:57

This is one of the _most important_ lesson 😤 you should start learning when you it's your first time **writing some code. ** 

As you know, an array is a typical data structure in JS, it's mainly a element chain, doesn't matter the type of their elements, the only important thing is to be _consistence_, let's see an example:

```js
let array = [1, "2", 3, null, undefined]
```

Look's at the example, doesn't matter the child types, it's the best characteristic on arrays here, but it's not the aim of this post, let's see how to manage that using JS and **functional programming** 🥰:  

```js
const result = [1, "2", 3, null, undefined]
    .filter((val) => typeof val !== 'undefined')
    .map((item, key) => {
      return { value: item, index: key };
    });
```

**Woow**!! 😏, yes I know, I'm so crazy, here I have use the most advance _functional programming_, let's try to see each part:

- First: the array start filtering using `filter`, it looks like the result array will have all the values without possibles **undefined**, it means to remove all values which their type are undefined. As you know 😉, filter return an array after applying the filter indicated in the `callback`. 

- Second: The result of the filter (an array) is passed to a `map` function, it's an actor who allows us to move between two context, it allow us to transform an array to an array of object with the structure provided on the `body` of this map.

Let's see each part separately: 

```js
const result = [1, "2", 3, null, undefined]
    .filter((val) => typeof val !== 'undefined')

// the result will be [1, "2", 3, null]
// after you can apply a map separately 

const secondResult = result.map((item, key) => {
      return { value: item, index: key };
    });

// the secondResult will be [{value: 1, index: 0}, 
// {value: "2", index: 1}, {value: 3, index: 2}, {value: null, index: 3}
// it's the same result as the example before

```

This is the same, we can mix all these `array functions` one after another, to get the result which we are looking for 😉. 

The idea of this post is to bring you the first approach to the _functional programming_ using `declarative methods` (it means say what we want not how to do that).

In the following post we will go into more detail about this functions and how to extract all the **power** that it has on JS. If you like this post 🧡, please don't forget to share it with your _friends_ and give us a _comment_, we really appreciate that.

See you 🙏
Easy way to pick a random geographic coordinate inside a radius in Python
Tags: haversine, python, tutorial, programming
Published: 2022-01-10 12:26:38

First of all, let's use the [haversine package](https://pypi.org/project/haversine/). We will use the inverse haversine function to get a random calculation given a coordinate and a radius.

The inverse haversine function needs a coordinates pair as the starting point of the calculations, a distance representing the radius, and a direction, which can be an Enum (Cardinal points, represented by multiples of Pi) or a float number.

Also, we need to pass an Enum representing the Distance Unit. The valid values are given by the haversine.Unit class:

```python
class Unit(Enum):
    """
    Enumeration of supported units.
    The full list can be checked by iterating over the class; e.g.
    the expression `tuple(Unit)`.
    """

    KILOMETERS = 'km'
    METERS = 'm'
    MILES = 'mi'
    NAUTICAL_MILES = 'nmi'
    FEET = 'ft'
    INCHES = 'in'
    RADIANS = 'rad'
    DEGREES = 'deg'
```

So you may already get what the secret is: we'll select two random numbers, one for distance, and another for direction.

Let's begin:

```python
from haversine import inverse_haversine, Unit


def random_coordinates(coords, radius, unit):
    """
    args - coords (Tuple: (lat: float, lng: float)), radius (float), unit (haversine.Unit enum)
    returns - new_coords (Tuple: (lat: float, lng: float))
    """

    # Choosing a random float between 0 and 2π
    random_direction = uniform(0.0, pi * 2)

    random_distance = uniform(0.0, radius)

    new_coords = inverse_haversine(
            point=coords,
            distance=random_distance,
            direction=random_direction,
            unit=unit
        )

    return new_coords
```
Top Resources to become a Better PHP Developer
Tags: php, beginners
Published: 2022-01-10 12:20:48

I have curated list of sites for anyone who wishes to learn PHP without spending a single penny :)

1. Free interactive PHP learning https://www.sololearn.com/learning/1059
2. Free PHP course https://www.educative.io/courses/learn-php-from-scratch/m2M2M8o7EA3
3. Free coding challenges https://edabit.com/challenges
4. Core php theory and concepts https://codelabs.greycampus.com/php/introduction
5. PHP fundamental course by codecademy https://www.codecademy.com/catalog/language/php
2022 Book List
Tags: books
Published: 2022-01-10 12:16:28

I really enjoy that so many people have freely given their knowledge on the web. Part of the reason the internet was so exciting was for the information. Although there is still something wonderful about books. Maybe it is all of the rigor that goes into making one or just that it is still a highly preferred method of distribution for knowledge. Whatever it is I have used books to further my career quite a bit and hope that I can inspire others to do so as well.

Curating a book list isn't easy. There are so many good titles and if you ask for recommendations from everyone you know you will likely be overwhelmed. You will need to deploy a system to help you think through what makes it and what doesn't. My system is not fully encompassing but it is simple. I created a set of categories of books that I wanted to fill and aligned them to my goals. For Self Help I wanted to build knowledge that I could use to help others as well as myself, and the books I chose would do just that. I also know that if I don't mix some fun books in with learning I will lose focus which led me to adding a couple of fun categories including kids books.

Usually I tend to get a set of titles as the year progresses from others but this year I thought I would jump in and collect a list of my own and start reading through it. Even as I was building this list I got some new ones while speaking to people. I will update this list as I pick more up throughout the year.

## Self
[Burnout Fix] (https://www.amazon.com/Burnout-Fix-Overcome-Overwhelm-Sustain/dp/1260464571) by Jacinta Jimenez
[PEAK Mind] (https://www.amazon.com/Peak-Mind-Attention-Invest-Minutes/dp/B08V5KFRM5) by Amishi P. Jha
[Thinking In Systems] (https://www.amazon.com/Thinking-Systems-Donella-H-Meadows/dp/1603580557) by Donella H. Meadows

## Leadership
[Elegant Puzzle] (https://www.amazon.com/dp/1732265186) by Will Larson
[She Engineers] (https://www.amazon.com/She-Engineers-Outsmart-Potential-Engineering/dp/1732070105) by Stephanie Lynn Slocum
[What got you Here Won’t get you There] (https://www.amazon.com/What-Got-Here-Wont-There/dp/1401301304/)

## Teck Skills
[Pragmatic Programmer] (https://www.amazon.com/Pragmatic-Programmer-Anniversary-Journey-Mastery/dp/B0833FBNHV) by David Thomas
[Philosophy of Software Design] (https://www.amazon.com/gp/product/1732102201) by John Ousterhout
 
## Fun
[The Lost Metal] (https://www.amazon.com/Lost-Metal-Mistborn-Novel/dp/0765391198) by Brandon Sanderson
[The Kite Runner] (https://www.amazon.com/Kite-Runner-Khaled-Hosseini/dp/159463193X) by Khaled Hosseini

## Kids
[Kenny & the Book of Beasts] (https://www.amazon.com/Kenny-Book-Beasts-Dragon/dp/1442486503/) by Tony DiTerlizzi
[The Adventurers Guild: Twilight of the Elves] (https://www.amazon.com/Twilight-Elves-Adventurers-Guild-Loran/dp/1368000339/) by Zack Loran Clark
Setup Flutter with VS Code
Published: 2022-01-10 12:16:15

Well, I decided to learn Flutter. I tried my hand at android app development and it was quite fun. At times it was daunting, especially when I ran the emulator and everything just stopped responding 😅. Overall Android Studio was a great experience!.

So this time instead of running a emulator I will be using my real device and why not let's use VS Code.

Before proceeding I assume you have Android Studio installed, it'll make things easier!.

1. Download the [Flutter SDK](https://docs.flutter.dev/get-started/install)
   - Choose your operating system (mine was windows 10)
   - Extract the zip file .I have extracted it to my `E:/` drive

2. Download [Git](https://git-scm.com/downloads) if you don't have. (Flutter depends on it)

3. Set environment variable
   - Copy the bin folder path from the extracted folder location. For me it was `E:\flutter\bin`
   - Open up environment variables tab. paste the copied path to `Path` variable. Hit OK.
   - Now you should be able to run Flutter commands anywhere. Open your terminal and type `flutter --version` that should fetch your Flutter version.

4. Download the [Flutter extension](https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter) in VS Code.

5. Open Android Studio, go to SDK manager, click on second tab SDK tools, check the Android SDK Command-line Tools and have it installed.

6. Run command `flutter doctor` in your terminal, here you might get a problem saying "Android SDK location not found", if that's the case then run `flutter config --android-sdk /path/to/android/sdk` (problem finding SDK path? search in Android Studio's SDK manager).

7. Run `flutter doctor` command again. Check if everything's fine.

8. Now in your terminal run `flutter doctor --android-licenses` and press y to accept every license.

9. In VS Code open up command palette `Ctrl+Shift+P` and type `flutter:new project` hit enter. Choose a template (Application) and give it a name. It will generate a default flutter app.

10. And Now to run the app on a real device, first enable USB debugging in your device settings. Connect the device to your PC. The bottom status bar in VS Code will now display your device name.

11. Finally run using `flutter run` command or by clicking `F5` in VS Code.

That's all! 👋
Agile Methodology in Testing: A Beginner’s Guide By QA Company in Dallas USA
Published: 2022-01-10 12:11:21

Agile testing is one of the critical part of application development life cycle and in this digital world it has huge impact on development process. In this post today as a part of top and leading[ QA Company in the Dallas USA,](https://www.testrigtechnologies.com/) I am going to take a deep dive into the world of Agile testing to know more about its Testing methodology.




<b>What is Agile Testing?</b>

Agile testing is one of the best and top practice of software testing in which software testers follows the rules and methodology of agile development. It is not similar to the Waterfall model, Agile testing start from the first of project with continuous integration between development and testing.
To keep this things in a mind, let’s have a look at what are the top Agile Test Methodology to consider while doing agile testing
•	Test-Driven Development (TDD)
•	Acceptance Test-Driven Development (ATDD)
•	Behavior-Driven Development (BDD)
•	Exploratory Testing
•	Session-Based Testing

<b>Test-Driven Development (TDD)</b>
TDD is one of the top software development approach used by QA engineers in which test cases are developed to specify and validate. In a simple words in the agile testing methodology Test cases are design first in case if test cases fails then new code must be prepare to recheck the test.
TDD start with developing a test cases. Which can be done with the help of automation testing.

Read also: https://www.testrigtechnologies.com/agile-testing-company-top-5-testing-challenges-in-agile-a-comprehensive-take/

<b>Acceptance Test-Driven Development (ATDD)</b>
ATDD is kind of programming technique it is completely different from TDD. The main purpose of ATDD is to collaborate the different teams members like testers, engineers, business stakeholders etc. to ensure the developers actually build what the customer needs.

<b>Behavior-Driven Development (BDD)</b>
Behavior Driven Development is another most important methodology in agile software development that improve the collaboration between teams of developers, QA. Behavior-driven development often stems from TDD and ATDD.

<b>Exploratory Testing</b>
In this type of software testing where Test cases are not prepared in advance but software testers needs to check system on the fly. This type of testing typically used to find hidden risks within a product. Software testers can overcome the errors and bugs which are missed in functional testing.

<b>Session-Based Testing</b>
We can also say Session-Based Testing is similar to the exploratory testing. Session-based testing is also used to find hidden bugs within a project.
Reading from the Standard Input (stdin) in Swift
Tags: swift, stdin
Published: 2022-01-10 11:56:53

There are many situations where we need to read input from StdIn. For instance, this is how inputs are provided in competitive programming websites such as [Hackerrank](https://www.hackerrank.com/).

## Reading from StdIn  
[readLine()](https://developer.apple.com/documentation/swift/1641199-readline) function is used to read the input from the user.
```swift
readLine(strippingNewLine: Bool)
```
Usually `strippingNewLine` is set to `true`, So that it will identify newline newline characters and character combinations are not a part of the input. Else, they will also be considered as the input. 

And `print()` function is used to write the output to StdIn.  

### Reading string from StdIn  
```swift
let str = readLine(strippingNewline: true)!
```
It will be fine to force unwrap the String if we are sure about the situation else it may leads to crash. 

### Reading Int from StdIn  
```swift
let str = Int(readLine(strippingNewline: true)!)!
```

### Reading array of String from StdIn  
```swift
let array = (readLine(strippingNewline: true))?.split {$0 == " "}.map (String.init)
print(array!)
```
![](https://i.imgur.com/2Ge2Y2o.png)

### Reading array of Int from StdIn  
```swift
import Foundation
var arr = readLine()!.components(separatedBy: " ").map{ (a: String)->(Int) in
    return Int(a)!
}
print(array!)
```
![](https://i.imgur.com/9Juq9ea.png)

## Testing  
`readline()` returns nil in Playgrounds. So, in order to use this function we need to create Command Line Tool application. 

File -> New -> Project.. (or simply ⇧⌘N) -> macOS -> Command Line Tool.
![](https://i.imgur.com/DPaIAeO.png)

After creating the project we can use it just as Playgrounds.