teleren/devto huggingface dataset:
Getting Started With Hackerrank Using Python | For Absolute Beginners
Tags: python, beginners
Published: 2021-09-06 09:09:16

## The Intro
Data Structures and Algorithms(DSA) are a necessity to land a Good ass Technical job. And when it comes to DSA, people turn to popular websites like `Leetcode`, `Hackerrank`, `Hackerearth` and many more. 

That being said, Starting anew can be difficult and sometimes overwhelming and newbies can find it difficult to figure out the ins and outs of the platform they use (How to take Input(s), how to produce the proper Output(s)  

## Hackerrank with Python

Let's say you come across [this](https://www.hackerrank.com/challenges/list-comprehensions/problem) kind of question, where you have input 
and output like:
![SampleInput](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i8foqxdr0vsx8chqwn7w.PNG)
Then the output would be given using `print` and one way to take in inputs would be individually take all four inputs like x,y,z,n as given below
```
if __name__ == '__main__':
    x = int(input())
    y = int(input())
    z = int(input())
    n = int(input())
    print ([[a,b,c] for a in range(0,x+1) for b in range(0,y+1) for c in range(0,z+1) if a + b + c != n ])

```
The other way to take in four inputs would be to use a for loop to store the inputs in a list.

_______
**Let's see another** [example] (https://www.hackerrank.com/challenges/find-second-maximum-number-in-a-list/problem) 
Consider the given inputs and the following code: 
![Case2SampleInput](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w0249k2wtgbzugi95ac2.PNG)
```
if __name__ == '__main__':
    n = int(input())
    arr = map(int, input().split())
```

What the above code does is it assigns 5 to n ; then checks the second line to find `2 3 6 6 5` where the input().split() splits the string `2 3 6 6 5` to a list with the following items :
`2` `3` `6` `6` `5` 

The map function then converts the items to integer type and we get a list arr = [2,3,6,6,5] where each item is an integer.

### Hope this was helpful~
#### Thats all for now, Until Next Time Bros
Improve the WooCommerce default import tool with this snippet.
Published: 2021-09-06 08:50:27

Here's a quick snippet to turbo charge the WooCommerce default import tool. It's set to 50 rows per import maximum, but this snippet will juice that number up to 5000. It shouldn't really max out your server unless you are trying to import photos from another website that is slow. 

```
// Increase the default batch limit of 50 in the CSV product exporter to a more usable 5000
add_filter( 'woocommerce_product_export_batch_limit', function () {
    return 5000;
}, 999 );
```

Currently in use at
[Wild Posters](https://wildposters.com/wheatpaste-poster-printing/)
[Monster Tees](https://monstertees.com/)
[Luxury Printing](https://www.luxuryprinting.com/)
[Windsurfing Fitness](https://getwindsurffit.com/)
[White Elephant Gift Ideas](https://milliondollargiftclub.com/)
[Broadway Liquor](https://winenliquor.com/)
[Rush Flyer Printing](https://www.rushflyerprinting.com/)
Remove a ton of WooCommerce bloat with some simple filters.
Published: 2021-09-06 08:45:06

Every time WooCommerce releases an update they seem to add more and more bloat to it. It's still the best ecommerce system around though, but we need to add a few snippets to keep it running fast. I'm currently selling a [WooCommerce Tax Rates CSV](https://salestaxusa.com) file and I wanted this site to be blazing fast. 

```
/****DISABLE WC FILTERS****/
add_filter( 'woocommerce_background_image_regeneration', '__return_false' );
add_filter( 'woocommerce_helper_suppress_admin_notices', '__return_true' );
add_filter( 'woocommerce_allow_marketplace_suggestions', '__return_false' );
add_filter( 'wp_lazy_loading_enabled', '__return_false' );
add_filter( 'woocommerce_menu_order_count', 'false' );
add_filter( 'woocommerce_enable_nocache_headers', '__return_false' );
add_filter( 'woocommerce_admin_disabled', '__return_true' );
add_filter( 'woocommerce_include_processing_order_count_in_menu', '__return_false' );
```

What these are doing are pretty self-explanatory by the name of the filter. Do you think you really want to be loading "marketplace suggestions" and the WooCommerce admin (which is just a fancier way of showing you more marketplace suggestions and ads) on every admin page load? Bleh... of course not. 

Currently in use at:
[Windsurfing Fitness](https://getwindsurffit.com)
[White Elephant Gifts](https://milliondollargiftclub.com)
[1800 Printing](https://1800printing.com)
[Printing Brooklyn](https://www.printingbrooklyn.com)
[Printing New York](https://www.printingnewyork.com)
[Rush Flyer Printing](https://www.rushflyerprinting.com)
[Luxury Printing](https://www.luxuryprinting.com)
[Wild Posters](https://wildposters.com)
[Monster Tees](https://monstertees.com)
Does not use passive listeners to improve scrolling performance
Published: 2021-09-06 08:36:55

Here's a snippet to fix the "does not use passive listeners to improve scrolling performance" Google Pagespeed warning for Wordpress sites.

It comes from the jquery.min.js file that Wordpress serves and the scrollers are usually on pages with comment forms. 

I get this warning on lots of my sites and finally I found something that worked to remove the warning. 

```

function wp_dereg_script_comment_reply(){wp_deregister_script( 'comment-reply' );}
add_action('init','wp_dereg_script_comment_reply');
add_action('wp_head', 'wp_reload_script_comment_reply');
function wp_reload_script_comment_reply() {
    ?>
<script>
//Function checks if a given script is already loaded
function isScriptLoaded(src){
    return document.querySelector('script[src="' + src + '"]') ? true : false;
}
//When a reply link is clicked, check if reply-script is loaded. If not, load it and emulate the click
document.getElementsByClassName("comment-reply-link").onclick = function() {
    if(!(isScriptLoaded("/wp-includes/js/comment-reply.min.js"))){
        var script = document.createElement('script');
        script.src = "/wp-includes/js/comment-reply.min.js";
    script.onload = emRepClick($(this).attr('data-commentid'));
        document.head.appendChild(script);
    }
}
//Function waits 50 ms before it emulates a click on the relevant reply link now that the reply script is loaded
function emRepClick(comId) {
sleep(50).then(() => {
document.querySelectorAll('[data-commentid="'+comId+'"]')[0].dispatchEvent(new Event('click'));
});
}
//Function does nothing, for a given amount of time
function sleep (time) {
  return new Promise((resolve) => setTimeout(resolve, time));
}
</script>
    <?php
}
```

Currently in use at:
[Luxury Printing](https://www.luxuryprinting.com)
[Rush Flyer Printing](https://www.rushflyerprinting.com)
[Printing Manhattan](https://www.printingmanhattan.com)
[Broadway Liquor](https://winenliquor.com)
[Windsurfing Fitness](https://getwindsurffit.com)
How and when to override Android Activity's Lifecycle methods?
Tags: android
Published: 2021-09-06 08:23:50

> Read this article on [my blog](https://genicsblog.com/how-and-when-to-override-android-activity-lifecycle-methods) for a better experience :)

Yesterday, I came across a [StackOverflow question](https://stackoverflow.com/questions/69064102/how-can-i-stop-the-progressdialog-after-returning-to-the-activity).

The OP(original poster) of the article had a scenario like this:

He made a `ProgressDialog` in an activity. After pressing a `CardView` in that activity corresponding to a meditation session, a `ProgressDialog` should appear for 3 seconds, and then the other activity would open - the `m1` activity. 

The problem he faced was - After returning to `MeditationActivity`, the `ProgressDialog` continued to show up and never stopped.

He wanted that the progress dialog is closed once the user comes back from the `m1` activity to the `MeditationActivity`.

Just after reading the question, it should strike to the mind that one can override the default methods present in an Activity's Lifecycle and dismiss the dialog from there!

Here's how the lifecycle of an Android Activity looks like:

![activity_lifecycle.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1630915330208/6F9zSmseW2.png)

*This is an image from the official [android documentation](https://developer.android.com/guide/components/activities/activity-lifecycle)*

From the flowchart, we can see that it is the `onResume()` method that is called whenever a person comes back to the activity from another screen. So it seems to be the place where we should place the logic for dismissing the dialog!

![activity_lifecycle.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1630915509631/Eq9kO4b_9.png)

Here's how we can do that:

```java
@Override
public void onResume(){
    super.onResume();
    if(progressDialog != null) progressDialog.dismiss();
}
```

The null check is placed because the `progressDialog` was initialized only when the person presses the `CardView`. And if it is initialized earlier, then there would be redundant dismissals of the `progressDialog`.

This was a perfect example where we could override the default lifecycle methods provided by an Android `Activity` to perform actions pertaining to lifecycle.

[Here's my answer](https://stackoverflow.com/a/69064294/9819031) to the original question on StackOverflow! I'll be writing more explanations to StackOverflow Questions, so consider following me on hashnode.

I hope you find this article helpful :)
SkillBar
Tags: codepen, css, html, webdev
Published: 2021-09-06 08:18:56

<p>skill bar using html and css.</p>

CodePen:
https://codepen.io/sanketbodke/pen/BaZQyXO

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wpo7fghc60mnrb1xv10i.png)

Github:
https://github.com/sanketbodke
Solve merge conflicts with PHPStorm
Tags: git, phpstorm, merge, conflict
Published: 2021-09-06 08:03:30

Once in a while a merge conflict popups. This happens when you've created your branch and in the meantime your colleague pushed changes just before you did on the same line. Git (or your colleague) will let you know if it can be solved automatically and if not, it's up to you how to fix it.

<img width="100%" style="width:100%" src="https://media.giphy.com/media/cFkiFMDg3iFoI/giphy.gif?cid=ecf05e475nr1w7qk4fbrntcra9zcmsfan9cj5pj1d6x06dyi&rid=giphy.gif&ct=g">

##How to fix merge conflicts with PHPStorm?

####1. Checkout the branch where you want to merge to. For example the `master` branch.

PHPStorm->Git->Branches...->master->checkout



####2. Pull the latest changes to your local machine from `master`

PHPStorm->Git->Pull...->Pull


####3. Checkout `your_feature_branch` where you've made your changes

PHPStorm->Git->Branches...->your_feature_branch->checkout



####4. Also pull the latest changes to your local machine from your branch, just to be sure

PHPStorm->Git->Pull...->Pull



####5. Merge `master` into `your_feature_branch`

PHPStorm->Git->Merge...->master



####6. Resolve Conflicts 

PHPStorm will automatically open this Conflict window if there is a conflict detected:

![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kjsvqaca0xy75grtnh53.png)
 
Choose Merge.


####7. Accept or refuse solutions on the right or left.
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x6sxybm0ah73nru4yzyy.png)
 

Apply if done.



####7. Git commit your changes

PHPStorm will automatically commit these changes if you Apply. Git will generate a comment for your commit such as "Merge branch 'development' into your_feature_branche"



####8. Git push and celebrate life!

PHPStorm->Git->Push...





Thats all folks~

Source:
[jetbrains.com](https://www.jetbrains.com/help/phpstorm/resolving-conflicts.html)
[React] Create awesome and fully responsive emails without stress.
Published: 2021-09-06 07:59:34

Hey developers,

I would like to share with you my new open source project that I just released, feel free to check it out and use it. If you have any suggestion or question please contact with me.



Following are the urls of the project:

Github

https://github.com/pavkout/react-mailkit

Website

https://www.react-mailkit.io

Storybook

https://pavkout.github.io/react-mailkit/
Ruby Arrays
Tags: ruby, rails, webdev, programming
Published: 2021-09-06 07:48:43

Array is a container made up of rows and col .In which every row and col denote a unique position in the container .Take for instance  a prison .Each cell(col) in a prison belong to  a block (row) which can be uniquely identified.

In ruby array are denote as
```
a = [1,3,4,6,7,8]


```
Ruby also have a lot of function to manipulate an array .To make this blog interesting let make it a quiz.

Quiz
a.length-
a.last
a.first
a.select {|number| number.odd?}
a.joint("-")
a.split(" ")
%w{"my name is eniola ajani solomon")



### Array loop

####each

```
a.each do |value|
     puts value 
end



```
#### for

````

for i in a 
   puts i
end 

````
To get more array method

```
a.methods
```
Thanks for reading
What is LocalStorage
Tags: javascript, 100daysofcode, webdev
Published: 2021-09-06 07:18:35

## 1. Definition

The localStorage read-only property of the window interface allows you to access a Storage object for the Document's origin; the stored data is saved across browser sessions.

localStorage is similar to sessionStorage, except that while localStorage data has **no expiration time**, sessionStorage data gets cleared when the **page session ends** — that is, when the page is closed. 

> localStorage data for a document loaded in a "private browsing" or "incognito" **session is cleared** when the **last "private" tab is closed**.

## 2. Data Format

The keys and the values stored with localStorage are always in the **UTF-16 DOMString** format, which uses two bytes per character. As with objects, integer keys are automatically converted to strings.

## 3. Example

```jsx
// Setting and item: key: value
localStorage.setItem('myCat', 'Tom');

// Reading an item
const cat = localStorage.getItem('myCat');

// Remove an item
localStorage.removeItem('myCat');

// Clear all items
localStorage.clear();
```

{% codepen https://codepen.io/moghaazi/pen/BajWgav %}

## 4. Advaced Examples

For setting objects or dates we need to convert to strings because localStorage only store string format

```jsx
let userList = [{name: "David"}, {name: "Kevin"}]
let date = new Date()

// Setting
localStorage.setItem("userList", JSON.stringify(userList))
localStorage.setItem("date", date.toString())

// Reading
userList = JSON.parse(localStorage.getItem("userList"))
date = new Date(localStorage.getItem("date"))

```

![Screenshot of localstorage](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/est18ehat29sscllrcoa.png)

## Links
- [Mozilla Docs](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage)
去重
Published: 2021-09-06 07:39:12

# 方法 1 
```
const arr = [1,1,2,3,4,4,5]
const uniqueArr = [...new Set(arr)];
console.log(uniqueArr); //[ 1, 2, 3, 4, 5 ]
```
# 方法2 
```
import _ from 'lodash';
const arr = [1,1,2,3,4,4,5]；
const uniqueArr = _.uniq(arr);
console.log(uniqueArr); //[ 1, 2, 3, 4, 5 ]
```
DEBUG CODE - A Developer Blogging Website
Tags: go, kubernetes, docker, blockchain
Published: 2021-09-06 07:27:47

Hello Developers,

I have just launched my new dev blogging website, will publish content from Golang POCs, Kubernetes, Blockchain, System design, and many more related to cloud-native areas, will share open-source projects POCs on the website.

Please visit my website 👉 https://debugcode.xyz

Ideas and Suggestions are always welcome 🙂😀

Thanks
Can you work from an airplane?
Tags: productivity, devenv
Published: 2021-09-08 11:40:00

---
title: Can you work from an airplane?
published: true
date: 2021-09-06 00:00:00 UTC
tags: productivity,devenv
canonical_url: https://jhall.io/archive/2021/09/06/can-you-work-from-an-airplane/
---

Quite often when I start working with a new team, they ask me to help get their “dev enironment” under control. You know, the set of tools, scripts, configurations, and in some cases network permissions, required to do local development.

This is a big hairy topic, and is full of technical nuances that depend on your tech stack. But next time you’re working on improving your own dev environment, let me challenge you with [one of the rules](https://jhall.io/jonathan-test/) I use with the teams I’m working with:

> If every engineer on your team cannot do _meaningful_ work from an airplane, your development environment is broken.

There are two elements here that deserve special attention:

- 

**from an airplane**

In 2021, some commercial flights do offer expensive, slow, spotty wifi. At some point, probably sooner than I expect, most flights will offer free, fast, reliable wifi. At that point, I’ll need to change my criteria. But for now it’s a nice short hand for: It should be possible to work without an Internet connection.

Even if you never fly, this is a big boost to productivity. It allows you to work during your commute. It allows you to work when your office Internet connection goes offline. It allows you to work when US-East1 goes down for a few hours, or any other network-based dependency is down.

- 

**_meaningful_ work**

In a perfect world, every engineer could do all of their work without an Internet connection. Few of us work in this perfect world, so it’s not very reasonable to expect to be able to do _all_ work without a network connection. However, it should be possible to do _meaningful_ work without an Internet connection. What constitutes “meaningful?” It depends a lot on your role and project, of course. It’s definitely more than “read documentation I downloaded before I left the office.”

It might just mean that most unit tests can run without a network connection. It might mean that you can fire up a full, or partial instance of your app, and do complete end-to-end and UI testing if you want to.

You and your team and project have to decide what “meaningful” means in your context. Just keep in mind: The more you can do without an Internet connection, the more productive the entire team can be.

- 

**every developer**

If only your backend devs, or only your frontend devs can work from an airplane, your dev environment is still broken. If only Mac users can work from an airplane, your dev enfironment is still broken. Don’t discriminate. Make it work for everyone.

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
Wrap_content vs Match_parent {Android Development} | Day 7
Tags: android, sharingknowledge, 50daysofcode
Published: 2021-09-06 07:27:18

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jhtoqnyth7yc183glmdw.png)



**1.Match_parent :**
➡️ This attribute/value is used for layout height and layout width property.
➡️ It is commonly used for ViewGroup and even sometime view.
➡️ It is used when want the width or height of the component(views) to the size of the layout(viewgroup).
➡️ And when we use match_parent for viewgroup the height and width is set to the size of the parent viewgroup (if applied to child viewgroup)or to the mobile screen (if applied to the parent viewgroup)

**2. Wrap_content:**
➡️ This attribute/value is used for layout height and layout width property.
➡️ It is commonly used for View and even sometime for viewgroup.
➡️ It help us to wrap the content inside of the components(view , viewgroups).
求和
Published: 2021-09-06 07:21:20


```
//将传入的参数转为数组
const turnArray = (...rest)=> [].slice.apply(rest);
//利用reduce对数组求和
const add = arr => arr.reduce((pre,cur)=>pre+cur);
console.log(add(turnArray(1,2,3,4,5,6)));
```
My GameDev Journey
Tags: writing, gamedev, beginners
Published: 2021-09-06 07:10:05

Esteemed friends, welcome to my dev blog. A direct English translation for my pseudo name would be "Tinear", it hints towards an old Afrikaans proverb: *'n Blikoor wees — So genoem omdat Vrystaters dan kwansuis dom sou wees omdat hulle nie met blikore kan hoor nie.* In other words, just hinting towards the province of origin. 😜

I have been learning to program for a few years now, but I have never really developed anything. Studying several programming languages in courses over the years and following along with tutorials, I still find myself in *Tutorial Purgatory*. But although I still feel like a beginner, I like to think that I am a game developer by heart. 😏

The general consensus seems to be that there are numerous convincing reasons to blog about your journey, for new developers and professionals alike. I look forward to assisting other developers in good faith and hopefully escape Tutorial Purgatory myself in the process. Admittedly, it would be equally great to learn from other community members as well. 😎
My open source journey 🤓
Published: 2021-09-06 06:58:35

I started my open source journey with my mentor @saintmalikhash when he posted a WhatsApp link to join a group for the open source community at Ado-ekiti

Tho I don't even know the meaning of open source at first....with the help of seminars from the community I got to know what open source is and not all about tho .....I'm still  pushing to know all about....I missed online session about benefits of my contribution to open source using Git as a version control system and developers uses GitHub to collaborate among themselves....I'm still a NOOB🤓
Using password_hash to Hash and Store Passwords in PHP
Tags: php, security
Published: 2021-09-06 06:48:04

PHP offers a very powerful `password_hash` function, which will create a one-way hash of a string. It's often used for hashing passwords and access tokens.

We can pass an algorithm to `password_hash`, but I'll be focusing on `PASSWORD_DEFAULT`, which is a built-in algorithm designed to change over time as stronger algorithms are developed.

If you want to read about the other built-in algorithms that PHP offers, the [official password hashing documentation](https://www.php.net/manual/en/function.password-hash.php) explains each of them.

Anyway, `password_hash` is fairly straightforward. The first parameter is the string to hash (in this case, "dragon123"). The second parameter is the algorithm to hash the string with.

```php
$password = 'dragon123';
$hash = password_hash($password, PASSWORD_DEFAULT);
// As of writing this, $hash returns this monstrous string:
// "$2y$10$WIj56IGASADOa26io1AzeuMRvp3SKdYu8saCU.6.1xDpnr3w6xECS"
```

Remember, the `PASSWORD_DEFAULT` algorithm is subject to change over time, so this code might return a different result for you in the future.

Furthermore, I want to echo the official documentation's suggestion to ensure your hashed password database column supports strings of up to 255 characters in length, likely ensuring future compatibility.

## Verifying hashed passwords with password_verify

Verifying a hashed password is just as simple, thanks to `password_verify`.

The first parameter is the *plaintext* string to check, and the second parameter is the *hashed* string to check the first string against.

```php
$password = 'dragon123';
$hash = '$2y$10$WIj56IGASADOa26io1AzeuMRvp3SKdYu8saCU.6.1xDpnr3w6xECS';
$result = password_verify($password, $hash);
```

This function will return a boolean, either `true` or `false`, depending on whether the first string is valid:

```php
if ($result === true) {
    echo "Successfully authenticated."
} else {
    echo "Invalid password."
}
```

If `dragon123` is passed, `$result` will be `true`. However, if `dragon456` or something else is passed, `$result` will be `false`.

## Conclusion

While this is certainly isn't state-of-the-art, it's a great step for most small websites and startups, that is at least certainly far ahead of using a custom salt (let alone storing passwords in plaintext).