teleren/devto huggingface dataset:
Intl Formatting Numbers in Javascript
Tags: javascript, usetheplatform, webdev
Published: 2019-12-12 15:16:07

---
title: Intl Formatting Numbers in Javascript
published: true
description: Browser API that will take the pain out of formatting numbers that supports multiple locales.
tags: js, usetheplatform, webdev
---

Formatting numbers is key to many applications. This may seem like a small task to an experienced developer, but the thought of having to write these for every application I start is disheartening. Well, anyways, enough with my rant. Let's look for a library to knock this out so we can move on. We need a solution that handles percentages, currency, and many languages. Hmm? What if there was an API in the browser?


## Using Intl.NumberFormat

The `Intl.NumberFormat` API can handle percentages, decimals, currencies and locale. Let's check it out.


### Adding commas where needed

```js
Intl.NumberFormat().format(40000); // 40,000
```

### Need support for Spanish?
```js
Intl.NumberFormat('es').format(40000); // 40.000
```

### Currency is a tricky one.
```js
Intl.NumberFormat("en-US", {
  style: "currency",
  currency: "USD"
}).format(40000); // $40,000.00
```

### Currency Again, Spanish?
```js
Intl.NumberFormat("es", {
  style: "currency",
  currency: "USD"
}).format(40000); // 40.000,00 US$
```


## Other Examples

{% stackblitz intl-number-format %}

I'll keep this short and sweet. I encourage you, next time you reach for a library to solve a problem, look to the platform first!

## References
MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat
Browser Support: https://caniuse.com/#search=NumberFormat
A case for productive note taking
Tags: productivity, motivation, startup, discuss
Published: 2019-12-12 17:54:21

You probably know this feeling when something inspiring, interesting, or generally exceptional pops into your head. I have the instant urge to jot it down to make sure it won't go away. And that's exactly what I usually do.

Despite having Notion, Evernote, and many other note apps, I always end up with an uncategorized list of random, out of context sentences in the apple notes app. That makes it difficult to get back and review them later on, not to mention reflecting on particular ideas.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/mpsz7rc7fy4thqkscd0t.png)
My Apple Notes app screenshot


The reason why I have such a mess in my notes is quite simple: Launching a more sophisticated app like Evernote, taking a note, picking the right notebook, tag, or category is friction.

I wonder whether you have this problem too?

I'd like to stop for a moment and make one thing clear - I'm not thinking of another TODO app.

There are various flavors of TODOs. There is a difference between "Buy milk" and "Establish healthy sleep habits". The first is simply a task with a clear definition of completion.
Finding a way to be healthier is rather a long term goal, which should be tackled methodically from various angles.

I think you now know where I'm going.

There is a whole class of notes that are basically ideas you should reflect on over some time. These Ideas convey a lingering value and have the power of habit-forming, changing your mentality, and eventually shaping who you are.

I might have an idea of how to make taking quick, yet essential notes frictionless. But before I even validate the idea, I'd like to ask for your help.

Here are a few categories I identified when going through the notes I took in the last few months:

<b>Quote</b> 
EXAMPLE:
"Wealth creation is an evolutionarily recent positive-sum game. Status is an old zero-sum game. Those attacking wealth creation are often just seeking status." Naval Ravikant

<b>Reflection / Thought</b> 
EXAMPLE: 
"The key to success is doing hard things and explaining them in simple words, never the opposite."

<b>Business Idea / Problem definition</b>
EXAMPLE: 
"A podcast app that allows for easy quote taking by tapping on airpods."

<b>Goal</b> 
EXAMPLE:
"Reduce my SaaS product churn by 30%."

<b>Wording</b> 
EXAMPLE: 
"take a page out of (someone's) book." 

I'd love to learn what kind of quick yet essential notes you are taking. Are some of them fall into one of the categories above? What are the missing categories, in your opinion? 

