teleren/devto huggingface dataset:
A Token Management Implementation for Web API Authentication in Java
Tags: java
Published: 2019-08-19 21:54:20

This article studies an implementation of a synchronized process in Java that enables multiple threads to share same timed tokens, assuming access tokens in OAuth2, for Web API authentication.

#### Specification of Token Management

I assume the following specification for this token management system.

* Multiple threads call Web APIs with the same token.
* When a token expires, a thread that detects the expiration first will update the token.
* During the update process, token retrievals from other threads needs to wait the completion of the update.

#### An Implementation in Java

The following is an implementation of the token management system described above.

```java
public class TokenManager {

  // Singleton Pattern
  private static TokenManager instance = new TokenManager();
  private TokenManager() {}
  public static TokenManager getInstance() {
    return instance;
  }

  /* Set "volatile" to variables for token and update time so that any
     threads can retrieve the up-to-date state of the variables. */
  // Timed token
  private volatile String token = null;
  // Update time calcurated from TTL of the token
  private volatile long refreshAt = 0L;

  // getToken doesn't need "synchronized" as any threads can retrieve
  //  the up-to-date token with the aid of "volatile" keyword.
  public String getToken() {
    if (System.currentTimeMillis() >= refreshAt) {
      syncUpdateToken();
    }
    return this.token;
  }

  // Make the method "synchronized" so that only one thread can
  // execute it in time.
  private synchronized void syncUpdateToken() {
    // Prevent subsequents threads that call getToken method during
    // the token update from updating the token again.
    if (System.currentTimeMillis() < refreshAt) {
      return;
    }

    // Token Update Process
    // Update "token" before "refreshAt" as "refreshAt" is used
    // first in getToken method to check the token expiration.
    this.token = ...
    this.refreshAt = ...
  }
}
```

By making instance variables (token and refreshAt) "volatile", getToken method doesn't need "synchronized", which enables parallel execution of token retrievals while the token is valid.

Note that results in subsequent threads invoking updateToken method, thus token expiration check is also needed in updateToken to prevent unnecessary token updates.
React Axios Tutorial – Make HTTP GET and POST Requests
Tags: react, javascript, reactaxios, httpgetpostrequests
Published: 2020-01-31 20:48:38

---
title: React Axios Tutorial – Make HTTP GET and POST Requests
published: true
tags: React, JS, React Axios, HTTP GET POST Requests
canonical_url: https://www.positronx.io/react-axios-tutorial-make-http-get-post-requests/
---

