teleren/devto huggingface dataset:
Minimum Number of Arrows to Burst Balloons
Tags: javascript, algorithms
Published: 2020-03-20 10:00:12

Question: There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. your task is to burst all the balloons with a minimum number of arrows.
Eg: let suppose given array is the horizontal diameter of ballons : [[1,3],[2,7],[5,9],[2,9],[9,12],[8,10],[12,15],[11,13]] and your task is to find minimum number of arrows to burst all balloons.

Let's break it down.
1> Balloons can be seen as x-coordinates start and end points.
2> We're aiming for bursting as many balloons as possible in a single arrow.
3> This leads us to find all the balloons whose x-coordinates overlap so that we can cover maximum possible balloons.
4> Also note that inputs are not strictly increasing/decreasing start and end points, will sorting help us? 

Let's visualize it.

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

This is how balloons stack up.

From the above observation we can say that we're greedily choosing ballons that have common start and end point range.

Step 1:
Since we're finding common start and end points, random start and end points won't help so let's sort the array.
balloons : [[1,3],[2,7],[2,9],[5,9],[8,10],[9,12],[11,13],[12,15]]

Step 2:
We need a start and end points of the first balloon as the initial point. 
end = balloon[0][1] // 
count =1 // need at least one arrow to burst one balloon

Step 3: 
Now how to proceed further? Lets go to back to our basic requirement, burst as many balloons as possible with one arrow. So we've to find all the balloons whose start and end diameters lie between the current start and end diameters. 
```javascript
balloon 1: 
start = 1 
end = 3

balloon 2: // within range
start = 2
end = 7

balloon 3: // within range
start = 2
end = 9

balloon 4: // out of range 
start = 5
start = 9
```

let burst first three balloons with one arrow
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/1i1dtpeyr8c3vn7xf4uz.jpg)
Arrow 1

Since balloon 4 was out of the range of the previous arrow, we need one more arrow to shoot down balloon 4, but at the same time we have to burst as many balloons as possible with it.  

These observations will help us derive to our solution. 

let's write some code :

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

First arrow : 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/1i1dtpeyr8c3vn7xf4uz.jpg)
Arrow 1 start = 1, end = 3 burst balloons [1,3],[2,7],[2,9]

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/8hi3fllg1zjjzcnio6vd.jpg)
Arrow 2 start = 5 end = 9  burst balloons [5,9],[8,10],[9,12]

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/gpnadbz11iufa5h4gi19.jpg)
Arrow 3 start = 11 end = 13 burst balloons [11,13],[12,15]

Now you know how to burst balloons

github :  https://github.com/AKHILP96/Data-Structures-and-Algorithms/blob/master/problems/burstBalloons.js
Finally updated my personal site
Tags: react, gatsby, career, javascript
Published: 2020-03-20 09:43:12

---
title: Finally updated my personal site
published: true
description: Article about my personal site update.
tags: #react #gatsby #career #javascript
---

Last year I went full freelance *webdev*, after some years of corporate employment. It was a very busy and creative period of my life full of learning, and I really wanted to update my old site with my newly obtained skillset. Unfortunately due to this whole *covid-19 situation*, I really had to hurry to get this site done to be able to put it into use.
So my point is, it's beta, I'm still refining it. 

