teleren/devto huggingface dataset:
LeetCode 121. Best Time to Buy and Sell Stock (javascript solution)
Tags: algorithms, javascript
Published: 2021-07-19 05:33:45

###Description:
You are given an array prices where prices[i] is the price of a given stock on the ith day.

You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock.

Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0.


###Solution:
Time Complexity : O(n)
Space Complexity: O(1)

```javascript
var maxProfit = function(prices) {
    let profit = 0
    let min = prices[0]
    for(let i = 1; i < prices.length; i++){
        // The day we should buy at
        min = Math.min(min, prices[i-1])
        // Check if selling at the current day gives us the most profit
        profit = Math.max(prices[i]-min, profit)
    }
    return profit
};
```
Perform Sorting in Flutter DataGrid Widget
Tags: flutter, grid, dart, widget
Published: 2021-07-19 04:42:43

Learn how to perform sort operations in the Syncfusion [Flutter DataGrid widget](https://www.syncfusion.com/flutter-widgets/flutter-datagrid "Flutter DataGrid widget") easily. This video explains how to enable sorting in a DataGrid and how to enable tri-state sorting. Also, it explains how to enable multi-column sorting, show sort numbers, and sort column by double-tapping. And finally, explains how to disable sorting for an individual column, and sort columns programmatically.

**[Syncfusion Flutter DataTable](https://www.syncfusion.com/flutter-widgets/flutter-datagrid "Syncfusion Flutter DataTable"): A High-Performance DataGrid Widget**
* Instantly load large amounts of data.
* Deliver features such as row selection, sorting and more out of the box.
* Style every element in a DataGrid easily.

Example project: 
Complete sample: https://bit.ly/3kiDbs1
Explore tutorial videos: https://bit.ly/3fAz0Ch

{% youtube DOvPUj_4-QI %}
Script to brute force Dell Promo code [in development]
Tags: javascript, webdev, 100daysofcode, codenewbie
Published: 2021-07-19 04:42:07

go to https://www.dell.com 

add something in the cart

open console paste the below script

press enter

```
let inp = document.querySelector("#appendedCouponInputButton")
let btn = document.querySelector("#applyCouponButton")
setInterval(function(){
let str = Math.round(Math.random()*99999999999998765876).toString(36);
    inp.value=str;
    btn.click();
},200)
```

i know that we required to build much more our str i.e coupon is not strong. i will update on this script on every weekend, till then you can modify script.
Report of airfares for global flights
Published: 2021-07-19 04:14:19

<a href="https://www.rome2rio.com/labs/2018-global-flight-price-ranking/#ranking">Report link</a>
After having a look on an article about air transportation in VN vnexpress.net/khong-can-them-hang-...

I have in mind a question of how expensive the airfare is in countries around VN (cost per kilometer). Then I got the research from rome2rio that could give me a satisfied answer even more info ( link for more detail) (against on data of economy class only that I think is closer to cattle class and adding fees on everything from luggage to seat assignments).

Year of report was 2018 then I gonna list out number of carriers in south east Asia countries:

- Vietnam 4 carries
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5mp6s35u30jold0l5oj2.png)
- Thailand 10 carries
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/40jphal3hexgez9b6d5a.png)
- Phillipines 6 carries
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4zwb1gh6qek2chd10bm8.png)
- Myanmar 4 carries
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yp9azjwn89nlaos1znu4.png)
- Malaysia 4 carries
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/34pojzb1ko7ogjm9jbm3.png)
- Indonesia 9 carries
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y5em4jtxdzueievm9be2.png)
- Cambodia 4 carries
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/67d0lxpgqg4u36pwsoan.png)
Crowbits - STEM toy for kids 😍
Tags: crowbits, stem, kids, learning
Published: 2021-07-19 04:13:04

