teleren/devto huggingface dataset:
Effective Java! Eliminate Unchecked Warnings
Tags: java, effective, generics, architecture
Published: 2020-06-02 04:59:14

---
title: Effective Java! Eliminate Unchecked Warnings
published: true
description: A dive into chapter 27 of Effective Java
tags: java, effective, generics, architecture
series: Effective Java Review
canonical_url: https://blog.scaledcode.com/blog/effective-java/effective_java_eliminate_unchecked/
---

As you start to use more and more generics you often will run into more unchecked warnings. Because Java has backwards compatability via raw types, as discussed in our previous chapter review, the compiler will not prevent us from writing type unsafe code. Even though it won't prevent us from compiling it will give us warnings. It is these warnings that we are focusing on in this chapter. 

As far as warnings go there are some that are harder to address than others. Some warnings simply require us to add the type to the declaration. For example the following code will throw an unchecked warning:

```java
Set<String> myStrings = HashSet();
```

We can fix it as simply as:

```java
Set<String> myStrings = HashSet<>();
```

We don't even need to list the type on the right-hand-side in this case as the diamond operator (`<>`) will cause the compiler to infer the type. Some other cases may not be as easy to remove the unchecked exceptions but if we can get rid of all the unchecked exceptions we can gain confidence that we won't have a `ClassCastException.`

So what if we find ourselves in a situation where we either can't get rid of the warning or the warning is showing up even though we know there is no risk of a class cast exception? If we have no other options the next step would be to annotate the unchecked usage with the `@SuppressWarnings("unchecked")` annotation. This, as the name suggests, will suppress the warning so that we don't get buried in warnings and so we can give the proper attention to future unchecked warnings. So what should we keep in mind when suppressing these warnings?
 * Only suppress warnings for locations you know are already type safe.
 * Put the suppress warnings annotation on smallest scope you can to accomplish the desired suppression.
 * Provide a comment for future developers of why the suppress warnings annotation is there and why it is still safe. 

That's what it comes down to. Remove all warnings (honestly all warnings not just the unchecked ones that we are focusing in this chapter) and for all places where you can't fix the warnings, suppress the warnings.
Can you suggest me Free productivity tools?
Tags: discuss, codenewbie, productivity, webdev
Published: 2020-06-02 04:52:15

Hi,
 Currently I use Trello for everything, right from noting down my tasks to ideas, tracking progress everything.

Just wondered if y'all could help me out with other Free tools that you've come across or used. 

Written by,
{% user developertharun %}

# Thank you for reading, This is Tharun Shiv a.k.a Developer Tharun

![Tharun Shiv](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xtxq6bdms36fmn62450h.png)
Understanding Javascript Filter
Tags: javascript, webdev
Published: 2020-06-02 03:02:10

`filter()` is a Javascript Method which was added to the ECMA-262 standard in the 5th edition. `filter()` provides an easy way of creating a new array out of an existing array under certain constraints. 

#### Simple Definition 
`filter()` method creates a new array with a certain constraints that are provided to the original array. 

#### Intuitive sense of Javascript Filter

As the name says, Javascript `filter()` does what is says. It filters things. As naive as it may seem ,  it actually is the case. Let's take an example of a simple water filter - what does it do ?  It takes impure water, filters out dirty things and gives you a clean water. The same analogy can be applied to Javascript filter. It takes an array, and you put certain constraints (like remove dirty things) and then gives you anoter array of items.

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

As we see in the above picture, it takes an array(here a array of red and yellow arrows) and we provide a certain filter(give me only red lines) and as a result you get a array of only filtered yellow arrows.

#### Syntax and Uses

`filter()` has the following syntax.

```javascript
var newArray = newArray.filter(function(items){
if(condition)
      return true;
})

```


Let's understand with a simple example:

Let's suppose that you have an array that contains students marks. So, now you want to give a simple present to students who have scored marks greater than 90. For this you'll have to separate the marks array that contains marks of students of the whole class into only those who have secured more than 90 marks.

```javascript
const studentsMarks = [40,35,89,92,94,46,98,65,93,97,45];
```

As we know, we want to filter only those students who have secured more than 90 marks and place them in a separate array called `topStudents`. Here's how we do that using `filter()`:

```javascript
const topStudents = studentsMarks.filter(function(student){
if(studentsMarks>90)
{ return true; }
})
```
Just writing this will create a new array named topStudents that will contain all the students who have secured marks more than 90.

If you `console.log(topStudents)` you'll see the following results:
```javascript
[92,94,98,93,97]
```

So, as you see this makes it much easier to create a new array out of an existing array.

#### Minimizing our existing code

For much simplicity and less code, the above code could be written using arrow functions. Let's see how we can minimize the code written above:

```javascript
const topStudents = studentsMarks.filter(function(student){
return student>90;
})
```

So, we omitted the `if() statement` using the above code which made our code less. This could even be made more beautiful using arrow function. Here's how we can write using arrow functions.

```javascript
const topStudents = studentsMarks.filter(student => student>90)
```

So, using arrow functions we minimized our code to just one line. This makes code much more beautiful, simple and easy to maintain. That's why I'm in love with Modern Javascript.
Laravel 7 File Upload Example
Published: 2020-06-02 04:18:51

Laravel - File Uploading. Uploading Files in Laravel is very easy. All we need to do is to create a view file where a user can select a file to be uploaded and a controller where uploaded files will be processed.

you can checkout full post here https://www.tutsmake.com/laravel-6-file-upload-with-validation-tutorial/
DynamoDB: the basics
Tags: aws, dynamodb, beginners
Published: 2020-06-02 04:09:36

---
title: DynamoDB: the basics
published: true
description: Exploring AWS, Basics of DynamoDB.
tags: aws, dynamodb, beginners
//cover_image: https://direct_url_to_image.jpg
---

Recently I've started looking at Serverless architecture inorder to move away from the monolithic architecture. While exploring AWS free tier, Amazon DynamoDB stood out to me. As a NOSQL database with free 25 GB of storage, I could use it for my personal projects basically for free.

So I've been reading up on AWS docs on the basics of DynamoDB, below listed are some of the basic terminology I have gotten to know about DynamoDB:

### Tables

Strange name, given DynamoDB is NoSQL, However, it serves as a good mental model, and helps understand how data is grouped together. These 'tables' consists of a collection of 'items'.

### Items

Items can be thought of as 'rows' in the tables, But unlike traditional tables, it does not have or need a specific schema. Aside from the primary key, it can contain any number of 'key-value' relations, and can also store nested objects upto 32 levels deep. 

### Primary Key

This is a simple one, Primary key uniquely identifies the 'item' in the table, it can be a single attribute or a combination of attributes.

#### Putting it all together

![Dynamo DB table](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/images/HowItWorksPeople.png)