The post [React Axios Tutorial – Make HTTP GET and POST Requests](https://www.positronx.io/react-axios-tutorial-make-http-get-post-requests/) appeared first on [positronX.io](https://www.positronx.io).

In this **React Axios tutorial** , we are going to learn how to make Axios GET, and POST requests using Axios. I will create a backend server for React app using MongoDB, Node, and Express.js. We will create a frontend using React.js and Bootstrap 4. Then, we will learn to make REST API calls using Axios.
 

[Click here to read more](https://www.positronx.io/react-axios-tutorial-make-http-get-post-requests/)
The Development vs Production Environments
Tags: explainlikeimfive, flatiron, beginners, javascript
Published: 2019-08-19 21:04:27

One of the disadvantages to doing a coding bootcamp is that you don't get much experience writing code in a production environment. This may be why I've had such a hard time moving my project backends onto Heroku.

The process introduced relatively foreign concepts, such as working with a production environment.

###What's the difference?
The development environment is your local computer, while the production environment is the live product customers or visitors might interact with.

Since it can be hard to remember new technical vocabulary, I've used the following mnemonic:
- development –> developer coding on their computer
- production –> product i.e. the final product


###Why do these terms matter?
If you're still coding mostly on your computer, with no intention of shipping your product, exploring the production environment isn't as urgent. 

But hosting my backend with Heroku forced me to create the production version of the database and to update my database.yml file with the proper settings. 

While making the changes themselves weren't difficult, knowing that and why I to create them took a couple of hours to understand. To keep this blog to 1-2 min, I will cover those changes in another blog.

[This video](https://youtu.be/pdNmlvJL7qw?t=108) covers the two above, as well as, some additional environments you will come across.
So you put an escaped string into a JSON column... 
Tags: postgres, json, jsonb
Published: 2019-08-19 21:01:56

---
title: So you put an escaped string into a JSON column... 
published: true
description: Turning escaped JSON strings in Postgres JSONB columns into actual JSONB
tags: postgresql, json, jsonb
---

Whoops! Let's pretend we made a mistake a while ago, and our application is writing escaped JSON strings into our Postgres JSON column instead of JSON objects. We can't use any JSON operators to select fields now! What are we to do?

`select (ingredients #>> '{}')::jsonb->>'cheese' from pizza;`

Do this ☝️. When you’ve got a table (pizza) with a jsonb column (ingredients), and you’ve accidentally put an escaped JSON string inside that column, instead of a JSON object. The value might look like this:

`"{\"cheese\": \"mozzarella\"}"`

See the quotes? That’s just a string at the root level inside of that JSON column. But what you really want looks like this:

`{"cheese": "mozzarella"}`

That’s better. But we’ve already made the mistake, so we’ve got to write a migration to fix the data. Here’s how we do it:

`(ingredients #>> '{}')::jsonb`

The `#>>` operator in Postgres gets a “JSON object at specified path as text” ([PostgreSQL: Documentation: 9.3: JSON Functions and Operators](https://www.postgresql.org/docs/9.3/functions-json.html)). Here we’re passing in an empty  path to say that we want Postgres to give us the *unescaped* string at the root level as a `text` value.

We can then cast that `text` value back to JSON like this: `(stand-in-for-text-value)::jsonb`. And then we have a normal, parsed JSON object at the root level that we can select fields off of.
About Karl Mehta

Tags: karlmehta
Published: 2019-08-19 20:13:02

Karl Mehta is a serial entrepreneur, author, investor, engineer, and civil servant with over 20 years of experience in founding, building, and funding technology companies in the U.S. and international markets. He is currently Founder & CEO of EdCast Inc., an AI-powered knowledge-cloud platform company backed by Stanford University & Softbank Capital. He is former venture partner at Menlo Ventures, a leading VC firm of Silicon Valley with over $4B under management.
Previously, he was the Founder & CEO of PlaySpan Inc., acquired by Visa Inc. (NYSE:V), the world’s largest payment network. Karl also served as a White House Presidential Innovation Fellow, selected by the Obama Administration during the inaugural 2012-13 term. In 2014 he was appointed by Governor Brown to the Workforce Investment Board of the State of California. In 2010, Karl won the “Entrepreneur of the Year” award from Ernst & Young for Northern California. Karl is on the boards of Simpa Networks and on the advisory board of Intel Capital and Chapman University’s Center of Entrepreneurship.
Karl is founder of several non-profit's including Code For India (http://CodeforINDIA.org) and Grassroots Innovation (http://grassrootsinnovation.org ). He is author of 'Financial Inclusion at the Bottom of the Pyramid”(http://www.openfininc.org) -http://www.amazon.com/dp/1460265513
What Is a Higher-Order Observable?
Tags: angular, rxjs, webdev, javascript
Published: 2019-08-19 19:49:59

One of the challenges of diving deeper into RxJS, or Reactive Extensions for JavaScript, is the terminology. We may know the basics of using RxJS, but to really understand how it works, we need a firm grasp of its vocabulary.
Let’s focus on answering these questions:

- What *is* a higher-order Observable?
- What are inner and outer Observables?
- And what is the purpose of a higher-order mapping operator, such as mergeMap or switchMap?

By mastering these concepts, we can better leverage RxJS to build more declarative and reactive Angular applications.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/n4nzgsn9bemi76nmv7qi.png)

**Find the full post here**: https://blogs.msmvps.com/deborahk/higher-order-observable/

**To learn more about RxJS**, check out my Pluralsight course: “RxJS in Angular: Reactive Development”. You can find it at this URL: https://app.pluralsight.com/library/courses/rxjs-angular-reactive-development
DEV Tip: Subscribe to the "Welcome Thread"
Tags: meta, devtips
Published: 2019-08-19 19:30:49

---
title: DEV Tip: Subscribe to the "Welcome Thread"
published: true
description: Sharing a tip that makes it fun and easy to welcome new members to the DEV Community.
tags: meta, devtips
---

Each week, thousands of new people join the DEV Community.  These are programmers of all backgrounds and experience levels, from all around the world.

Many of these folks choose to introduce themselves in a "Welcome Thread" posted by the [DEV Staff](/thepracticaldev) account.  It's a great place to say say hello, meet other community members, and to ensure that everyone feels welcome here on DEV.

If you'd like to be notified of new posts in that thread, consider "subscribing" to notifications.  Simply click `...` in the post sidebar and choose the option to be notified of "Top Level Comments" 

![example of option to subscribe to a thread](https://cl.ly/30476a2604a0/Image%202019-08-19%20at%201.48.48%20PM.png)

That way, you'll get a notification whenever a new person introduces themselves.  If at any point you want to disable the notification, just go back into the same area and choose "unsubscribe."

I hope this tip encourages you to welcome new users, and also helps inform you of the comment-subscription functionality here on dev.to.

You can find the latest Welcome thread here:

{% link https://dev.to/thepracticaldev/welcome-thread-v37-172 %}
npm security tips to keep you safe of malicious modules
Tags: npm, node, security, javascript
Published: 2019-08-19 19:24:20

---
title: npm security tips to keep you safe of malicious modules
published: true
description: npm security tips to keep you safe of malicious modules
tags: npm, nodejs, security, javascript
canonical_url: https://www.lirantal.com/blog/2019-08-19_npm-tips-to-keep-you-safe
---

Tip 3: Minimize attack surfaces by ignoring run-scripts (out of [10 npm security best practices](https://snyk.io/blog/ten-npm-security-best-practices/))

The npm CLI works with package run-scripts. If you’ve ever run `npm start` or `npm test` then you’ve used package run-scripts too.

The npm CLI builds on scripts that a package can declare, and allows packages to define scripts to run at specific entry points during the package’s installation in a project.

For example, some of these [script hook](https://docs.npmjs.com/misc/scripts) entries may be `postinstall` scripts that a package that is being installed will execute in order to perform housekeeping chores.


With this capability, bad actors may create or alter packages to perform malicious acts by running any arbitrary command when their package is installed.

A couple of cases where we’ve seen this already happening is the popular [eslint-scope](https://snyk.io/vuln/npm:eslint-scope:20180712) incident that harvested npm tokens, and the [crossenv](https://snyk.io/vuln/npm:crossenv:20170802) incident, along with 36 other packages that abused a typosquatting attack on the npm registry.

Apply these best practices in order to minimize the malicious module attack surface:

* Always vet and perform due-diligence on third-party modules that you install in order to confirm their health and credibility.

* Hold-off on upgrading blindly to new versions; allow new package versions some time to circulate before trying them out.

* Before upgrading, make sure to review changelog and release notes for the upgraded version.

* When installing packages make sure to add the `--ignore-scripts` suffix to disable the execution of any scripts by third-party packages.

* Consider adding `ignore-scripts` to your `.npmrc` project file, or to your global npm configuration.

--

I also blogged about a complete [10 npm security best practices](https://snyk.io/blog/ten-npm-security-best-practices/) you should adopt in a post that includes a high-resolution printable PDF like the snippet you see below.

Thanks for reading and to [Juan Picado](https://twitter.com/jotadeveloper) from the Verdaccio team who worked with me on it.

[![Node Version](https://thepracticaldev.s3.amazonaws.com/i/yvey2bykpvbjcxrurqoz.png)](https://snyk.io/blog/ten-npm-security-best-practices/)
60 Days of Flutter : Day 6–7 : Implementing a Slideable Widget Using Bottomsheet in Flutter
Tags: flutter, android, ios, mobile
Published: 2019-08-19 19:18:45

https://medium.com/@adityadroid/60-days-of-flutter-day-6-7-implementing-a-slideable-widget-using-bottomsheet-in-flutter-c320dc106f2b?sk=18ddb63ed2fb69dfc90d6aa8f4ac574f
2 Effective Methods for Managing People Who Are Smarter than You
Tags: ui, ux, management
Published: 2019-08-19 18:58:50

<sup>Cover Image: [Close Up Photo of Grape Fruit](https://www.pexels.com/photo/close-up-photo-of-grape-fruit-197907/) by [Henri Guérin](https://www.pexels.com/@henriguerin)</sup>


Part of my responsibilities as Lead UX Engineer at the company I work for is to manage a small UI/UX team made up of 3 brilliant people and myself. I've learned a lot so far and I have two solid tips that may help if you're ever in a similar situation.

## 1) Ask questions
Asking questions is a great way to learn together as a team and encourage collaboration. This comes to mind when there is a particular piece of a design or software that doesn't quite function the way it <em>should</em> or isn't the pattern you would have implemented.

Asking how the user would feel when interacting with the problem area vs expressing dislike or suggesting a change is going to produce a more collaborative and ultimately better result.

At the same time, they more than likely have spent more time in that area trying to figure out a solution so often they have perfectly good reasoning that you may not have found out about if you didn't ask first. **Acting on assumptions will underutilize your team**, ask questions instead.

## 2) Encourage pushback
When members of a team are encouraged to express their opinions and give pushback when they see fit the whole team benefits.

Using one person's opinion isn't usually the right way to build things, especially in the UI/UX world. Want to implement something but the team thinks it's a bad idea? Guess what, it's probably a bad idea and enabling your team to pushback on it just saved tons of time and money.

Take your team members seriously and thank them when they do pushback. **Creating a safe environment is critical** if you want to get the most out of your team.

One thing that seems to always ring true: **Collaboration to produce a better solution is essential when working with smart people.**
Octocat Memory Game
Tags: codepen
Published: 2019-08-19 18:48:38

<h1>Octocat Game</h1>

<p>Test your memory, you know how to play.
 All the images are belongs to there respective owner .</p>

<p>// Updated  on  16 July, 2017   :  Second time play error fixed. Some image replaced.</p>

{% codepen https://codepen.io/JasonEtco/pen/yobKqg %}
Tell us your Thoughts About Open Source
Tags: discuss, healthydebate, opensource, hacktoberfest
Published: 2019-08-19 18:35:32

---
title: Tell us your Thoughts About Open Source
published: true
description: Take a few minutes to share your thoughts about open source and help us understand and report back on the state of open source in 2019.
cover_image:  https://assets.digitalocean.com/articles/devto/currents_2019q4.jpg
tags: discuss, healthydebate, opensource, hacktoberfest
---

Open source software is everywhere, powering applications and gadgets of all sizes, all over the world. If you work with technology, and especially if you are a developer, you are certainly using a wide range of open source software on a daily basis. You probably have used GitHub to check out some code or to find out how to use a certain library / API. But have you ever asked yourself **why** so many people around the world dedicate so much time to building and contributing to open source projects? 

We want to hear from you. Have you ever contributed to open source? What was your main motivation for doing that? Did it have a positive impact on your career? What was your biggest challenge?

We will be sending a limited edition Sammy sticker to everyone who participates in [our newest Currents survey about Open Source](http://do.co/currentsOSS). Take a few minutes to share your thoughts about this subject and help us understand and report back on the state of open source in 2019. This will be just in time for the upcoming Hacktoberfest.

![open source sammy](https://thepracticaldev.s3.amazonaws.com/i/pj7ai60qabp8fyizhslf.png)

Additionally, we welcome anyone who would like to share their #OpenSourceStory either on Twitter or by leaving a comment in this post. We'll feature the best comments on our social media channels in order to bring visibility to the benefits — as well as the struggles — of open source work!
Introduction to Docker Part 1
Tags: docker, introduction
Published: 2019-08-19 18:02:34

In the next few #blog posts I'll try to give a quick introduction to 
@Docker
 

I'll be doing some hands one demos with a few 
@digitalocean #Ubuntu servers

Check out part 1 here:

https://bobbyiliev.com/blog/introduction-to-docker-part-1

Feel free to reach out to me if you have any questions :)
Welcome Thread - v37
Tags: welcome
Published: 2019-08-19 17:53:37

---
title: Welcome Thread - v37
published: true
description: Welcome to DEV! A thread of hellos and intros.
tags: welcome
---

![Forest, Forest Gump](https://media.giphy.com/media/dw36yjtOAtuSZyxEJG/giphy.gif)

### Welcome to DEV!

1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋 

**Great to have you in the community!**
Contact section, Tagged thumbnails, Intro fade in | Module Monday 52
Tags: showdev, webdev, javascript, githunt
Published: 2019-08-19 17:44:45

---
title: Contact section, Tagged thumbnails, Intro fade in | Module Monday 52
published: true
description: Module Monday 52
tags: showdev, webdev, javascript, githunt
cover_image: https://res.cloudinary.com/component/image/upload/b_rgb:1d2133,c_lpad,h_350,w_800/v1566005129/form_wd7ctb.gif
canonical_url: https://guide.anymod.com/module-monday/52.html
---

## Open-source web modules for your next project
Everything below is open source and free to use on any website, web app, or anywhere else. There are hundreds more like these on [AnyMod](https://anymod.com).

Click a mod to see it along with its source code.


## Contact section with form (works automatically)
Ready-to-use form and responsive section with email, phone, and address.
<a class="btn btn-sm" href="https://anymod.com/mod/contact-section-with-form-ralnnn">View mod</a>
<a href="https://anymod.com/mod/contact-section-with-form-ralnnn">
  <img src="https://res.cloudinary.com/component/image/upload/v1566005129/form_wd7ctb.gif"/>
</a>

## Tagged thumbnails with filtering
Add and tag thumbnails; filters work automatically.
<a class="btn btn-sm" href="https://anymod.com/mod/tagged-thumbnail-links-barnkk?preview=true">View mod</a>
<a href="https://anymod.com/mod/tagged-thumbnail-links-barnkk?preview=true">
  <img src="https://res.cloudinary.com/component/image/upload/v1566005130/thumbnails_jhd6uh.gif"/>
</a>

## Fade in intro section
Class up your initial page load with progressive fading text and image.
<a class="btn btn-sm" href="https://anymod.com/mod/hero-kdnbmm?preview=true">View mod</a>
<a href="https://anymod.com/mod/hero-kdnbmm?preview=true">
  <img src="https://res.cloudinary.com/component/image/upload/v1566005130/hero_b9otsl.gif"/>
</a>

## Content left, image right
Colorful content section with call to action. Responsive out of the box.
<a class="btn btn-sm" href="https://anymod.com/mod/left-content-ordnkl?preview=true">View mod</a>
<a href="https://anymod.com/mod/left-content-ordnkl?preview=true">
  <img src="https://res.cloudinary.com/component/image/upload/v1566005129/content-left_y8oz6g.png"/>
</a>

## Jumbo page card
Use this oversized card section to highlight featured content on your page.
<a class="btn btn-sm" href="https://anymod.com/mod/content-with-image-alrndl?preview=true">View mod</a>
<a href="https://anymod.com/mod/content-with-image-alrndl?preview=true">
  <img src="https://res.cloudinary.com/component/image/upload/v1566005130/content-image_q9kvdl.png"/>
</a>

<hr>

I post new mods from the community [here](https://dev.to/tyrw) every (Module) Monday -- I hope you find them useful!

Happy coding ✌️
Experts and Interlopers
Tags: pedagogy, dreyfus
Published: 2019-08-19 17:39:47

---
title: Experts and Interlopers
published: true
description: 
tags: meta, pedagogy, dreyfus
---

Experts give a lot of value to their team. They get a ton done, they know things inside and out, and they can operate well within the system. They're great to consult with questions. They're good at building things quickly and in a stable manner.

Interlopers give a lot of value to their team. Because they're coming in from the outside, they're a font of new ideas that can drastically improve team processes, practices, and standards. They have no attachment to the status quo. They bring in smart ideas from other fields at a higher rate. They stoke revolution.

There's a reason revolutions are most common in countries with high numbers of unemployed teenagers.

Experts, despite their skills, have indeed drunk the Kool Aid. They're indoctrinated into the status quo, and it takes additional, rarer skills for an expert to see outside of the bubble in which they function so effectively.

I guess the takeaway here is that it's important for you to have experts _and_ interlopers on your team. Those that preserve the status quo, that teach the old ways, and that know their way around the system, and those that can bring new revolutionary ideas to your team.

And the even bigger, more difficult-but-worth-it goal, might be to become and expert while still retaining that interloper spirit, never getting too comfortable with the way things are while still understanding how they work.