Last year I backed up the [Crowbits](https://www.kickstarter.com/projects/elecrow/crowbits-electronic-blocks-for-stem-education-at-any-level) project on Kickstarter because I saw a potential for kids to learn so much by assembling these kits especially that it could be integrated with lego's.

At the moment you can purchase the kits from the [Elecrow](https://www.elecrow.com/crowbits-kit/kits.html)'s website. And just worth mentioning that this post is not sponsored, nor do I have any association with the team or any money from sharing these links is in play.

<!--more-->

## What are they?

To me Crowbits are the coolest coding toys that I've seen so far. With more than 80+ electronic blocks, and a kid friendly graphical software, it really stands up from other similar products and creates a whole other level of fun for kids (and adults, I had fun too 😁).

![Crowbits kit](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1afzlc2s9zlmnqrjf3vt.jpg)

## Modes

There are two modes you could play with this set, no-code and code modes. In this mode you just stick the pieces together and make a project using cardboard, lego pieces, strings and other crafting tools.

![Crowbits robot walking](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/73061x4rg9vq5cmnxl3d.gif)

In the coding mode, they use a software which helps them understand how the order of pieces should be and what happens when they connect them together. They don't need to write any code, rather drag and drop the blocks in the software to make something like a robot, or tell the robot what to do next.

![Crowbits letscode software](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yv1b8i6jflgtdzm9hqex.png)

## Kits

There are different types of kits you can purchase:

* **Hello kit**: With this kit you will get a flashing window light, pandora's box, cute little dog and morse code machine.
* **Explorer kit**: With this kit you will jump a notch to minsweeper, climbing monkey, piggy bank, the smart fan, ski and quadruped robots, and much more.
* **Inventor kit**: This kit gets you the gesture control and bluetooth cars, obstacle avoidance car, elevator, automatic door, and a whole bunch of cool other projects.
* **Creator kit**: You can build a horse racing project, catch the fruit game, crazy bird, tank wars and much more with this one.
* **Master kit**: This one gets you phone, game console, radar and more advanced projects.

## So

So don't wait, go order your desired kit and get your kids (or yourself) busy building cool stuff.
UI Design Fundamentals
Tags: uiweekly, ui, uidesign, design
Published: 2021-07-19 04:08:51


![Custom Size – 1.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1623670832800/nJXaU8C2T.png)


![White Space.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1623670857575/_jWcLV1Ul.png)



![COLOR.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1623670868060/Ot8OcVAdc.png)



![Contrast.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1623670878784/Hw_e-ikQb.png)



![alignment.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1623670893012/FSuxrtfaD.png)



![Scale.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1623670904804/zyltpANuV.png)



![Typogarphy.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1623670915250/HwosMiM5l.png)



![Visual Hierarchy.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1623670927511/69MoTfeu8.png)




### Follow me on Instagram

[@reboot13_dev](https://instagram.com/reboot13_dev)
Coroutine vs JVM thread
Tags: android, coroutine, kotlin, multithreading
Published: 2021-07-19 03:44:15

Hi there,

You might have worked with kotlin's coroutine by now and possibility is, you may have an impression that it is a form of light-weight thread.

I was curious to know it's internal working, how it is light-weight compared to JVM thread and any hidden advantages which I was unaware of.

I dug into framework + read some articles, and wrote a [blog](https://hardik9850.medium.com/jvm-threads-and-kotlin-coroutines-5b17e417bc0) where I describe how beneficial Kotlin coroutines are over JVM threads.

If this concept interests you then please give it a read. I hope it is fruitful.
Day 15 of #100DaysOfCode!

Tags: codenewbie, 100daysofcode, css, beginners
Published: 2021-07-19 02:37:38

<h2>Today's progress</h2>
Worked on using `@each` to iterate through each item in a list or a map. 

<h2>What I learned</h2>
Similar to JavaScript's forEach() method. SASS also has a feature to iterate through each item in a list or map. Making it easier and faster to assign values to a variable.

For instance, let's say we want to create several `<div>` elements with different background colors. One way we can solve this problem is using `@each` directive within SASS.

Here's the code example.

####<center>Variable List</center>
```css
 $bg-colors: (
    bg-color1: blue,
    bg-color2: black,
    bg-color3: red
  );
```

We created a variable list called `$bg-colors` which stores three different background colors. 

Now we want to iterate through the list or map and assign each key to a new variable.

We can do that by doing the following...

####<center>Iterating and assigning values to new variables</center>
```css
@each $key, $bg-color in $bg-colors:{
  .#{$bg-color}-background {background-color: $bg-colors}
}
```

The `@each` allows us to loop through the list or map and the `$key` is needed to reference the keys. 

Next we use the interpolation and wrap our values `$bg-color` to get the values from our map or list.

The output should be the following...

####<center>Compiled CSS</center>
```css
.blue-background {
  background-color: blue;
}

.black-background {
  background-color: black;
}

.red-background {
  background-color: red;
}
```

<h2>In Conclusion</h2>
@each allows you to iterate through the keys in a list or map and get their values. This is a useful tool especially when having to assign multiple values to a large set of class names.
Let's Talk About Sets Baby...
Tags: javascript, sets, datastructures
Published: 2021-07-19 02:35:49

## <center> 🎶 *Let's talk about sets...* 🎶 </center>

So if you read my blog post [Data: Types vs. Structures](https://dev.to/maxjacobzander/data-types-vs-structures-1knf), you might recall me talking about a data structure known as a **Set**. I was doing a code challenge this last week and found sets to be incredibly helpful in finding an efficient solution, so I decided to take a minute this week to 🎵*talk about sets (baby)*🎵.

----------

Sets (or set objects) are a collection of values and, as I mentioned in my aforementioned previous post, the values in a set are unique (meaning they can only occur once). This can prove super helpful for finding out if something belongs to a set of values or if you need to figure out how many unique values exist in a a given set of data.

So now that we've established *what* sets are, let's talk a little bit about how to use them:

First of all, how do we create a set? Well, to create a new set we say:
```
new Set()
```
and if we want to add an argument, we can either add data directly:
```
let triadSet = new Set([1, 3, 5])
// the Set now looks like this: [1, 3, 5]
```
or we can convert existing data to a set:
```
let array = [1, 3, 5, 3, 1]
let triadSetFromArray = new Set(array)
// the Set now looks like this: [1, 3, 5]
```
*You'll note that the `triadSetFromArray` doesn't repeat the second `3` or `1` because (again), the values in a set are unique!*

If we want to add to our set, we can call a method `add()` to do so:
```
triadSetFromArray.add(8);
// the Set now looks like this: [1, 3, 5, 8]
```
*N.B. The `add()` method adds the new element to the end of the set object.*

If you want to remove an element from a set object, you can do that by calling the `delete()` method:
```
triadSetFromArray.delete(8);
// the Set now looks like this: [1, 3, 5]
```

So let's say you've created your great new set, `triadSetFromArray` and you want to check what it contains. Sets have a method `has()` that you can call to check on the contents. `has()` returns a boolean value depending on the contents and works like this:
```
triadSetFromArray.has(5);
// true

triadSetFromArray.has(4);
// false
```

Now let's say you've been given the array above and are tasked with returning the amount of unique items exist in the array. Well, sets have a `size` property that you can call to retrieve that kind of data.
```
let array = [1, 3, 5, 3, 1]
let triadSetFromArray = new Set(array)

return triadSetFromArray.size
// 3
```

And if you decide that you're over the entire set object and you want to get clear out the whole thing (or, you know, you have a better reason to do it 😉), you can call the `clear()` method to do so:
```
triadSetFromArray.clear();
// The Set now looks like this: []
```

-----

So there's a little introduction to Sets. I think they're awesome and super helpful and I very much recommend adding them to your arsenal!
Quiz app with React.js and typescript
Tags: javascript, react, typescript
Published: 2021-07-19 02:33:05

In this article I will create a quiz app with react.js and typescript using [open trivia api](https://opentdb.com/) and tailwind css.

[Github Link](https://github.com/sarthak090/react-quiz-app)
![quiz app react js](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wi4juo0ezjapo7tm01xa.png)

## Setup

- Clone the repo .
- run ``yarn install`` .
- Generate your custom endpoint from [opentdb](https://opentdb.com/api_config.php) and add to ``ENDPOINT`` variable in ``Mainpage.tsx``.
- Run ``yarn start`` to start the project.
  

## About The Project.
- Project is created with react and typescript
- for styling I have used tailwind css.
- context api has been utilized for keeping the score of the user.
Five Dev Podcasts You Should Be Listening To
Tags: podcast, leadership, ruby
Published: 2021-07-19 01:31:48

I got asked a while back what I listen to as an avid podcast listener. So I thought I'd make a quick post of some of my fav tech related podcasts. 

* The ReadME Podcast
* The ChangeLog
* CoRecursive
* Software Engineering Daily
* Masters of Scale
First 3 weeks as a Flatiron school student!!
Published: 2021-07-19 00:56:48

It has been almost 3 weeks since I started and I have learned so much already. Five days ago I finished my first ever project using Vanilla JavaScript and I have to say, it was such a fun experience, I kept wanting to add more features and improve it constantly, I was never satisfied of how it turned out so I kept going back to make changes, I realized, I'm really really enjoying learning JavaScript.

There is so much to learn, but I'm so eager to just know everything which I know is impossible : ) .
School has been taking most of my time, 4 hours coding could feel like 4 minutes, time just flies, but I still love it.

Next week, I should be submitting my phase-1 project, which I already did and also passed my assessment, yaaay, phase-1 down, 4 more to go :) .
My Project basically was about fetching data from an Api "asynchronously", let me explain a little, Since JavaScript as a programming language is always synchronous and single-threaded, it executes/read code line by line, which means, in case I'm trying to fetch data, it could take a while, depending on the size of the data I'm trying to fetch, which also means, the whole page would stop and freeze until that fetching process is complete and also successful and here comes the need to use the JavaScript asynchronous built in method, "fetch". fetch returns a "Promise", A simple way to explain it is: while the asynchronous method that is used to fetch the data is running, it could take its sweet time but it will not stop JavaScript from executing the rest of the code, even when there is an error during the fetching process.
Now that I explained the main part that was crucial for building my project, I'll talk a little more about the fun part, the features I added to my phase-1 project.
I used a recipe and food API, built a random recipe generator and also a search ingredients form that upon submission will return a list of 10 recipes that matches the search form inputs. Also I added a comment section and for that, I hosted a json-server that I used to fetch data to and from (POST, GET) to display the comments on the page, and that would be it for my first project, here is a link to it if you would like to check it out:

https://www.youtube.com/watch?v=va0AYjBYYh0

Next week we will be starting with React, I'm super excited and looking forward to it, I have been watching videos of all the amazing applications that was built using React, hopefully I'll build my own one day. 

Thank you for reading.
Fast Request v1.1.4 release, IDEA based PostMan plug-in
Tags: intellij, tooling, api, postman
Published: 2021-07-19 00:45:08

![Example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ilrhpr1wdwny6gowcn9l.gif)

release detail:
1.curl support
2.support add params to header from
3.support pretty and raw response
4.support expand and collapse json params
5.support toggle request and response panel
6.remove domain from url
7.optimize the interaction add/remove json params
8.fix send request return error response parse error

doc:https://github.com/kings1990/fast-request-doc
plugin url:https://plugins.jetbrains.com/plugin/16988-fast-request
Deploy Vue.js projects to Heroku
Tags: vue, heroku, github
Published: 2021-07-19 00:30:41

The first time I was to ever host a Vue app on Heroku was a hustle. I ran into multiple errors which then inspired this article to help make the life of my fellow Vue developers easier by putting together the right and easy way to host apps on Heroku.

Heroku is one of the tools used by developers to deploy, manage, and scale modern apps. Some reasons you would want to choose Heroku as your host is because it's user friendly, supports several databases and data stores, you also have the option to link your app directly from GitHub and enable default deployment each time you push some code into master (isn't that amazing!).

**To follow along, I want to assume you have a Vue app up and running and you also have an Heroku account. That out of the way, lets get right into it.**


###Create a node server
The first step is to create a node server to serve your Vue files and writing a simple express server can help get the job done. Run the following command to install express and serve-static.

```
npm install express serve-static

 ```


Then create a file in the root of your project called **server.js** (feel free to name it as you please) and then add the following code blocks.

```javascript
const express = require('express');
const serveStatic = require("serve-static")
const path = require('path');
app = express();
app.use(serveStatic(path.join(__dirname, 'dist')));
const port = process.env.PORT || 3000;
app.listen(port);

```


###Add package.json scripts

```javascript

"postinstall": "npm run build",
"start": "node server.js"

```


The "postinstall" script is the script Heroku will run after installing dependencies but before starting the app while the "start" script is the default script Heroku will try to run once all dependencies are installed to start the app.

Note: incase you didn't name your file server.js, remember to use your correct naming (node [file-name].js).



###GitHub and Heroku
The next step is to create a GitHub repository for your project (if you don't have one already) and then push your ready to be deployed code to the branch you choose to deploy.
From your Heroku dashboard create a new app


![create new heroku app](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9wb0xmq5cy9p79j6icb9.png)

Afterwards, choose the GitHub option(connect to GitHub) as your deployment method. select the appropriate repository to deploy.

![choose github repository to deploy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c2xqigvfvz0ddps0xe7z.png)


You should see something like the images below. Enabling automatic deploy is optional but then why not?

After enabling automatic deploy, click on Deploy branch (the second image).
This could take a while but by the time it's done deploying, your app is LIVE on Heroku.

![choose automatic deployment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/imgo49em91y8lw81sm6r.png)

![deploy branch](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wu1877ogakyvwe0vipwp.png)



You have successfully deployed your Vue.js project to Heroku!
Reset WordPress File Permissions
Tags: wordpress, tutorial
Published: 2021-07-21 06:49:16

---
title: Reset WordPress File Permissions
published: true
date: 2021-07-19 00:00:00 UTC
tags: WordPress, tutorial
canonical_url: https://jackharner.com//blog/reset-wordpress-file-permissions/
---

[Originally Posted to JackHarner.com](https://jackharner.com/blog/reset-wordpress-file-permissions/)

Somehow I continuously run into File Permissions Issues while working with WordPress, so this is primarily just a reference for myself. For whatever reason, things can get pretty hectic, and you've probably ran into a similar issue if you've ever seen a "Permission Denied" error, or if WordPress asks you for your FTP Connection Information to update a plugin.

![WordPress asking for Connection Information](https://jackharner.com/static/bed1aeac20e55f178ab525719878f31c/5c6e9/connection.png "WordPress asking for Connection Information")

Sometimes it's just best to reset everything back to the way Apache needs it to be to run smoothly: `775` on folders, and `664` on files.

Run the following 3 terminal commands from the root of your WordPress install (the folder containing your `wp-config.php` file):

```
chown www-data:www-data -R * # Set Apache's www-data user as the owner
find . -type d -exec chmod 775 {} \; # Change folder permissions to rwxrwxr-x
find . -type f -exec chmod 664 {} \; # Change file permissions to rw-rw--r--
```

I'm sure future me is thanking "now" me for writing this down so I can stop googling it. You're welcome future me!