teleren/devto huggingface dataset:
Push Notifications for React Native using OneSignal
Tags: react, reactnative, javascript, webdev
Published: 2020-02-02 07:12:38

Performing mobile application push notifications is an important feature for any application.

This video shows you how to configure OneSignal with React Native in order to have Push Notifications. 

We take a look at installing OneSignal, including:

* Generating the certificate required from the Apple Developer Certificate location, 
* Connecting the certificate to OneSignal and setting up the App ID in our project. 
* Installing OneSignal library in our React Native Project
* Installing all the dependencies, as well as perform the manual steps. 
* We ensure that the subscription service is working on a real physical device and test it out. 
* We take a look at push notification functionality such as what functions can be run when a push notification has been received, selected, and viewed

{% youtube Qf8OzB9qJq8%}
_This first video will focus on iOS and another will be released soon for Android_

## Want to see more:
I will try to post new great content every day. Here are the latest items:
* [Designing a Full Website UI using Figma](https://dev.to/adriantwarog/designing-a-full-website-ui-using-figma-48fi)
* [Why you should Whiteboard your Design & Development, UI & UX](https://dev.to/adriantwarog/why-you-should-whiteboard-your-design-development-ui-ux-5g12)
* [How to start using Styled Components for React Native](https://dev.to/adriantwarog/how-to-start-using-styled-components-for-react-native-5don)
* [Creating a Mobile Design and Developing it](https://dev.to/adriantwarog/creating-a-mobile-design-and-developing-it-5c4o)
Material Card View, the practical guide
Tags: materialdesign, cardview, android, materialcard
Published: 2020-02-02 05:42:53

---
title: Material Card View, the practical guide
published: true
description: Google's Material card comes with practically incomplete styles, here's one way to fill in the gap so your cards look like cards.
tags: material design, cardview, android,material card
---

This scene is usually what you end up with if you added a material card with no additional styling.
Scroll past the images to see how to bring the card in line with your expectations.

Expectation | Reality
----|----|
![Three items that look like cards, evenly spaced](https://dev-to-uploads.s3.amazonaws.com/i/4p12z6fxqvqvcvf58xan.png) | ![Three items, no spacing, nothing that even makes them look like cards, just flat views next to each other with not even a line between them.](https://dev-to-uploads.s3.amazonaws.com/i/9c7pue967ymtwhqul2wk.png)

---

All that's needed for a card to really look like a card, is the minHeight and margins (top, left and right only because if you add bottom, the top and bottom margins both apply between cards and that space increases).

Add this to your `styles.xml`

```xml
    <style name="SensibleDefaultsMaterialCard" parent="Widget.MaterialComponents.CardView">
        <item name="android:layout_marginLeft">@dimen/mtrl_card_spacing</item>
        <item name="android:layout_marginTop">@dimen/mtrl_card_spacing</item>
        <item name="android:layout_marginRight">@dimen/mtrl_card_spacing</item>
        <item name="android:minHeight">200dp</item>
    </style>
```
Note: I know the mtrl_card_spacing is private, if you'd like you could move the 8dp out into your own value but I think this value should've been either public or actually applied to the card and then it could remain private. So I choose to use it directly.

---

Then we apply the styles to the MaterialCardView the important part here is `style="@style/SensibleDefaultsMaterialCard"` where the style is applied to the MaterialCardView.


```xml
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

        <variable
            name="goalData"
            type="com.aniketkadam.dogether.goals.GoalWithMetadata" />
    </data>

    <com.google.android.material.card.MaterialCardView
        style="@style/SensibleDefaultsMaterialCard"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@{goalData.goal.name}"
            tools:text="Some Goal Name" />
    </com.google.android.material.card.MaterialCardView>


</layout>
```

Other layout issues:
Another problem you may encounter is that when setting padding, it doesn't apply. I'm investigating why this is, and in the meantime I'll be padding the padding to the view directly or another wrapper layout if there's more than one view inside it.
P vs NP Algorithm Problem Types
Tags: programming, algorithms
Published: 2020-02-05 04:27:27

---
title: P vs NP Algorithm Problem Types
published: true
date: 2020-02-02 06:30:00 UTC
tags: programming, algorithms
canonical_url: https://varunbarad.com/programming/2020/02/02/p-vs-np-algorithm-problem-types.html
---

![Venn Diagram - Problem Types](https://varunbarad.com/assets/images/posts/p-np-venn-diagram.png)

The above image represents something completely un-understandable to me during my college years. I couldn’t understand what the professor tried to explain during my algorithms class when the topic of P vs NP vs NP-Complete problems came.

Finally I understood it from [a video by “Up and Atom”](https://www.youtube.com/watch?v=EHp4FPyajKQ). The problems are grouped according to these 2 criteria:

1. Can a solution to the problem be found in polynomial time?

2. Can a given solution for the problem be verified in polynomial time?

## NP Problems

These are the problems for which condition 2 holds true. If given a solution to such problem, the correctness of that solution can be verified in polynomial time. Condition 1 being true or false for such problems doesn’t affect whether they can fall under NP category or not.

## NP-Complete Problems

These are the problems for which condition 2 holds true but condition 1 is false. A valid solution to the problem can’t be verified in polynomial time, but if given a solution to the problem the correctness of that solution can be verified in polynomial time.

## P Problems

For these problems, both conditions 1 & 2 hold true. There exist methods by which a valid solution to any of these problem can be found under polynomial time. And also, any given solution for such problem can be verified in polynomial time.

Want to discuss this or any other interesting thing, hit me up on Twitter [@varun\_barad](https://twitter.com/varun_barad)
Login and Registration Form Using NES.css
Tags: css, html, todayilearned, todayisearched
Published: 2020-02-02 06:09:08

NES.css is a front-end CSS framework for crate and designed classic web user-interface like retro bit web apps. So here we designed simple Login and Registration Form Using NES.css. Also, we used CSS3 properties to make our elements more attractive.

Login and Registration form are common in any dynamic website but a different type of user-interface is our first priority.  Here we used NES.CSS to designed this awesome login and registration form and also we used CSS3 flexbox properties in these elements. Here customize some classes to make our element perfect and minimal. This is responsive elements in all views.

Get Source code:-

https://w3hubs.com/login-and-registration-form-using-nes-css/
Relearning project setup with git and angular
Tags: angular, vscode, git, devops
Published: 2020-02-02 05:27:02

So I've finally done it. After many months of not programming more than what's necessary for powerapps for work and after years of having a domain with nothing on it, I've decided to start a project to create a personal website based on angular and to document the process here.

Tonight I started by creating a GitHub repo for the project, updating my node, npm, and angular to latest and clone my repo in vscode. So far so good. I then used angular cli to create my website and serve it locally. Again... Great. 

Now I hit my snag. I try to commit my local changes through vscode git and it doesn't see the new files in my directory. I end up going to GitHub and uploading the files via the website. I pull latest but something wasn't right with vscode still. I ended up downloading GitHub desktop, blowing away my local directory and cloning again from the GitHub app. Because not all the files were pulled I ended up clearing everything from the source directory and recreating the site with angular cli. This time vs code saw the files and I was able to commit and push. Whew!

My overall goal is to reconnect with more complex coding, learn vscode better, and finally get my personal site up and running. My next goals are to get https certificates for my site, setup GitHub to push the website when I merge to master and then to get the start of the site up on my server. Hopefully I can get to this before next week!
Reading Snippets [42 => Computer Science ]
Tags: computerscience, beginners, ruby
Published: 2020-02-02 05:26:57

When programming, it is important to remember that the computer is never wrong. It is simply using the instructions that you have given it. 

Computer science is ultimately about problem solving. The following is a basic approach to solving problems:

1️⃣- Understand the problem.

2️⃣- Write out a solution in plain language.

3️⃣- Translate the language into code.

4️⃣- Test the code in the computer.

Being able to create efficient algorithms is one of the factors that distinguish a good computer scientist. 

<kbd><small>Source:<a href="https://learning.oreilly.com/library/view/computer-science-programming/9781449356835/onedot1_what_is_computer_sciencequestion.html">Computer Science Programming Basics in Ruby
</a></small></kbd>
ReactJS resources from beginners to master
Tags: react, node, webdev
Published: 2020-02-02 05:25:27

Hey! This is my ultimate list of ReactJS resources that I and many of my friends used to learn ReactJS from when we were beginners. Please take a look and comment if I missed out your favourite resource :)

https://easyontheweb.com/reactjs-resources-for-beginners-from-scratch/
Please don't make a mobile app (unless if you have to)
Tags: pwa, webdev, mobile, apps
Published: 2020-02-02 04:01:34


Last december I've started my first "real job" and, apart from the great onboarding experience, I've been having a bit of trouble setting up my benefits plans. Yeah, there are some UI quirks and weird verification challenges but, by far, **having to install a bunch of apps on my phones** caused most part of this pain.

Some of this apps exists for the sole puporse of consulting information, like the one from the healthcare company. No need for background processing, no notifications, nor some fancy use of the camera, and it still is shipped only as a native mobile app. One funny thing about this app in particular is that it has an "online chat" functionality that, when accessed, guess what: **it redirects to a webpage.** 

I know that mobile apps are still _a hit_. Companies are proud to say "download our app on Play Store or App Store", and most users get into that as well, but **we have to start evangelizing more about web apps.** And it's not a hard job, since, after battery draining, the most common complain from my close ones is their cellphones being low on storage, and, for the companies, building a native apps is more time-and-resource consuming compared to web development.

Whenever I see a new startup releasing a mobile app for its shine new CRUD, I feel a bit of the pain of every developer that has been doing an awesome job pushing [**PWA**](https://developers.google.com/web/progressive-web-apps) technologies forward for the last couple of years. And, in fact, being up-to-date with their job is a great way for us to embrace this campaign as developers. 

We still have a long way to support every native API on the browser, but we **[already have a ton of features](https://whatwebcando.today/)** that makes it possible to implement most of the apps I use everyday. There are also [great web apps](https://www.simicart.com/blog/progressive-web-apps-examples/) that are already PWAs (in fact, I use **dev.to** as an installed PWA on my phone).

An accesible and inclusive WEB is everyone's goal!
Unit testing from open source world
Tags: aws, unittest, junit, testing
Published: 2020-02-02 04:01:21

Hi Guys,

I was just preparing for one of my talks around unit testing and junit, I stumbled on one of the code repository on github aws-sdk-java. Here I found one unit test/integration/functional test class(Not sure where to fit in). 

Some of the things worth noting, 
1. There are no assertions
2. There are no validations of side conditions
3. Only one test has expected condition as exception

1. Share your thoughts on which category you will put this type of testing here ?
2. Is the developer just trying to make effort for code coverage ?

https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/test/java/com/amazonaws/http/AmazonHttpClientTlsAuthTest.java

Right now dev.to doesnot support embedding of code block please click and link and see
Hack Your Brain to be a Better Developer - with Science!
Tags: brainhack, adiecon, adiecon2020
Published: 2020-02-02 03:53:06

---
title: Hack Your Brain to be a Better Developer - with Science!
published: true
description: type up of my 2020 AdieCon talk
tags: brainhack, adiecon, adiecon2020
---

At the 2020 AdieCon I spoke about 5 different issues that I’ve encountered in my 3.5 years of being a developer, my understanding of the science behind why those things happen, and what my best strategy is for dealing with that issue. I've broken them out into the following articles:

[Asking For Help](https://dev.to/lgranger/asking-for-help-1cl9)

[Tracking Daily Activity](https://dev.to/lgranger/tracking-daily-activity-4el2)

[The More You Need to Know, The Harder it is to Remember](https://dev.to/lgranger/the-more-you-need-to-know-the-harder-it-is-to-remember-1nh7)

[Use a Checklist to Un-Stuck Yourself](https://dev.to/lgranger/use-a-checklist-to-un-stuck-yourself-2cle)

[Success Is A Feeling](https://dev.to/lgranger/success-is-a-feeling-1bma)

I had a blast at AdieCon and can't wait for next year!
Success Is A Feeling
Tags: brainhack, adiecon, success, 110percent
Published: 2020-02-02 03:52:11

---
title: Success Is A Feeling
published: true
description: Hack Your Brain to be a Better Developer Series
tags: brainhack, adiecon, success, 110percent 
---
*This is part 5 of [Hack Your Brain to be a Better Developer](https://dev.to/lgranger/hack-your-brain-to-be-a-better-developer-with-science-1np8), my talk from AdieCon 2020.*

*This section doesn't have the same research behind it as the first four parts, but it's important to me, and comes from my personal experience.*

In my life before Software Development I worked in Social Services, specifically in a homeless shelter, and later in low-income housing. To say that the clients and residents were folks who had and were experiencing severe trauma somehow feels like a massive understatement.

So I thought that when I came to work in software that my feelings of burnout would be easier to manage. The problem is that both careers have a commonality. Me.

When I honestly look inside, what I want in life is to be successful, to be the person who always gives 110%.

I wanted to be the best case manager. To give 110% meant being emotionally present for everyone. But I had 45 - 60 residents. Folks with histories of mental illness, disability and trauma. In a world that doesn’t believe housing is a human right. More than that, I’m human. And I couldn’t be everything for everyone.

I want all of my code to be flawless and sail through code review. I want to understand new concepts on first pass. I want to design beautiful, elegant new features. But the definition of flawless code is up for debate, it takes me time to really understand things, and not everyone agrees that my designs are elegant. More than that, I’m human. And I can’t be everything to everyone, even myself.

When we define success at giving 110% we are bound to be disappointed and to burn ourselves out trying. So here’s my best advice for my fellow folks who look inside themselves and see that what they want it to be successful. Success isn’t an outcome to be attained.

*Success is a feeling. And it’s a feeling you get to define for yourself.*

I've defined success for me this way:

Success is the feeling of getting up and going to do work that matters, that does good, even in little ways, with people you care about and who care about you. Success is the feeling of sitting around a big table eating food, talking, and just being together. Or going out into the world and really experiencing, moving your body through the world. Success is the feeling of coming home at the end of the day tired, but fulfilled. For me that’s what success feels like.

Go define success for yourself. You can.
Use a Checklist to Un-Stuck Yourself
Tags: brainhack, adiecon, getunstuck
Published: 2020-02-02 03:51:41

---
title: Use a Checklist to Un-Stuck Yourself
published: true
description: Hack Your Brain to be a Better Developer Series
tags: brainhack, adiecon, getunstuck
---
*This is part 4 of [Hack Your Brain to be a Better Developer](https://dev.to/lgranger/hack-your-brain-to-be-a-better-developer-with-science-1np8), my talk from AdieCon 2020.*

There’s a brain resources problem that is exposed when we get so stuck that we can’t think of what to do next. We don’t have the emotional and creative resources to save the code problem, so we also don’t have the emotional and creative resources to solve the get-unstuck problem.

In times like this I turn to my three-part un-stuck yourself checklist ([shout out to Coach Jennifer Underwood for the term un-stuck yourself](https://www.jenunderwoodcoaching.com/)).

*Take Care of You*

Do you need to eat a sandwich?
When was the last time you went outside?
Would a short nap help?

*Name the Problem*

Re-read the original task - are you [shaving the yak](https://en.wiktionary.org/wiki/yak_shaving)?
Enumerate what you do know - you've been thinking about what you don't know, refocus on what you do know
Write one sentence that names where you are stuck

*Re-frame the Problem*

Have an attitude of [let’s see](https://emilykarpinski.blog/why-we-avoid-what-we-can-do-about-it/). Reframe your one sentence as curiosity - from I don't know, to I get to find out.
What one thing can you do next? Pick the smallest unit of action you can do next. It doesn't have to solve the problem! In fact it probably won't, and that's ok, the goal is get going.
Do it! 

Now you've gone from so stuck you can't think, to taking action towards your goal. Congrats!
The More You Need to Know, The Harder it is to Remember
Tags: brainhack, adiecon, longtermmemory, notetaking
Published: 2020-02-02 03:51:26

---
title: The More You Need to Know, The Harder it is to Remember
published: true
description: Hack Your Brain to be a Better Developer Series
tags: brainhack, adiecon, longtermmemory, notetaking 
---
*This is part 3 of [Hack Your Brain to be a Better Developer](https://dev.to/lgranger/hack-your-brain-to-be-a-better-developer-with-science-1np8), my talk from AdieCon 2020.*

There’s an error code that I get sometimes in Android Studio. I can remember now what it is, but for years - yes years - I’d see it, realize that I’d seen it before, and not be able to remember how to fix it.

The issue with human long-term memory isn’t storage, [it’s recall](https://human-memory.net/memory-encoding/). The more often you remember something, the easier it is to remember it. The less often you deal with something, the harder it is to recall.

*Keep your own personal Stack Overflow.*

There are a plethora of note taking apps (make sure you’re not violating your work’s data privacy though!), but text files in a central location you can grep are just as good.

Some of the things that I keep:

Error Codes - group by IDE & language if you can
Common APIs & requests - especially ones you use to answer customer tickets! 
“Basic” questions - I always have to look up ternary operator syntax!
Good code examples - From code reviews or open source projects, tagged with why you liked them (ex: Clean Factory Setup, or Mocking Date/Time)
Set up instructions for specific devices - Android vs iPhone, your different smart speakers, etc

Workspace setup - your dot files, the settings of software you use on a regular basis if you can export them. These should definitely be backed up to an external HD or cloud. In the first 2.5 years at work I used the same computer. In the last year I’ve gone through two more. Trust me on the importance of backing up!

Where you can update open source documentation, team or company specific wiki’s, do it, but a just-for-you source is also worthwhile.
Tracking Daily Activity
Tags: brainhack, adiecon, workingmemory, dailylog
Published: 2020-02-02 03:51:06

---
title: Tracking Daily Activity
published: true
description: Hack Your Brain to be a Better Developer Series
tags: brainhack, adiecon, workingmemory, dailylog
---
*This is part 2 of [Hack Your Brain to be a Better Developer](https://dev.to/lgranger/hack-your-brain-to-be-a-better-developer-with-science-1np8), my talk from AdieCon 2020.*

You’re writing tests. You’ve got a mental map of how pieces of code work with each other, and an idea of what structures you’re going to set up for the test. You make mental note to change this var to that var. Then you realize you need to look something up, there’s a meeting, or the service you run tests through is suddenly down. You address the issue/attend the meeting, and switch back. Wait, what were you doing again?

The work we as developers is working memory intensive -  make and track connections, update ideas, and task-switch. [Memory research shows these tasks use the same WMC - working memory capacity](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3721021/), and we all know what happens when more memory is required than what is available:

*Brain Stack Overflow*

So aside from avoiding interruption, what can we do? I’ve tried a bunch of things and the best solution I’ve come across is to keep a timestamped diary. Note the time, what I’m working on, where in the code I’m working, and why I’m doing it. When my working memory capacity is hijaked by something else I’ve got a log to reference.

I also find this helpful for validating how much time tasks are taking, so I can keep at something that’s difficult but I haven’t actually been at that long, or pivot to a new tactic when the log shows I’ve been at it for a while.