*The image above is from [AWS docs](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.CoreComponents.html#HowItWorks.CoreComponents.TablesItemsAttributes)*

In this specific case, 'People' is the table, which consists of a collection of items, And 'PersonID' is the primary key which uniquely identifies the item. Here, besides 'PersonID', other key value attributes can be anything, even nested items.

#### Conclusion

So AWS DynamoDB is an awesome free data storage option, however NoSQL Databases has its own use cases as does Relational Databases. So it is important to figure out what kind of storage option is best for your specific project before going forward.

Thanks for reading.

*P.S. Please follow me on twitter [@Nipeshkc7](https://twitter.com/Nipeshkc7)*
Let's talk about ML Granny...
Tags: machinelearning
Published: 2020-06-02 04:07:46

Grandma, do you remember the last time you had come to Mumbai? We went to Murlidhar to buy your favorite sweets on our way back home after a long tiresome day. Looking into her mobile, mummy suggested that we should take the other road (L.M Road) instead of the one that passes through the shop (M.G Road). But you were adamant. We had to take the M.G Road. We reached home 2 hours later than we were supposed to reach. How come mummy predicted the traffic-congestion in M.G Road? 
Based on the historical and real-time data like time, location, velocity, etc. Google Maps is able to predict the traffic congestion. Google Maps also give out the live traffic delays for buses. How does it work? Do you think a real person is coordinating with thousands and thousands of drivers and sending this information to Google? Would you believe me if I told you that no human is involved? The answer to all your doubts is ML I.e Machine Learning. 
What is Machine Learning? ML gives systems the ability to learn without being explicitly programmed. In simple terms, you don’t need manpower. You just have to train the system just like you have taught mummy and uncle how to read and write from scratch. From then on wards, the machine performs the required/ expected task on it’s own. 
Ever heard of those self-driving cars? The main challenge here is the surrounding environment and obstacles. They will have to detect, recognize, classify and predict the movement of an object.You must be wondering how can a car or a machine mimic a human brain. Computer have many neural networks interlinked together. The input layer provide information from the outside world to the network. 
This isn’t restricted to roads and vehicles. The applications of ML are quite vast. For example, ML is being used in ICUs to monitor and analyse the data of the patient. An app claims to be able to detect skin cancer with the help of ML. Search engines use ML to improve the search results for you according to your taste and requirement based on your previous searches.
It’s a huge accomplishment that we can have machines that think and act like humans. It is said that the successful implementation of ML methods can help the integration of computer-based systems into our normal lives providing opportunities to facilitate and enhance the work , improve the efficiency and quality of life.
Working with JSON in JavaScript
Tags: javascript, json, server, node
Published: 2020-06-02 03:58:33

JSON is a universally used format for storing and transporting data. JSON is often used when working with a server that transfers information to a webpage.

# What is JSON
JSON stands for JavaScript Object Notation. It's a lightweight data interchange format that's language agnostic and self-describing.

# JSON Example
The data represented below is an array of three employees. 
```json
{  
	"employees":[  
		{"firstName":"John", "lastName":"Doe"},  
		{"firstName":"Anna", "lastName":"Smith"},  
		{"firstName":"Peter", "lastName":"Jones"}  
	]  
}
```

# JSON is Easily Transformed into JavaScript Objects
The JSON format is pretty much identical to the JavaScript object notation, so it's extremely easy for JavaScript programs to convert JSON data into a native JavaScript objects.

# JSON Syntax Rules
1. Data is in name/value pairs
2. Data is separated by commas
3. Curly braces hold objects
4. Square brackets hold arrays

# JSON Data - A Name and a Value
JSON data is written as name/value pairs, just like JavaScript objects. This means easy name/value pair consists of a field name, in quotes, followed by a colon, and then a value.
```json
"firstName": "John"
```

**Unlike JavaScript objects, JSON requires double quotes for field names**

# JSON Objects
Objects are written in curly braces, which contain multiple name/value pairs.
```json
{
	"industry": "Computer Engineering"
	"age": 32
}
```

# JSON Arrays
JSON array's are written in square brackets. They consists of multiple objects. 

```json
{  
	"employees":[  
		{"firstName":"John", "lastName":"Doe"},  
		{"firstName":"Anna", "lastName":"Smith"},  
		{"firstName":"Peter", "lastName":"Jones"}  
	]  
}
```

The key "employees" is an array of three objects. Each object is a record of a person.

# Converting JSON to JavaScript
A common use of JSON is to read data from a web server, then interpret and display that data on a web page. For simplicity, we're going to use a string as a JSON input. 

```javascript
var text = '{ "employees" : [' +  
'{ "firstName":"John" , "lastName":"Doe" },' +  
'{ "firstName":"Anna" , "lastName":"Smith" },' +  
'{ "firstName":"Peter" , "lastName":"Jones" } ]}';
```

Then, we'll use the built-in JavaScript function `JSON.parse()` to convert the string into a JavaScript object:
```javascript
var obj = JSON.parse(text);
```

Finally, we can actually use this object in our webpage as so:
```html
<p id="demo"></p>  
  
<script>  
document.getElementById("demo").innerHTML  =  
obj.employees[1].firstName  +  " "  + obj.employees[1].lastName;  
</script>
```

# Converting JSON to a String
If we want to convert JSON back into a string, to send data to a server for example, we can do that with the built in `JSON.stringify(obj)` function as so:

```javascript
var stringifiedJSON = JSON.stringify(obj); // This is now a simple string :)
```
Invert Binary Tree - LeetCode
Tags: tree
Published: 2020-06-02 03:49:02

---
title: Invert Binary Tree - LeetCode
published: true
description: Easy Problem
tags: Tree
---

Given a binary tree, you have to invert left and right nodes of it

**Example**:

*Input*

     4
   /   \
  2     7
 / \   / \
1   3 6   9

*Output*

     4
   /   \
  7     2
 / \   / \
9   6 3   1

**Algorithm:**

The intuition here is for each root node you visit swap left and right

The code would be something like

```js
temp = root.left
root.left = root.right
root.right = temp
```

And we have to do this recursively for all the nodes


**Code**

```js
/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {TreeNode}
 */
var invertTree = function(root) {
  // If there is a root we swap it and if there is no root just return the value
  if(root) {
    let temp = root.left
    root.left = root.right
    root.right = temp  
    invertTree(root.left)
    invertTree(root.right)
  }
  return root
};
```
Container Queries: Reimagined
Tags: ember, showdev, javascript, webdev
Published: 2020-06-02 03:27:27

_Originally published on [crunchingnumbers.live](https://crunchingnumbers.live/2020/06/01/container-queries-reimagined/)_

On Friday, I published my first addon. It's called [ember-container-query](https://github.com/ijlee2/ember-container-query/). Becoming an addon author was one of my goals for 2020, so I'm especially proud of it and hope that you will find a good use.

Container queries aren't new in Ember. My addon is based on Chad Carbert's [ember-fill-up](https://github.com/chadian/ember-fill-up) from 2019. That, in turn, credits Andrey Mikhaylov's [ember-element-query](https://github.com/lolmaus/ember-element-query) from 2017. I even found a [blog post](https://gregbabiars.com/responsive-ember-components/) from 2015, by Greg Babiars!

Simplicity is what makes `ember-container-query` different from the previous tries. I combined 2 atomic solutions (**modifiers**, introduced in Ember Octane) to arrive at _the_ atomic solution to container queries.

Because I practiced code composition and provided the minimum necessary API, the benefits are twofold. I have fewer code to maintain, while you have a choice to build your code on top of my addon or another with a similar API.

Testing is the second differentiator. With every code change, the [CI](https://crunchingnumbers.live/2020/03/17/ci-with-github-actions-for-ember-apps/) checks that my addon and demo app work **no matter the window size**. Testing multiple windows is _kinda_ important for container queries.

To my knowledge, no Ember app or addon has tried testing multiple windows and publicly released their solution. In the next article, I will go over how you can update the default test setup to achieve this feat.

In the meantime, I encourage you to learn [what container queries can do for you](https://github.com/ijlee2/ember-container-query#applications) and get inspiration from my [demo app](https://ember-container-query.netlify.app/). The code is publicly available on [GitHub](https://github.com/ijlee2/ember-container-query/tree/master/tests/dummy/app).

![Demo of ember-container-query](https://user-images.githubusercontent.com/16869656/82177207-72699c00-989e-11ea-9cb6-2e388c5e98c0.gif)
Graph Query Searches (Part 3)
Tags: gsql, dataanalysis, query, graphdatabase
Published: 2020-06-06 18:14:41

---
title: Graph Query Searches (Part 3)
published: true
date: 2020-06-02 03:16:00 UTC
tags: gsql,dataanalysis,query,graphdatabase
canonical_url: 
---

[![](https://cdn-images-1.medium.com/max/2600/1*86F8G_NMameuzKNuGQThvQ.jpeg)](https://towardsdatascience.com/graph-query-searches-part-3-a8bff845c3f1?source=rss-fc0227505fc6------2)

Writing GSQL Queries using TigerGragh Cloud

[Continue reading on Towards Data Science »](https://towardsdatascience.com/graph-query-searches-part-3-a8bff845c3f1?source=rss-fc0227505fc6------2)
Coffee Companion App LS:005
Tags: swift, swiftui, ios
Published: 2020-06-02 03:03:06

---
title: Coffee Companion App LS:005
published: true
description: Coffee Companion App iOS app development.
tags: Swift, SwiftUI, iOS
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/30uyz1j8uwzh0jbqeq7n.png
canonical_url: https://ko-fi.com/post/Coffee-Companion-App-LS005-H2H01RYLK
series: Coffee Companion App
---

Thanks for all that joined me on the live stream! Make sure to tune in next week same time (1pm CDT on Monday) and [same place](https://twitch.tv/appsbymw)!

{% youtube 63NaHvrP3j4 %}

# What did I do in the stream?

- Added Core Data to store multiple brewing methods
- Fixed an issue where coffee and water ratio should have been switch
- Fixed an issue where the calculation for water amount wasn’t working correctly.
- Made a view to see all brewing methods

# What am I doing in the next one?

- Edit brew method from list
- Time button needs to be bigger
- An option to put how much coffee you want and get the amount of coffee needed

# Looking for more about the project?

- Want to know what tasks need to be done or what’s being planned? Check out the Trello board.
- Want to see the code? Dig through the GitHub repo and star, watch, and sponsor it!
- Want to help fund the app and get your name listed at the end of the stream? Buy me a coffee or two by clicking the image below!

[![Donate Caffeine by buying me a coffee on Ko-Fi](https://dev-to-uploads.s3.amazonaws.com/i/8fey6iatjrl7cvrent11.png)](https://ko-fi.com/appsbymw)

---

Find me on the socials!

![Follow me on social media](https://dev-to-uploads.s3.amazonaws.com/i/hdy3a8kjjqn9i8frzs2j.png)
Cloning a Particular Branch of a Git Repository
Tags: git, github
Published: 2020-06-02 02:41:51

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/w2ffhshbznj1puakc5ey.jpeg)

Using git from the command line is something I have always wished I was good at. When I see how wonderfully well-experienced people use git from the command line, I marvel and am pushed to continue striving to attain an appreciable level of expertise in this art. Thus, whenever I use git, I try as much as possible to do so from the command line, although the lack of consistency has been a problem.

Recently, I released a second version of the miniature electronic voting application which I developed. Before I committed the codebase for the second version to the GitHub repository, I was not so sure how to go about it because there was a huge difference between the technologies used for the first and the second versions, and as such I could not add the second version as a release, because it required a separate README file. Eventually, I decided to move the first version to a new branch and commit the second and most recent version to the master branch so that I could write separate READMEs for them.

While drafting the README, I figured that less experienced command line users might find it difficult to clone a specific version (branch) of the app (repository) with the conventional **_git clone URL_** command. After a little research, I discovered a way to do this, which is a little tweak from the conventional command; `git clone -b branchname URL` gets the work done. So, if the name of the branch I want to clone is **v1.0** and the URL to clone the repository is **https://github.com/Chukwuamaka/ballotpal.git**, I would do `_git clone -b v1.0 https://github.com/Chukwuamaka/ballotpal.git`.

If you just found out, **welcome to the club!**
My 1st AWS Knowledge Center article published to help customers ✍️👨‍💻👩‍💻⛔💭✅😇🤝 (Amazon Data Lifecycle Manager)
Tags: aws, linux, devops, cloud
Published: 2020-06-02 02:38:24

<b>Thought of sharing with you</b> 😊😊

<h3><b><a href="https://aws.amazon.com/premiumsupport/knowledge-center/troubleshoot-data-lifecycle-manager-ebs/"> How can I troubleshoot problems using Amazon Data Lifecycle Manager? </a></h3></b>

<h4><b>[+] <a href="https://aws.amazon.com/premiumsupport/knowledge-center/troubleshoot-data-lifecycle-manager-ebs/">https://aws.amazon.com/premiumsupport/knowledge-center/troubleshoot-data-lifecycle-manager-ebs/</a></b></h4>



<h4><i>"Many Amazon Web Services (AWS) customers use Amazon Data Lifecycle Manager (DLM) which basically allows you to create policies to automate the creation, retention, and deletion of snapshots taken to back up your Amazon EBS volumes. Check out above article for some troubleshooting tips."<h4></i>


<h3><b>If you need any extended details of this, please refer my post below :</h3></b>

[+] https://dev.to/dineshrathee12/aws-dlm-data-lifecycle-management-snapshots-not-being-created-or-policy-in-error-state-troubleshooting-tips-4lkm

<a href="https://dev.to/dineshrathee12/aws-dlm-data-lifecycle-management-snapshots-not-being-created-or-policy-in-error-state-troubleshooting-tips-4lkm">![aws-dlm-data-lifecycle-management-snapshots-not-being-created-or-policy-in-error-state-troubleshooting-tips-4lkm](https://dev-to-uploads.s3.amazonaws.com/i/rrxubulx3w2w8co6hzjr.JPG)</a>



                                   😇 Happy learning 😇

![Happy Learning](https://media.giphy.com/media/wpoLqr5FT1sY0/giphy.gif)