Check it out [HERE](https://www.lenkovits-develops.com/)
For comparison here's the [old site](https://loving-hawking-c6ac25.netlify.com/).

It's a **Gatsby** site, using **Contentful** as CMS. I know it's a bit cheesy but I must admit, I took the idea for the vertical menu from Riot's [Valorant](https://playvalorant.com/en-gb/).

Have at it dev.to!
Covid-19 API
Tags: covid19, corona, restapi
Published: 2020-03-20 09:27:45

---
title: Covid-19 API
published: true
description: An open API for monitoring the covid-19 pandemic
tags: covid19, corona, rest-api
---
Hey guys, I made a tiny API that saves an hourly snapshot of the covid-19 status of every country (starting the evening of 03/17), based on [this](https://github.com/javieraviles/covidAPI) project's rest API.

I don't have a specific use for it yet, but I thought that it might be useful for the people among you who are developing corona related side projects. 

So feel free to use it. Feel free to suggest uses for other people if you have any ideas. Feel free to ask me to expand the API if there's any unanswered need.

Currently the only endpoint is for by-country sampling: 
`http://covid19.soficoop.com/country/{countryCode}`
(e.g. [http://covid19.soficoop.com/country/us](http://covid19.soficoop.com/country/us))

I'm also attaching a link to the repo:

{% github avirankatzsofi/covid19-api %}

That's it. I'd love to hear your thoughts.
Stay safe!
How To Develop Growth Mindset
Published: 2020-03-20 09:20:46


Having a growth mindset is believing that you are in control of your own ability, and can learn and improve your self which is one of the main key of success
 
So how do you develop your mindset 

A mindset is a set of assumptions, methods, or notations held by one or  groups of people. You can read more on [Wikipedia] (https://en.wikipedia.org/wiki/Mindset) And in this world there is two main types of mindset,
there is one that believes qualities such as intelligence and talent are changeable traits. or ones that believe that these qualities are inborn, fixed, and unchangeable but the one who can develop the ability through hard work and effort to achieve or improve any of the qualities that is said to be god given or unchangeable are the one with the positive mindset 

this is how i have created a growth mindset 
I use to have an undeveloped mindset as many of us have before we understand the growth mindset
before i didn't know what growth mindset was and as i worked on different project, i always wanted to get through everything without working as hard as i should 
i use to search for the shortcuts every-time i was stack, but after i understood 
the growth mindset and having the control of my own ability to learn and improve myself, i started working on learning and improving my skills


so before i had what i can call a positive mindset cause i always wanted to work on different project but i was lacking the ability to control myself, and this where growth mindset comes in 

creating a growth mindset will start by you understanding that you can improve your nature, and you are in the control of your self,
and that's all it takes.
creating a growth mindset will effect positively your life by which you will be able to work hard and improve your self belief
you will able to view a setback as an opportunity to learn. instead of a threat for you to quit 
your brain will become more responsive and active when finding solution and 
you will become the best version of your self 

developing your growth mindset could be the most important thing to help you achieve success and every time you hear voice in your head telling you that you can’t do something, reply with a growth mindset approach and tell it you can learn improve and conquer whatever that is you are facing
CORS
Tags: ajax
Published: 2020-03-20 09:18:56

[跨來源資源共用（CORS）](https://developer.mozilla.org/zh-TW/docs/Web/HTTP/CORS)
[輕鬆理解 Ajax 與跨來源請求](https://blog.techbridge.cc/2017/05/20/api-ajax-cors-and-jsonp/)
這套規範跟你說，如果你想開啟跨來源 HTTP 請求的話，Server 必須在 Response 的 Header 裡面加上`Access-Control-Allow-Origin`。

node Express [cors](https://expressjs.com/en/resources/middleware/cors.html)

```js
app.post("/api/request_disclosure", async (req, res) => {
    res.json(req.body);
});
```
Create a hotspot in your linux(debian) machine
Published: 2020-03-20 09:09:42



 - Install hostapd(hotspot server) and dnsmasq (dns dhcp server) : `sudo dhclient eth0 or sudo dhclient wlan0`
 - Prevent the installed services starting at the start up : 
    - ` sudo service hostapd stop`
    - ` sudo service dnsmasq stop`
    - `sudo update-rc.d hostapd disable`
    - `sudo update-rc.d dnsmasq disable`
  - Setup the configuration file of dnsmasq : `sudo gedit /etc/dnsmasq.conf` 
    - paste the code below :
  
            # Bind to only one interface
            bind-interfaces
            interface=wlan0
            dhcp-range=192.168.150.2,192.168.150.10

- Setup the configuration file of hostapd : `sudo gedit /etc/hostapd.conf` 
    - paste the code below :
  
            interface=wlan0
            driver=nl80211
            ssid=JackSparrow
            hw_mode=g
            channel=11
            wpa=1
            wpa_passphrase=test12345
            wpa_key_mgmt=WPA-PSK
            wpa_pairwise=TKIP CCMP
            wpa_ptk_rekey=600
            macaddr_acl=0

**You should change the ssid and wpa_passphrase to your preferences**


- Create hotspot.sh file :`sudo gedit hotspot.sh`
  - paste the code below :
  
            #!/bin/bash
            # Start
            sudo ifconfig wlan0 192.168.150.1
            sudo service dnsmasq restart
            sudo sysctl net.ipv4.ip_forward=1
            sudo iptables -t nat -A POSTROUTING -o eth0-j MASQUERADE
            sudo hostapd /etc/hostapd.conf
            sudo iptables -D POSTROUTING -t nat -o eth0-j MASQUERADE
            sudo sysctl net.ipv4.ip_forward=0
            sudo service dnsmasq stop
            sudo service hostapd stop


- Now, execute the shell script : `sh hotspot.sh`
How to Minimize Chances of Black Swan Effect
Tags: productivity, blackswaneffect
Published: 2020-03-20 09:06:44

Given the ongoing situation that snowballed into a management issue for majority of industries in more than 150 countries, discussing ways of minimizing the Black Swan events is very timely. 

Read full article here https://blog.tmetric.com/how-to-minimize-chances-of-black-swan-effect/
postman
Published: 2020-03-20 08:54:34

Post，因為Post通常都會是傳送Json去伺服器端，這邊有兩種做法，一種是如下圖的例子，使用x-www-form-urlencoded的方式去打post，web api也是能吃

一種則是直接寫Json的方式，這時候Headers必須先加上Json的格式，這也是現在比較通用的做法

[Header] Content-Type / application/json
[Body] raw

utils\request.js
```js
const JSON_HEADERS = {
    "Accept": "application/json",
    "Content-Type": "application/json"
};
```
然後就可以直接在`raw`裡面寫json
Deploy your ExpressJS app to zeit Now
Tags: zeit, express, node
Published: 2020-03-20 08:35:43

---
title: Deploy your ExpressJS app to zeit ▲ Now
published: true
description: How to deploy your ExpressJS web app to zeit hosting 
tags: #zeit, #expressjs, #node, #nodejs
---


**🙄 What is Zeit?**

ZEIT is the easiest way to deploy websites. Host your web projects with zero configuration, automatic SSL, and global CDN. You can visit their website https://zeit.co/ and explore more things.

In this article, we are going to deploy out expressjs web app to ▲ zeit now before we deep dive you have installed **Node.js 10 LTS** on your machine and zeit account.

Next install now globally on your machine using npm or yarn
```
$ npm i -g now
```

After installation configure your account
```
$ now login
```

Clone my repository
```
$ https://github.com/BhautikChudasama/Node-with-zeit.git
```

In this repository, I created the template of expressjs web app and you can also replace your code in index.js 

Here is source code of *index.js* that sends the response *Hello from zeit* whenever **/** and for other wildcards, such **/any, /aa, /xyz** that sends *wild card* in response

Next we bind our app to 5000 port.

```js
const express = require("express");
const app = express();

app.get("/", (req, res) => {
    res.send("Hello from zeit");
});
app.get("**", (req, res) => {
    res.send("wild card");
});

app.listen(5000, () => {
    console.log("App is listening on port 5000");
});
```

Open your terminal and fire
```
$ now
```
that asks some basic questions
```
$ now
? Set up and deploy “F:\zeit-demo”? [Y/n] y
? Which scope do you want to deploy to? Bhautik
? Link to existing project? [y/N] n
? What’s your project’s name? zeit-demo
? In which directory is your code located? zeit-demo/
�🔗  Linked to ** (created .now and added it to .gitignore)
�🔍  Inspect: URL [Hidden]
✅  Production: https://zeit-demo-six.now.sh [copied to clipboard] [42s]
�📝  Deployed to production. Run `now --prod` to overwrite later (https://zeit.ink/2F).  
�💡  To change the domain or build command, go to URL [Hidden]
```

✌️ After successful deployment that copied the production URL into the clipboard and now you can explore the app in your browser.

Try open https://zeit-demo-six.now.sh/ that show **Hello from zeit** and https://zeit-demo-six.now.sh/dev that show **wild card** in the response.

**Thank you** for reading my first article in dev.to and you can follow me on twitter also @bhautiktweets 😊
Quick Tip – How to make a TextView bold or italic ?
Tags: android, todayilearned, mobile, java
Published: 2020-03-20 07:06:35

---
title: Quick Tip – How to make a TextView bold or italic ?
published: true
date: 2020-03-20 07:00:00 UTC
tags: Android,todayIlearned,Mobile,java
canonical_url: https://10xlearner.com/2020/03/20/quick-tip-how-to-make-a-textview-bold-or-italic/
---

Hello ! I’m Xavier Jouvenot and in this small post, I am going to explain how to change `TextView` into a bold or italic.

_Self promotion_: You can find other articles on Android development on my [website](www.10xlearner.com) 😉

## Bold or Italic by default

To transform a `TextView` text into a bold or an italic text, there are several solutions.And the first one we are going to see is how to make it bold or italic by default.

To do so, we are going to modify the `TextView` XML definition, and add one attribute to it.This attribute is `android:textStyle` and can be set to `bold`, `italic`, `normal` or `bold|italic`, in case you want you text to be both bold and italic.

Here is how it look like:

```
<TextView
    <!--Some attributes-->

    android:textStyle="bold"

    <!--Some other attributes --> >;
```

If not specified, this attribute is set to `normal`.

## Modify the text style dynamically

Specifying the attribute in the XML is great!But if you want to modify the style of a `TextView` while the program is running, then, you must use some Java code and the method `setTypeface`.

Here is how it looks like:

```
TextView tv = findViewById(R.id.my_text_view_id);
tv.setTypeface(tv.getTypeface(), Typeface.ITALIC);
```

In this sample of code, you can replace `ITALIC` by `BOLD`, `NORMAL` or `BOLD_ITALIC` depending on what you want to do with your `TextView`.

* * *

Thank you all for reading this article,And until my next article, have an splendid day 😉

## Interesting links

- [android:textStyle documentation](https://developer.android.com/reference/android/widget/TextView#attr_android:textStyle)
- [setTypeface documentation](https://developer.android.com/reference/android/widget/TextView#setTypeface(android.graphics.Typeface,%20int))
- [Typeface documentation](https://developer.android.com/reference/android/graphics/Typeface)
- [10xlearner website](www.10xlearner.com)
Sticky Social Bar Using CSS
Tags: webdev, css, codenewbie, weeklyui
Published: 2020-03-20 06:56:07

The sticky bar is important for all websites to show a website link with others. So here we build a social media sticky bar using CSS and HTML.

In this element, we used font awesome icons CDN and also we used CSS media queries. To make our bar responsive to mobile-side as well as tablets-side. Here we used HTML ‘ul’ and ‘li’ tag with CSS basic properties. In this sticky bar, we used CSS position and transform properties to make the element more attractive. 

Make it yours now by using it, downloading it and please share it.

[Download Sourecode](https://w3hubs.com/sticky-social-bar-using-css/)
New Features on 19th March
Tags: release, sprint75
Published: 2020-03-20 06:33:55

We've just completed Sprint 75 and here's the start of many posts that will document shiny new stuff from our weekly deployments (hopefully these can become more frequent, but policies are policies!):

- - -

Here's what's new this time:

# Features

## New section header in resume analysis

If you've been using our new resume analyzer feature (powered by [JobScan](https://www.jobscan.co/)), you'd notice that we have a new section to provide work experience recommendations for your uploaded resumes.

![Check Resume modal showing Experience section header](https://dev-to-uploads.s3.amazonaws.com/i/0remjmacfg1zf1ntuu11.png)

> If you haven't been, [why haven't you?](https://mycareersfuture.sg)

## Updated UI for nudges

Our sister team had also worked on some of the digital nudges that we've had from a few deployments ago, adding a **Learn More** button and making it arguably more user-friendly than before by having both a mobile and desktop version:

![Mobile view of nudges](https://dev-to-uploads.s3.amazonaws.com/i/ma6dr8kxtf44aw4jgi6r.png)
![Desktop view of nudges](https://dev-to-uploads.s3.amazonaws.com/i/kxfj3n8d3yi2fypd0o6c.png)

# Bugs Fixed

1. When all skills in the skills box are deleted, the nudge box no longer disappears.

- - -

Till next time! Got feedback/flames/feature requests? Drop us a note in the comments section and we'll get back to you-
New UI for Covid-19 tracker and PWA support
Tags: webdev, showdev, pwa, ui
Published: 2020-03-20 06:14:20

I've updated the UI for my Covid-19 tracking and reports app. 
Share your reviews.

Link ; https://novel-coronavirus-reports.netlify.com

## Splash
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/k919v1v0mnpsxcwvdio7.jpg)

## Home
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/krw3rf4bg957pkm89f26.jpg)

## Map
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/r154oj46wi3rk2shyems.jpg)

## Reports section
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/j7ikkimxati1xwo45vyf.jpg)
Issues with AlpineJS + Datatables
Tags: help
Published: 2020-03-20 05:28:22


Hello fam, I'm working on a admin dashboard UI and using [AlpineJS](https://github.com/alpinejs/alpine) for small interactions.

 I got some data to deal with as well and I'm using vanilla JS library called **[Simple-DataTables](https://github.com/fiduswriter/Simple-DataTables)**

Now my issue is - say I got two tabs on my page and one of the tab is visible by default and datatables are just perfect and another one is set to `display:none` by AlpineJS.

Now, when I switch to another tab, the table is there but no datatable controls and tried a lot like the options datatable library provides like `.init()` `.refresh()` `.update()`

I don't want to use jQuery or something, please help me with this! :)

I'm here if you need anymore info or code :)
Install Odoo 11 on Ubuntu 16.04
Tags: odoo, ubuntu
Published: 2020-03-20 05:06:18

What is Odoo?

Odoo ERP stands for On-demand Open Project ERP. Odoo is also known as OpenERP. Odoo was founded by Fabian Pinckaers in 2005. Odoo is a collection of business applications and modules like CRM, Sales, Warehouse, Accounting, Manufacturing, and Human resource..etc.

How to Install Odoo 11 on Ubuntu 16.4?

Step 1: Update the Server
Make your system Updated using these two commands
sudo apt-get update
sudo apt-get upgrade

Step 2: Secure Server
Run this command to make your server/system remotely accessible
sudo apt-get install openssh-server fail2ban

.....................................................................

Originally Published at <a href="https://www.cybrosys.com/blog/how-install-odoo11-on-ubuntu">Install Odoo 11 on Ubuntu 16.04</a>
Simplify AWS IAM Role Trust Policies in Organizations
Tags: aws, security, iam
Published: 2020-03-20 04:58:32


## Background
As a company scales out the number of AWS accounts used for different workloads, they may require IAM roles which are able to be assumed by any other account within the organization to perform some action, if you are trusting accounts by adding each account principal to the trust policy you may soon find your self hitting the 2048 character limit.

## Solution
### Use conditions
When making use of conditional filters and the inherent trust that comes from being within an organization, you can dramatically reduce the size and complexity of policies.

**From listing all explicit account IDs**
```YAML 
  OrgWideRole:
    Type: AWS::IAM::Role
    Properties:
      RoleName: OrgWideRole
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal:
              AWS:
                - '012345678901'
                - '123456789012'
                - '234567890123'
                - '345678901234'
                - '456789012345'
                - '567890123456'
                - '*150 or so more account IDs*'
            Action: sts:AssumeRole
```

**To trusting the organization ID**
```YAML 
  OrgWideRole:
    Type: AWS::IAM::Role
    Properties:
      RoleName: OrgWideRole
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal:
              AWS:
                - '*'
            Action: sts:AssumeRole
            Condition:
              StringEquals:
                aws:PrincipalOrgID : o-12345abcd
```

You can change the behavior to limit to accounts associated with a specific OU by using conditional key `aws:PrincipalOrgPaths` 

**e.g.**
```YAML
  Condition:
    ForAnyValue:StringEquals:
      aws:PrincipalOrgPaths:
      - o-12345abcd/r-eg123/ou-example123/
```

Further extension of this is possible by using `StringLike` operator to trust all children of the OU

**e.g.**
```YAML
  Condition:
    ForAnyValue:StringLike:
      aws:PrincipalOrgPaths: 
      	- o-12345abcd/r-eg123/ou-example123*
```

There are more permutations of this possible to fit your needs, though implementing trust via organization membership or OU membership has significantly reduced our trust policy sizes while increasing scalability of the platform.


### Useful References
[AWS Global Condition Context Keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html)
[IAM and STS Limits](https://docs.amazonaws.cn/en_us/IAM/latest/UserGuide/reference_iam-limits.html)
Add openAPI document to your maven Spring-boot project
Tags: openapi, springboot, maven
Published: 2020-03-20 04:46:42

---
title: Add openAPI document to your maven Spring-boot project
published: true
description: 
tags: #OpenAPI #Spring-boot #maven
---
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/9134d4glncyioyjnq4fg.jpeg)
                   Photo by Lanju Fotografie on Unsplash

I.What is OpenAPI
OpenAPI Specification (formerly Swagger Specification) is an API description format for REST APIs. An OpenAPI file allows you to describe your entire API, including:

- Available endpoints (/users) and operations on each endpoint (GET /users, POST /users)
- Operation parameters Input and output for each operation
- Authentication methods
- Contact information, license, terms of use and other information.

API specifications can be written in YAML or JSON. The format is easy to learn and readable to both humans and machines. The complete OpenAPI Specification can be found on GitHub: [OpenAPI 3.0 Specification](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md)

You can find out more information about OpenAPI from [here](https://swagger.io/docs/specification/about/)

By the end of this post, you should be able to see the API documentation like below:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/uh7dq76w6lygpel17sa5.png)

II.OpenAPI documentation
What dependency we need to add to POM file

{% gist https://gist.github.com/cuongld2/781ae60e730c085cab28a912c7b93f90 %}

We also need to add some annotation to the controller api file

{% gist https://gist.github.com/cuongld2/4ddd34c8df73c5af7c1a86f6da9c4ab5 %}

That’s it. Run the maven spring-boot project to see what happens

```javascript
mvn spring-boot:run
```

You can navigate to the [default url](localhost:8081/swagger-ui.html) in your browser to check the documentation.

The full source code can be found in github from [here](https://github.com/cuongld2/springboot-simpleAPI).

Happy coding ~~