I'd greatly appreciate your feedback and encourage further discussion. Thanks for reading!
You can now run Github repos on Repl.it!
Tags: github, replit
Published: 2019-12-12 17:49:53

#Repl from Repo
As someone who is still learning to code and is often doing so in a situation where I don't have access to my local files or a code editor (hint, hint, at work during my downtime on the organization's device), I've been using a similar in-browser editor to test ideas or work on my projects. I recently "discovered" [repl.it](repl.it) because I needed an editor that could run Python or Node.JS in browser as I shifted my learning away from the front end HTML/CSS/JS combo. Repl.it has a ton of languages to choose from- even some "toy" languages like LOLCode. Even better, they just leveled up their Github integration. 

{% youtube O2fZ_B6juNc %}
I am pleased to find out that today they began rolling out "Repl from Repo", which allows you to run repos within Repl! It looks like they're still fleshing out the functionality, but it sure does feel good to have another avenues to run my projects and build them in scenarios where I don't always have access to my personal device or files. Even better, all of the repos where I'd have to download them and configure an environment are also able to be run through Repl, so I can easily try out cool looking repos from all types of languages without the commitment of a full on download. 

You can now also add a "Run it from repl.it" badge to your README.md's on Github, which gives folks an instant link to run your project! [Try it here with a game of Minesweeper.](https://github.com/unknownblueguy6/MineSweeper) Be sure to click "Run" once repl.it compiles the project. 

