teleren/devto huggingface dataset:
How to remove whitespaces from a string in java
Tags: java, programming, computerscience
Published: 2020-12-20 10:56:11

In this article, we will learn **how to remove spaces from a string in java**
In thisblog, we will learn how to remove the whitespace from a string in java. One method uses a brand built-in method that will be useful when you are developing applications and other methods do not use the built-in methods that will help to interview you. Because, in the interview, the interviewer always asks to not use the built-in method while testing your coding skills

 
###How to Remove White Spaces Of String in Java Using Built-In Methods?
In the first method, we use the method replaceAll () of the String class to remove all whitespace (including tabs as well) from the string. It is one of the easiest ways to remove the spaces from the string in java. replaceAll () method takes two parameters. One of them is the string to be replaced and another one is the string that will be replaced with. We passed the string "\ s +" to be replaced with an empty string "". This method removes spaces at the end, the space at the beginning and a space between the words.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

---
title: originally posted here 👇
canonical_url: https://kodlogs.com/blog/2204/how-to-remove-spaces-from-a-string-in-java
---

###Program
```
java.util.Scanner import;
 
Public class RemoveWhiteSpaces
{
    public static void main (String [] args)
    {
        Scanner sc = new Scanner (System.in);
         
        System.out.println ( "Enter input string to be cleaned of the white space ...!");
         
        String inputString = sc.nextLine ();
         
        String stringWithoutSpaces = inputString.replaceAll ( " s +", "");
         
        System.out.println ( "Input String:" + inputString);
         
        System.out.println ( "String Input Without Spaces:" + stringWithoutSpaces);
         
        sc.close ();
    }
}
```
###output:

Enter input string to be cleaned of the white space ...!
One space TwoSpaces ThreeSpaces FourSpaces Tab End
String input: one space TwoSpaces ThreeSpaces FourSpaces Tab End
Put String Without Spaces: OneSpaceTwoSpacesThreeSpacesFourSpacesTabEnd

**Note:**