[See more about the functionality in their blog post!](https://repl.it/site/blog/github)
How to configure the imgur API
Tags: authentication, api, oauth
Published: 2019-12-12 17:42:41

This guide explains how to configure the Imgur API, using OAuth2.0 for authentication.

## Overview

1. Sign in to your [imgur account](https://imgur.com) (*step 1*)
1. Create a new application (*step 2*)
1. Grab your credentials (*steps 3*)

## Step by step

**Step 1.** [Sign in to your imgur account](https://imgur.com). Imgur use the same account for their main website, as well as the developers portal.

![imgur-home](https://blog.bearer.sh/content/images/2019/12/imgur-home.png)

**Step 2.** Once signed in, open the [OAuth application registration form](https://api.imgur.com/oauth2/addclient). From there:

* enter your **Application name**
* confirm that the Authorization type is *OAuth2 authorization with a callback URL* (default option)
* register a **redirect URL** to handle the OAuth dance. Use `https://int.bearer.sh/v2/auth/callback` to let Bearer handle the authentication flow on your behalf.
* provide an email

![imgur-apps-new](https://blog.bearer.sh/content/images/2019/12/imgur-apps-new.png)

**Step 3.** Click save and that's it! Imgur will prompt your API keys right away.

![imgur-apps-keys](https://blog.bearer.sh/content/images/2019/12/imgur-apps-keys.png)

> 💡 If ever you need to find your credentials again, they are accessible from [your account settings](https://imgur.com/account/settings/apps).

## Video guide

Follow along as we create a new application:

{% youtube AEHr_H4OMIU %}

## What's next?

You're now all set to build an awesome integration with the Imgur API. To help you get it through easily, here are a few more links:

* [Examples and tutorials](https://www.bearer.sh/integrations/68/imgur-api) curated by Bearer.sh
* [Create a temporary access-token](https://www.bearer.sh/integrations/68/imgur-api/generate-an-access-token) with our generator
* Learn more about the API in the [official documentation](https://apidocs.imgur.com/?version=latest)
HMAC and MAC Explained Simply – Building Secure Auth With JWTs
Tags: cryptography, passwords, programming, security
Published: 2019-12-12 17:28:04

---
title: HMAC and MAC Explained Simply – Building Secure Auth With JWTs
published: true
date: 2019-12-12 17:02:36 UTC
tags: Cryptography,Passwords,Programming,Security
canonical_url: https://qvault.io/2019/12/12/hmac-and-mac-explained-simply-building-secure-auth-with-jwts/?utm_source=rss&utm_medium=rss&utm_campaign=hmac-and-mac-explained-simply-building-secure-auth-with-jwts
---

![](https://qvault.io/wp-content/uploads/2019/12/cybersecurity-speakers.jpg)<figcaption><a href="https://speaking.com/category/it-security/">speaking.com</a></figcaption>

Moved to [Qvault](https://qvault.io/2020/08/05/hmac-and-mac-explained-simply-building-secure-auth-with-jwts/)
Decorator in PHP [Design pattern with examples]
Tags: php, designpattern, decorator, oop
Published: 2019-12-12 16:50:29

---
title: Decorator in PHP [Design pattern with examples]
published: true
description: Design patterns help solve software problem, the Decorator Pattern will add features to your object a piece of cake
tags: php, design pattern, decorator, OOP
cover_image: https://anastasionico.uk/img/blog/decorator-in-php-design-pattern-with-examples.jpg
---

If you are reading this post there are two options.

You are an excited beginner coder, one that is trying to understand what is happening with the PHP language,
or
you are an experienced developer but that still wants to be up-to-speed and always improve.

Either way, you are in the BEST POSITION to learn how to structure your code.

You can do so by learning design patterns,


They provide a solution to problems that occur often when developing web applications.

In this episode of the series, we'll discover the Decorator pattern,


the one that enables us creating a structure for multi-features objects.

We'll do so by using a lot of actionable examples and step by step explanation.

[READ THE FULL ARTICLE HERE](https://anastasionico.uk/blog/decorator-in-php-design-pattern-with-examples)
Resolve vs Reach
Tags: devops, distributedsystems
Published: 2019-12-12 16:48:10


I have seen lot of people confuse between resolving dns vs reach IP. So this small blog.

Inorder to get data from any computer we need to know the address of the computer which is IP address. Let's say we want to get some data from google and its IP is `172.217.31.196` (currently). Its very hard to remember this IP and also they can have multiple machines(IPs) which will give the same data (horizontal scaling). So we cannot remember IPs. So we need a map (key: name, value: IP) stored in a server called DNS whose IP is configured automatically (done by DHCP server) when we connect to internet (8.8.8.8 or 1.1.1.1 or your custom dns server). 

So when we do `www.google.com` in browser
    
    1) Check which dns server to use in `/etc/resolve.conf`
    2) Use that dns server to get the `ip address` of www.google.com
    3) Use that IP address to connect and transfer data

**First two steps** is `resolve` and **third step** is `reach`.


### Example:
1. Let's say we have private network and to access machines inside that network, we have to connect to the VPN. There is an application running in that network in machine `172.11.11.11`. We can add entry in dns. Key is `www.myapplication.com` and value is `172.11.11.11`. Once that is done, anybody can **resolve** `www.myapplication.com` to `172.11.11.11` as we added entry in public dns server. But it is reachable only to people who are connected to the VPN.

2. Let's say I want to expose/transfer some data to my colleagues. And my ip is `192.168.1.4` which is private and will be accessible only to the people whose is in my network. Instead of asking my colleagues to use this IP, we can put an entry in public DNS server (8.8.8.8 or 1.1.1.1). Key is `www.dineshba.com` and value is `192.168.1.4`. Once that is done, anybody can **resolve** `www.dineshba.com` to `192.168.1.4` as we added entry in public dns server. But it is reachable only to people in my network.
How do you plan a personal project?🧭
Tags: discuss
Published: 2019-12-12 16:45:10

<h4>Hello, users!</h4>

I'd like to start planning a project where design, programming, researching and a lot of writing will be required. However, I feel a bit **lost**.

I'm pretty comfortable with my knowledge but I don't know where or how to start. How do you plan your projects? Do you follow a schedule? Do you organize it with notes?

I know I'm not getting into details, I'd like you to think about your last personal project if possible and try to explain how you organized it in your head/paper/pc.

Thank you in advance, see you around, I'll be reading!
A brief introduction
Published: 2019-12-12 16:29:47



After a long time without a blog, it's time to put pen to paper again.

The immediate cause is simple: I'm about to become a father. 👶 As the CTO of a company that provides resources for working parents and those who manage them, I'm well resourced. But I've now become one of our users, and I'm encountering everything for the first time. Selfishly, I hope this will improve my understanding of our users' journeys — but I promise to share my honest thoughts too.

I'll also aim to share code and tips from a more technical perspective.
Rails 1.0 turns 14
Tags: ruby, rails, history, todayilearned
Published: 2019-12-12 16:28:44

_Past Rubies is a tiny weekly newsletter that shares curated historical content from the Ruby community. Consider it Ruby&#39;s version of &#39;on this day in history&#39;. New issues every Wednesday. [Get copies to your inbox](https://www.getdrip.com/forms/275494850/submissions)_

* * *

## [10 more features in Ruby 2.5](https://tom-lord.github.io/10-More-New-Features-In-Ruby-2.5/)
  

 ![Odwgr6o](https://i.imgur.com/oDWGr6O.png)
  

_It&#39;s Christmas which means new Ruby time! But I think it&#39;s all too easy to forget the new features of recent versions so we can utilize the latest Ruby goodness! Here&#39;s a great writeup published this week in 2017 on those features in Ruby 2.5_

## [A pagination helper for Rails in 2004](https://web.archive.org/web/20090815113042/http://redhanded.hobix.com/inspect/aPaginationHelperForRails.html)
  

 ![Hyrr5sk](https://i.imgur.com/HyRr5SK.png)
  

_Well would you look at that! A little cheeky banter between Ruby legends \_why and DHH this week fifteen years ago. This is a neat little peek into Rails pagination in 2004, a year before 1.0 was released! (Yes, it&#39;s that old of a problem space)_

## [What are events, why you might care, and how EventMachine can help](https://web.archive.org/web/20120222115215/https://www.engineyard.com/blog/2011/what-are-events-why-might-you-care-and-how-can-eventmachine-help)
  

 ![Biqglmx](https://i.imgur.com/BiqgLMx.png)
  

_This is a great little writeup on the EngineYard blog by Kirk Haines on events and event machine (published this week in 2011)_

## [The 2005 Ruby Advent Calendar](https://web.archive.org/web/20061115100130/http://farm.tucows.com/_archives/2005/12/16/)
  

 ![6cm9fyy](https://i.imgur.com/6CM9fyY.png)
  

_Who remembers reading the Tucows blog back in the day? It was a massive source of info for Rubyists in the early coding days. Here&#39;s a glimpse into the Ruby Advent Calendar they were hosting in 2005 (note: the famous PeterC also had a few that may yet get featured this month!)_

## [Neat Ruby snippets 2004](https://web.archive.org/web/20061115100130/http://farm.tucows.com/_archives/2005/12/16/)
  

 ![Aoo2vi1](https://i.imgur.com/aOO2VI1.png)
  

_Gosh, I haven&#39;t hustled through the RubyTalk archives yet... That changes this week! Here&#39;s a pleasant fifteen year old (this week) thread on interesting Ruby snippets that accomplish cool things. (We&#39;re talking servers in six lines)_
What I learned making my first open-source pull request
Tags: opensource, todayilearned, dotnet
Published: 2019-12-12 16:27:57

Last night I took a bold first step as a developer and opened my first official open-source pull request. I've been testing the waters with the Dapr framework recently, and the .NET Core API's were missing some key functionality.

What better way to get these features in the libraries than to just dive in and do it myself. 

## Strict code guidelines are great

The Microsoft code repositories have a very strict set of StyleCop rules associated with them. From everything to the comments on your classes/constructors/methods through to having too many white spaces. 

Couple that with the build treating these style rules as errors, and I had a rather error-filled start to my development.

I don't consider myself to be a messy programmer, well at least I didn't. But having these rules taught me that I need to pay more attention to this kind of thing.

It's also made me want to borrow some of Microsoft's rules and implement them in my own company. Especially the rules around commenting and documenting.

Having enforced comments, made understanding the existing so much easier.

## Copy and Paste is the enemy

The code I actually implemented, was almost a direct clone of some functionality that was already in the library. 

As a starting point, an exercise in copy and paste seemed a time-saving first step. How wrong I was!

Whilst the pasted code I forgot to change wasn't necessarily a 'bug', it does make you feel a little bit daft when the first review comment to your first pull request is about the wording of comments not making sense.

## Open Source is amazing

There aren't many other industries, where if something is missing from an item you need you can just go and add it yourself.

If your new speakers don't support Google Assistant, well that's just tough.

If the user manual you are reading isn't detailed or feature-rich enough, you can't just go and re-print it.

However, in the world of open-source software, this is entirely possible.

If an open-source library doesn't have a feature you need, it isn't as performant as you'd like or just isn't documented very well you can just go and change it. 

Microsoft's commitment to open source is a masterstroke as far as I see it.
They've expanded their developer base by thousands and, with a good set of code rules and reviewers, improved their code quality and cycles immensely.

The pull request I opened still hasn't been fully approved, but this first experience has certainly made me want to get more involved. 

If you're a developer who uses open source software, take the plunge and get involved! One of the best ways to say thank you to the open-source community is to get involved and help fix some issues.

For anyone interested in the pull request in question, you can check it out [here](https://github.com/dapr/dotnet-sdk/pull/185).
Managing your Public and Private Container Registries
Tags: containers, registry, devops, security
Published: 2019-12-12 16:27:12

Container registries have become an essential part of our (work) lives with the increasing usage of various containers, and container management tools, used in our CI/CD processes. As developer and DevOps enthusiasts, we surely find the need to have a registry that can be robust and scalable according to our needs. It is also requisite that the access to these registries is in accordance with our business use cases.  

Using the [JFrog Container registry](https://jfrog.com/container-registry/), here’s how we can have our public and private repositories segregated and managed using the basic permissions model. 

**Public repositories**
The public repositories are the ones that can be accessed by anyone in our organization regardless of the team they belong to. To make them public, all we need to do is to enable anonymous access generally (Under Admin-&gt; Security Configuration) and give the user ‘anonymous’ appropriate permissions to these repositories or builds that use these public repositories.
 

*Step 1: Enabling anonymous access to the instance*
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/3qz43yesmf6oeh2a9bs4.png)  


*Step 2: Allocating appropriate resources (repositories/builds)*
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/4n5f2opag9qm3k1eeild.png)
  

*Step 3: Giving the user ‘anonymous’ required permissions to the resources*
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/x49co8zejf2z1j23hnoj.png)  
  

    
**Private repositories**
The private repositories are the ones that are being utilized by a particular user/team or a group of teams in your organization. The access to these repositories can be based on the teams - groups, or users.   

To give pertinent role-based access control to these repositories, we just need to allocate users or groups apt permissions to these resources (repositories/builds) based on the use cases.
 

*Step 1:Include the relevant resources (Private repositories/Builds) in a Permission Target*
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/jtfiuq5brxz8tldes2ll.png)  
  

*Step 2: Give apt permissions based on the Business use cases (Team-based permissions)*
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/72hj8g3qohyxxi0q168g.png)
    

Additionally, the users of a registry can authenticate using [LDAP integration](https://www.jfrog.com/confluence/display/RTF/Managing+Security+with+LDAP) as the JFrog Container Registry is powered by Artifactory. These users can then be set up to have different permissions/groups in the Registry instance based on the Permissions model of the organization.
  
In this way, managing all of your public, as well as private registries, can be easy and secure with a Container Registry that you can always trust.