"\ s +" Vs "\ s": Both of these strings, when passing to replaceAll () method, produce the same results with similar performance. But, when the number of consecutive rising space, "\ s +" is a little faster than the "\ s". Because, replacing some space set in a row
with the replacement string at a time rather than replacing one by one.
trim () method trims string given mis eliminate white space at the beginning and at the end of the string, not the words.
[Find more in original post](https://kodlogs.com/blog/2204/how-to-remove-spaces-from-a-string-in-java)
Type checking JavaScript
Tags: javascript
Published: 2020-12-26 05:57:15

---
title: Type checking JavaScript
published: true
date: 2020-12-20 10:51:00 UTC
tags: JavaScript
canonical_url: https://drmsite.blogspot.com/2020/12/type-checking-javascript.html
---

[![](https://1.bp.blogspot.com/-JgjLlouJkK4/X98sDT9xCgI/AAAAAAAAo8Y/xJYRGhjfsXgYjgTzsulJcPhyf6OXXw5ogCLcBGAsYHQ/s320/man_in_blue_and_white_checked_dress_shirt-scopio-2c072d18-0cf0-4b3e-a7f4-f4014495a98d.jpg)](https://1.bp.blogspot.com/-JgjLlouJkK4/X98sDT9xCgI/AAAAAAAAo8Y/xJYRGhjfsXgYjgTzsulJcPhyf6OXXw5ogCLcBGAsYHQ/s2048/man_in_blue_and_white_checked_dress_shirt-scopio-2c072d18-0cf0-4b3e-a7f4-f4014495a98d.jpg)
<label style="display:flex; justify-content: start; align-items: center; font-family: Barlow"><a style="display:flex; align-items: center" href="https://scop.io"><img height="20x" src="https://cdn.shopify.com/s/files/1/2395/7099/t/46/assets/icon_2x.png?v=17766308506443902960" style="margin: 0px 10px 0px 0px"></a> By <a style="text-decoration: none; margin: 0px 5px;" href="https://scop.io/collections/vendors?q=Adam+Drobiec">Adam Drobiec</a></label>

I read an [article](https://gils-blog.tayar.org/posts/jsdoc-typings-all-the-benefits-none-of-the-drawbacks/) yesterday by Gil Tayar, which was fascinating. In it, he talked about his journey from strongly typed languages to untyped languages and back again. I'd recommend reading the article; it's well written and very informative.

His main gist seemed to be that TypeScript wasn't all that bad. I agree, and I've used it on and off for ages, I think I even have a certificate for a course somewhere, but I'm all for the flexibility of JavaScript.

Anyway, after reading it, I thought I'd give it a go, mostly as I wrote [something](https://dev.to/mouseannoying/javascript-classes-es5-and-es6-2ina) a little while back which already implemented JSDocs. The process wasn't all that hard but was a bit of a faff. The odd wobble came from destructuring arguments in one of the constructors of one of the toy car child classes, and I was blown if I could understand the differences between String and string types until I read up some more. There were a few such quibbles, and TypeScript had issues with a few of my more relaxed approaches to JavaScript - such as explicitly checking for the existence of variables using `!!`. You can check out some of the other changes on a [branch on GitHub](https://github.com/annoyingmouse/class_examples/tree/typechecking).

I'm not sure I'll do it again, but it was worth spending a little while playing with it last night. It certainly would help in terms of distributing code to other developers, especially in terms of the automatic type checking offered by many IDEs and editors. I'm not overly sure of the **`strict`** setting - I like the whole fast and loose aspects of JavaScript quite a lot but, indeed, if I were to upload an NPM package I'd be inclined to be a little more rigorous.
The document could not be saved. A number is out of range.
Tags: computerscience, productivity
Published: 2020-12-20 10:49:25

When the user tries to view a PDF or delete a page from a PDF, then you see an error message;
`
“A number is out of range.”
`
A user can also get the same error when you try to perform other actions on the PDF, such as combining it with another PDF or inserting a new page.

#Solution:
Export the PDF as a PostScript file and then convert it into a PDF using Distiller. The “A number is out of range” error occurs when Acrobat finds some problem with the underlying structure of the PDF file. The best solution is to get a new PDF from the owner. If you can’t get one, then follow the below steps to resolve the problem.

---
title: originally posted here 👇
canonical_url: https://kodlogs.com/blog/692/the-document-could-not-be-saved-a-number-is-out-of-range
---

##Steps to follow:
* Open the PDF in Acrobat.
* Choose File -> Export To -> PostScript.
* In the Save As PDF dialog box, enter a different name for the file and then click on the Save button.
* Go to the folder where you saved the PostScript. Right-click on the file and choose Open with Adobe Acrobat Distiller. Acrobat Distiller converts the PostScript file into PDF file. The PDF file now saved in the same folder.
* Open the PDF file in Acrobat. Now you can try to view the pages or delete, insert, or add a page in the PDF.

[Find more in original blog](https://kodlogs.com/blog/692/the-document-could-not-be-saved-a-number-is-out-of-range)
Rich Dad Poor Dad Summary Chapter 2
Tags: beginners
Published: 2020-12-20 08:25:19

Today we are telling you the story of Rich Dad Poor Dad Summary Chapter 2 in detail. We will discuss the rich dad poor dad summary. This book is a great motivation for us. Rich dad poor dad is one of the best books that you may have ever read. Let’s get started on our story.
Rich Dad Poor Dad Summary Chapter 2 Untold Part
I asked him, what the old rules meant? He said that the rules that people like us have in mind during the game are different from yours. Then he said what happens if the Corporation wants to reduce its staff?

It is very difficult when people are suddenly shocked, they are surrounded by worries, their families are hurt, unemployment rises, I said it’s all right. But what happens to a company, especially a public one?
What is a stock exchange? Usually, when a company announces liquidation, the price of the stock goes up. I said that the stock market likes such things because it has reduced the expenses of the company.

This can be done by reducing the workforce or by increasing the use of machines because they are more efficient than humans.

That’s right he said, when the stock price goes up people like me, the shareholders, get richer. By different rules, that’s what I mean.

Rich Dad Poor Dad Summary Chapter 2
https://www.tagpk.com/rich-dad-poor-dad-summary-chapter-2/
how to login/signup using django-allauth without leaving the page.
Tags: django, react
Published: 2020-12-20 10:34:44


![how to make a login popup like this](https://dev-to-uploads.s3.amazonaws.com/i/i915ua838jw1edlztf00.png)
when you go to `localhost:8000/accounts/login` and lick google django-allauth will redirect you to the google login/singup page. But, I want to get all the user accounts inside my page in which I can create the list of the google account so user can click them and login or singup without leaving the page.
Note: I know how to make a popup window where it open the google login/singup page but this is not what I want. I want to get each account separately not an uncontainable google page
what is web scraping | complete guide
Tags: computerscience, python, javascript, programming
Published: 2020-12-20 10:22:15

####[ORIGINAL POST](https://www.codingtouch.in/web-scraping/)
in this time we and our business should be on internet means we should use internet to grow our business. In this article which topic we have chooses has a connection with Business. Yes we are talking about Web Scraping . In this post we will see what is and what its use.

#Web Scraping
Web scraping is a technique that is used to fetch data from a website. For gathering data of a website we use this technique that is called as Web Scraping . We use this technique for many reasons .

#Uses of this technique
we use web scraping can be used of own or business purpose. we use web scraping for following reasons-

###Lead generation
Lead generation is refers to the process of identifying potential customer for your product or service. to generate lead we collect contact detail like email, mobile number of customers to grow our business . For this purpose we use web scraping.

###Reputation and brand monitoring
To actively build brand intelligence and monitoring perception we use it . For understanding how customer feel about our product or services and how to give them a better products or services we use it.

###machine Learning
Machine learning is about teaching computers how to learn from data to make decisions .For machine learning e requires a lot of data . For gathering a lot of data we use a lot of web pages of websites.
For gathering a lot of data from various website pages we use scraping.

###Analysing competitors
If your are in a business then you should know what our competitors are doing and not. To extract competitors data , customers etc in a structured and usable format we use it.

###building a price comparison website
If you are a website developer and thinking about to develop a website that compare prices between various sites then you have to collect product details like price , description , and images for analysing we should use.

###Other uses
Financial data analysis
building product catalog
map compliance
social media analyze
news monitoring
For SEO etc.
Advent of code - Day 19
Tags: javascript, typescript, adventofcode
Published: 2020-12-20 10:02:43

Are you participating in the [Advent of code](http://adventofcode.com) this year?

If you don't know what the advent of code is, it's a website where you'll find a daily challenge (every day it gets harder). It's a really fun event, you should participate!

I try to solve the exercises using either JavaScript or TypeScript and will share my solutions daily (with one day delay so no one can cheat!). I only share the solution for the second part.

Again a fun one where you have to generate a RegEx to validate some strings. Part one was super nice, I just had a function to generate the RegEx and... voilà. For part 2, I had to hardcode the two rules for 11 and 8, then merge then for the RegEx to work. Not beautiful, but it works!

Here is my solution for day #19:
```js
const [rawRules, input] = rawInput.split('\n\n')

const rules = rawRules
  .split('\n')
  .map((rule) => rule.split(': '))
  .map((rule) => {
    return {
      id: rule[0],
      possibilities: rule[1],
    }
  })
  .reduce((acc, rule) => {
    acc[rule.id] = rule
    return acc
  }, {})

function transformToRegex(rules, possibilities) {
  if (possibilities === '42 | 42 8') return `(${transformToRegex(rules, rules[42].possibilities)})+`
  return possibilities
    .split(' | ')
    .map((possibility) => {
      return possibility
        .split(' ')
        .map((p) => {
          if (p.match(/\".+\"/)) return p.slice(1, -1)
          const expression = transformToRegex(rules, rules[p].possibilities)
          return expression.includes('|') ? `(${expression})` : expression
        })
        .join('')
    })
    .join('|')
}

const rule11Part1 = transformToRegex(rules, '42')
const rule11Part2 = transformToRegex(rules, '31')

let rule11 = `${rule11Part1}${rule11Part2}`
for (let i = 0; i < 20; i++) {
  rule11 = `${rule11Part1}(${rule11})?${rule11Part2}`
}

const firstRegex = transformToRegex(rules, rules[8].possibilities)
const fullRegex = new RegExp(`^${firstRegex}${rule11}$`)

console.log(input.split('\n').filter((str) => str.match(fullRegex)).length)
```

Feel free to share your solution in the comments!

________________________

Photo by [Markus Spiske](https://unsplash.com/@markusspiske?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText) on [Unsplash](https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText)
Day 20 of JavaScriptmas - Domain Type Solution
Tags: 24daysofjavascriptmas, scrimba, javascript
Published: 2020-12-20 09:22:26

Day 20 challenge is to return an array of information from the domain name based on the last dot (.) 

For example, an array of `["en.wiki.org", "codefights.com", "happy.net", "code.info"]` will return `["organization", "commercial", "network", "information"]`

I also mapping each domain name `.com` for `commercial`, `.info` for `information`, `.net` for `network`, `.org` for `organization`.

These are two methods that I found to solve the challenge
### **1st - Mapping domain with filter**
```javascript
function domainType(domains) {
    let typeNames = [
        {id: 'com', desc: 'commercial'},
        {id: 'info', desc: 'information'},
        {id: 'net', desc: 'network'},
        {id: 'org', desc: 'organization'}
    ];
          
    const result = domains.map( url => {
        const urlType = url.split('.').pop();       
        
        let name = typeNames.filter(name => {
           if(urlType === name.id) {
                return name;
           } 
        });
        name = Object.assign({}, ...name);
        
        return name.desc;
    });
    
    return result;
}
```
### **2nd - Mapping domain with switch**
```javascript
function domainType(domains) {
    let result = domains.map(domain => {
        switch(domain.split('.').pop()) {
            case 'com':
                return 'commercial';
                break;
            case 'info':
                return 'information';
                break;
            case 'net':
                return 'network';
                break;
            case 'org':
                return 'organization';
                break;
            default: 
             return 'unknown domain';
        }
    });
    return result;
}
```
Both methods are good for memory muscles, but I found out that the first one most likely going to be the common case.
A weekend project with Nuxt & Tailwindcss- Fluenticons
Tags: javascript, webdev, vue, programming
Published: 2020-12-20 08:59:29

I made a small weekend project - [Fluent Icons Viewer](https://www.producthunt.com/posts/fluenticons-viewer).

Microsoft has made a really great icon set called Fluent icons and they're open source but I was not able to find these icons by name and I had to look and find them manually.

Hence I made a small web project which lets you search and download the icons.

I have also made a dark mode to view these.

The project is open source and the code can be found [here](https://github.com/fayazara/fluenticons), contributions welcome.

I tried showing the icons inline but it affected the performance heavily, as there were over 2000 icons, hence I am showing them as images.

The trick with dark mode was, inverting the color of the image, seems hacky but worked great. 

I am planning to add changing colors, a figma plugin and an api to embed these icons inside websites.
Python sort list of tuples by first element
Tags: python, programming, computerscience
Published: 2020-12-20 08:48:51

In this post i will tell you about “python sort list of tuples by first element” which is easy and need just basic knowledge. A tuple is defined as a collection that is ordered and unchangeable.

#DEFINITION ABOUT TUPLE
 In Python programming language, tuples are written within round brackets.

* Tuple is defined as a collection that is ordered nd’ unchangeable. It allows doing duplicate members.
* Example TUPLE.
* thistuple = ("sun", "moon", "stars")
print(thistuple)
 
---
title: originally posted here 👇
canonical_url: https://kodlogs.com/blog/2600/python-sort-list-of-tuples-by-first-element
---

##Python sort lists of tuples by first element...
If a list of tuples are given, write a Python program to sort the tuples by first element of every tuple.

Access

 first element of each tuple using the nested loops. 

Reverse : To sort these in ascending order we could have just Python.

Remove tuple having duplicate first value from given list of  Sorting that list of numbers / characters is easy. 

We can use sort() method /  sorted() built-in function. In this , we want to sort a list of tuples by first value in the tuple.

**Example-** Let’s consider a tuple list having actor’s charater in a movie and his real name. [(Robert Downey Jr, "Ironman"), (Chris Evans, "Captain America")]

 

##Method of Executing 
**Method:** Using sort() method

When we sort via this method the actual content of the tuple is changed, just like the previous method, the in-place method of sort is executed.

###Example:
```
# Python programming code to sort a list of tuple by the first element using sort()  
  
# Functions to sort the list by first element of tuple 

def Sort_Tuple(tup):  
  
    # reverse = None (get sorted in Ascending order)  
    # key is a set to sort using second element of  
    # sublist lambda is used  
    tup.sort(key = lambda x: x[1])  
    return tup  
  
# Driver Code  
tup = [('saket', 10), ('tony', 5), ('steve', 20), ('bahubali', 15)]  
  
# print the sorted list of tuples 
print(Sort_Tuple(tup))  
```
###Output:
[('tony', 5), ('saket', 10), ('bahubali', 15), ('steve', 20)]
A Beginner's Journey: Part One
Tags: beginners, webdev, hardware, setup
Published: 2020-12-20 08:44:22

Every journey requires preparation, you know your destination and plan your itinerary. You pack your bags and start on your journey. Being a developer is similar. There are many problems you will encounter as a beginner but preparation helps limit misery.
I bought my first computer for word processing. It was what I could afford at that time and it was sufficient for my needs as a researcher and freelance writer. The spec sheet was the worst, it was running on 2GB of RAM and used a 500GB HDD(hard disk drive).
I decided to pursue my passion of being developer during lockdown and installed Python and Node successfully, but I struggled as I began to install more packages.
I upgraded my RAM and switched to Ubuntu and it improved the performance of my computer but it still had its limitations. I learnt the hard way that there was a reason software providers had hardware requirements. My opinion, if you plan on being a developer, you need the best possible workstation. There should be no compromise on RAM - at least 16GB. A computer with a SSD (Solid State Drive) of a minimum of 256GB and a quad core processer.
The more you learn, the more your hardware needs increase. In addition to having the right hardware is ergonomics. You need a cozy environment to work, an enclosed space with minimal noise, a comfortable chair and desktop. A cozy room should also have some plants, space to walk and a sofa to rest sometimes. A TV and a gaming console is optional if it won't be a distraction.
In conclusion, get a good computer; from my experience, brand and Operating System is subjective. The next thing is where you code. It should be somewhere you are pleased with and can immerse yourself in debugging code.
1password cli script
Tags: 1password, secrets, passwords
Published: 2020-12-20 08:24:32

For those using 1password to manage their passwords,there is 1password command-line tool to script the retrieve of your passwords.

Here I'll just share some useful commands to script your password manager.

Requirements:
* [1password](https://1password.com/)
* [password command-line tool](https://support.1password.com/command-line-getting-started/)
* [jq](https://stedolan.github.io/jq/)

## Log in

```bash
login() {
    eval $(op signin my)
}
``` 

## Log out


```bash
login() {
    op signout
}
``` 

## Retrieve password

To retrieve with jq a password from sections details or field details:

```bash
echo "$(op get item MyITEM --vault MyTeamVAULT | jq -r 'if .details.sections[0] == null then .details.fields[] |select(.designation=="password").value else .details.sections[].fields[] | select((.n=="password") or (.t=="Password")).v end'
```

You can modify this command to retrieve other fields than password.

P.S. jq could be used with curl to parse JSON result and do some interesting scripting tasks.

Have fun
:)
I made an Free API to get random words and Generate pronunciation on the go
Tags: randomwords, api, randomwordsapi
Published: 2020-12-20 08:16:30

### The Story

From long time I want to learn a new word everyday. But I'm not fond of reading or going through the dictionary every single day. I wanted to do something technical.

So I created this API.

### Tech Stack
- NodeJS with Cheerio, Express
- Compromise-pronounce for generating pronunciation

{% github mcnaveen/Random-Words-API %}

It fetches the word from the web and generate pronunciation on the go.

Feel free to use it. PRs are welcome.

Thanks to @mskian for Progressive Web App.
https://wordsonrandom.netlify.app/