teleren/devto huggingface dataset:
HTML : App Cache [deprecated]
Tags: html, webdev, programming, productivity
Published: 2021-05-12 08:00:51

With app cache it is easy to make an offline version of a web application, by creating a cache manifest file.

# What is App Cache?
HTML5 introduces application cache, which means that a web application is cached, and accessible without an internet connection.

# Advantages:

* Offline browsing - users can use the application when they're offline
* Speed - cached resources load faster
* Reduced server load - the browser will only download updated/changed resources from the server

# How to enable app cache?
To enable application cache, include the manifest attribute in the document's <html> tag:
```html
<!DOCTYPE HTML>
<html manifest="index.appcache">
...
</html>
```

# Basic Example of HTML5 cache
This is our `index.html` file -
```html
<!DOCTYPE html>
<html manifest="index.appcache">
<body>
 <p>Content</p>
</body>
</html>
```
then we will create `index.appcache` file with below codes
```html
CACHE MANIFEST
index.html
```
write those files that you want to be cached load index.html then go for offline mode and reload the tab.

>Note: The two files must be in the same folder in this example.

More details can be found at - https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache

> *Unfortunately this feature is in progress of being deprecated so please do not use for your upcoming projects*

<a href="https://www.buymeacoffee.com/rkycom" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>

With all that being said, I highly recommend you keep learning!

Thank you for reading this article. Please feel free to connect with me on [LinkedIn](https://www.linkedin.com/in/www-rajeshkumaryadav-com/) and [Twitter](https://twitter.com/rky_com).
Introduction to ARRAYS
Published: 2021-05-12 07:54:02

An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together. This makes it easier to calculate the position of each element by simply adding an offset to a base value, i.e., the memory location of the first element of the array (generally denoted by the name of the array). The base value is index 0 and the difference between the two indexes is the offset.

For simplicity, we can think of an array as a fleet of stairs where on each step is placed a value (let’s say one of your friends). Here, you can identify the location of any of your friends by simply knowing the count of the step they are on. 
Remember: “Location of next index depends on the data type we use”. 
In C language array has a fixed size meaning once the size is given to it, it cannot be changed i.e. you can’t shrink it neither can you expand it. The reason was that for expanding if we change the size we can’t be sure ( it’s not possible every time) that we get the next memory location to us as free. The shrinking will not work because the array, when declared, gets memory statically, and thus compiler is the only one to destroy it.


Types of indexing in an array: 
0 (zero-based indexing): The first element of the array is indexed by a subscript of 0
1 (one-based indexing): The first element of the array is indexed by the subscript of 1
n (n-based indexing): The base index of an array can be freely chosen. Usually, programming languages allowing n-based indexing also allow negative index values, and other scalar data types like enumerations, or characters may be used as an array index.
DQN cartpole-v1
Tags: deeplearning, machinelearning, python
Published: 2021-05-12 07:41:46

Hi! I made this video to show my algorithm from scratch of a deep q network with minibatch gradient descent, target network, momentum and a little variation of gym cartpole-v1 environment
https://www.youtube.com/watch?v=gmQn5_izEjM&t=18s&ab_channel=LorenzoTinfena
How to Track Versions with MongoDB

Tags: help, mongodb, architecture, design
Published: 2021-05-12 07:40:19

Consider requirement that we have to be able to recreate/query any version of a document that ever existed in a particular collection. So we start out with:

```
{   docId: "A",
    v: 1,
    color: "red",
    locale: "USA"
}
```
If we need to set color to “blue”, instead of updating the “color” field from “red” to “blue”, we have to create a new version of the document which now has its full “current” state, and preserve somehow the old version of the document. So we insert

```
{   docId: "A",
    v: 2,
    color: "blue",
    locale: "USA"
}
```
The goal is to preserve every state for each object, but we only respond to queries with the “current” or “latest” version, we just have a requirement to be able to have an audit (which would be very infrequent so it’s okay if it’s slow). Is keeping each version as we do in this example the best schema/approach to this problem?
DEADLOCK PREVENTION AND AVOIDANCE
Published: 2021-05-12 07:31:21

Deadlock Prevention and Avoidance

Deadlock characteristics
1. Mutual Exclusion
2. Hold and wait
3. No preemption
4. Circular wait

Deadlocks can be prevented by eliminating these conditions

Eliminating Mutual exclusion
It is not possible to do this as some resources such as the drivers and printers
are inherently non-shareable.

Eliminating Hold and wait
Allocate all necessary resources to the process before it begins to run; this
eliminates the hold and wait conditions, but it results in low system
utilization. For instance, if a process needs printing at a later time and we have
allocated a printer before the start of its execution, the printer will be blocked
until the process is completed.
This process will make new requests for a resource after releasing set of
resources but this may lead to starvation

Eliminating No preemption
Preempt resources from the process when it is required by other high priority
process

Eliminate Circular wait
A numerical number will be allocated to each resource. A process may request
that the number of resources be increased or decreased. For example, if P1 is
given R5 resources, the next time P1 requests R4, R3, or any other resource
less than R5, the request will be denied; only requests for resources greater
than R5 will be granted.

Deadlock avoidance
This can be done with Banker's Algorithm
Bankers Algorithm:
Bankers’ Algorithm is a resource allocation and deadlock avoidance algorithm
that examines all resource requests made by systems, checks for the safe state,
and makes the request if the system remains in the safe state after approving
the request. If there is no safe state, the request is denied.

Inputs required for Bankers algorithm:
1. maximum need or resources required by each process
2. The currently allocated resources by each process
3. Free resources available in the system

Request for the resource will only be granted when:
1. If the request made by the process is </<= freely available resource in the system
2. If the request made by the process is </<= maximum amount of
resources required for the process
how to make pie chart in kibana
Published: 2021-05-12 07:28:21

Pie charts are a form of sorting information given to us for our convenience. it is an easy and fun way to sort the small piece of info required from a large group

first, make sure you open the kibana website

1.Select the Visualize tab from the left menu bar

2.Click the Create a Visualization button

3.Select the Pie chart

 


you will get a basic pie chart like this



next, in the pie chart editor use the matrices as shown below

1)Click to expand the Slice Size

2)Select Unique Count from the Aggregation pull-down

3)Select transmitterId.keyword from the Field pull-down

4)Enter a label in the Custom Label field

5)Click the right arrow on the top of the toolbar to update the changes 

now adjust the Buckets as shown below 1)Click to expand the Split Slices buckets

2)Select Filters aggregation from the pull-down

3)Each filter will collect all documents that match its associated zone. Customize the filter by adding receiverId.keyword(s), an RSSI threshold, a Type filter, etc.

4)Define a Label to specify the zone by clicking the icon.

5)Click the right arrow on the top of the toolbar to update the changes



after this, the pie chart will look like this



The color of the pie chart can be changed by clicking directly on the color of each slice on the right side of the chart.

Then, to get information, follow the next steps.

Open Options tab and then:

1)Check the Show Label box from the Label settings

2)Click the right arrow on the top of the toolbar to update the changes
How often do you maintain the code that's not a part of your favorite stack?
Tags: watercooler, webdev, coding
Published: 2021-05-12 06:45:04

---
title: How often do you maintain the code that's not a part of your favorite stack?
published: true
description: 
tags: watercooler, webdev, coding
cover_image: https://nickroberts.ninja/wp-content/uploads/2016/10/php-code.jpg
---
For example, you are focusing on mastering MERN stack, but you still have to maintain codebases written in PHP and jQuery (no offense).

How often do you find yourself in situations like these?
What is the next stage of your dev journey?
Tags: watercooler, discuss, career, motivation
Published: 2021-05-12 06:38:16

How would you describe your current situation in terms of your set of skills and career, is it where you want it to be?

Maybe you’re just getting started learning to code, if so where do you hope to be in say a year's time?

If you work as a developer, do you have any particular career aspirations?
LeetCode 278. First Bad Version
(javascript solution)
Tags: algorithms, javascript
Published: 2021-05-12 06:25:20

###Description:
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.

Suppose you have n versions [1, 2, ..., n] and you want to find out the first bad one, which causes all the following ones to be bad.

You are given an API bool isBadVersion(version) which returns whether version is bad. Implement a function to find the first bad version. You should minimize the number of calls to the API.

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

```javascript
// Binary search
var solution = function(isBadVersion) {
    /**
     * @param {integer} n Total versions
     * @return {integer} The first bad version
     */
    return function(n) {
        // Min left start is 1
        let left = 1, right = n
        while(left < right) {
            const mid = left + Math.floor((right-left)/2)
            if(isBadVersion(mid)) {
                right = mid
            } else {
                left = mid + 1
            }
        }
        return left
    };
};
```
Xcode 12.5 archiving the App got issue “Build input file cannot be found”
Published: 2021-05-12 06:25:04

Background: We trying to update Xcode version from 11 to 12.4. Such updating, we was able to run on both stimulator and real device. But when we tried to archive the app to upload testflight. we faced this issue “Build input file cannot be found”. 

We are looking how to solve such errors. Thanks.
Weekly web development resources #73
Tags: weekly, webdev
Published: 2021-05-12 06:20:57



______

##[How React hooks work](https://eliav2.hashnode.dev/how-react-hooks-work-in-depth)
[![How React hooks work](https://wweb.dev/weekly/content/73/hooks.jpg)](https://eliav2.hashnode.dev/how-react-hooks-work-in-depth)
An in depth article that explains and demonstrates how React hooks work.

______

##[Building split text animations](https://web.dev/building-split-text-animations/)
[![Building split text animations](https://wweb.dev/weekly/content/73/split-text.jpg)](https://web.dev/building-split-text-animations/)
A foundational overview of how to build split letter and word animations.

______

##[The Quest for “Perfect” Infinite Scrolling ](https://css-tricks.com/going-meta-gsap-the-quest-for-perfect-infinite-scrolling/)
[![The Quest for “Perfect” Infinite Scrolling ](https://wweb.dev/weekly/content/73/infinite-scroll.jpg)](https://css-tricks.com/going-meta-gsap-the-quest-for-perfect-infinite-scrolling/)
An article about a concept, to help you think about animations in a different way.

______

##[ClearURLs](https://github.com/ClearURLs/Addon/)
[![ClearURLs](https://wweb.dev/weekly/content/73/ClearURLs.jpg)](https://github.com/ClearURLs/Addon/)
A browser add-on that will automatically remove tracking elements from URLs. 

______

##[Bootstrap 5](https://blog.getbootstrap.com/2021/05/05/bootstrap-5/)
[![Bootstrap 5](https://wweb.dev/weekly/content/73/v5-new-logo.jpg)](https://blog.getbootstrap.com/2021/05/05/bootstrap-5/)
Bootstrap is shipping the first stable release of the new major version.

______

##[HTML Tips](https://markodenic.com/html-tips/)
[![HTML Tips](https://wweb.dev/weekly/content/73/html-tips.jpg)](https://markodenic.com/html-tips/)
An article with some useful HTML tips.

______

##[HTML and CSS Checkbox Examples](https://www.sliderrevolution.com/resources/css-checkbox/)
[![HTML and CSS Checkbox Examples](https://wweb.dev/weekly/content/73/checkboxx.jpg)](https://www.sliderrevolution.com/resources/css-checkbox/)
An article with some cool CSS checkbox examples-

______

##[Oslo](https://oslo-vsc.netlify.app/)
[![Oslo](https://wweb.dev/weekly/content/73/hooks.jpg)](https://oslo-vsc.netlify.app/)
A cool generator for VSCode themes.

______

##[Web Accessibility for Newbies](https://levelup.gitconnected.com/web-accessibility-for-newbies-1098fa15f9f0)
[![Web Accessibility for Newbies](https://wweb.dev/weekly/content/73/web-accessibility.jpg)](https://levelup.gitconnected.com/web-accessibility-for-newbies-1098fa15f9f0)
Introductory information and advice on how to think about and approach web accessibility

______

##[Fluid typography](https://fluid-typography.netlify.app/)
[![Fluid typography](https://wweb.dev/weekly/content/73/fluid.jpg)](https://fluid-typography.netlify.app/)
An online tool to create text that scales with the window size.

______

To see all the weeklies check: [wweb.dev/weekly](https://wweb.dev/weekly)
What's your favorite Static Site Generator?
Tags: watercooler, webdev, ssg
Published: 2021-05-12 06:08:52

---
title: What's your favorite Static Site Generator?
published: true
description: 
tags: watercooler, webdev, ssg
cover_image: https://snipcart.com/media/205627/bestssg.png
---
SSGs handle the build process before the pages are requested by the client, meaning that they’re ready to serve when requested.

Some of the most common choices include NextJS, Gatsby, Hugo, Jekyll, Eleventy, Nuxt, Hexo, and [many others](https://jamstack.org/generators/).

Which ones have you tried and what are your favorites?
LeetCode 35. Search Insert Position (javascript solution)

Tags: algorithms, javascript
Published: 2021-05-12 05:51:27

###Description:
Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.

You must write an algorithm with O(log n) runtime complexity.

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

```javascript
// Binary Search
var searchInsert = function(nums, target) {
    let left = 0, right = nums.length
    while(left < right) {
        const mid = left + Math.floor((right - left) / 2)
        if(nums[mid]===target) {
           return mid
        } else if(nums[mid] > target){
            right = mid
        } else {
            left = mid + 1
        }
    }
    return left
};
```
My Moodle Tips #3
Tags: moodle, lms, administration, php
Published: 2021-05-12 05:37:36

Do full cleanup for every completed courses by your users (regularly or on demand). They usually don't aware of your limited resources.

From my perspective, you may need to:
- Go to a **Course settings** > **Reset course** > **Check all** course module categories and options _that considerably consume too many resources_ > **Reset course**
- Unenroll inactive users. If you have external database enrolments and/or authenticated users, you may want to delete all associated user's data that not currently active from those tables. Make sure the related Moodle CRON jobs are active for this case.

Be aware of these course resources! (your case may be different)
- Assignments
- Files/Folders
- Quizzes
Algorithmic Game Theory
Published: 2021-05-12 05:25:42

Game theory is a branch of mathematics devoted to studying interaction among rational and self-interested
agents. The field took on its modern form in the 1940s
and 1950s (von Neumann and Morgenstern 1947; Nash 1950,
Kuhn 1953), with even earlier antecedents (such as Zermelo
1913 and von Neumann 1928). Although it has had occasional
and significant overlap with computer science over the years,
game theory received most of its early study by economists.
Indeed, game theory now serves as perhaps the main analytical
framework in microeconomic theory, as evidenced by its prominent role in economics textbooks (for example, Mas-Colell,
Whinston, and Green 1995) and by the many Nobel prizes in
economic sciences awarded to prominent game theorists.
Artificial intelligence got its start shortly after game theory
(McCarthy et al. 1955), and indeed pioneers such as von Neumann and Simon made early contributions to both fields (see,
for example, Findler [1988], Simon [1981]). Both game theory
and AI draw (nonexclusively) on decision theory (von Neumann and Morgenstern 1947); for example, one prominent
view defines artificial intelligence as “the study and construction of rational agents” (Russell and Norvig 2003), and hence
takes a decision-theoretic approach when the world is stochastic. However, artificial intelligence spent most of its first 40 years
focused on the design and analysis of agents that act in isolation, and hence had little need for game-theoretic analysis.
Starting in the mid to late 1990s, game theory became a
major topic of study for computer scientists, for at least two
main reasons. First, economists began to be interested in systems whose computational properties posed serious barriers to
practical use, and hence reached out to computer scientists;
notably, this occurred around the study of combinatorial auctions (see, for example, Cramton, Shoham, and Steinberg 2006).
Second, the rise of distributed computing in general and the
Internet in particular made it increasingly necessary for computer scientists to study settings in which intelligent agents reason about and interact with other agents. Game theory generEditorial
Copyright © 2010, Association for the Advancement of Artificial Intelligence.
Strange Behavior in JavaScript
Tags: javascript, uiweekly, webdev, typescript
Published: 2021-05-12 05:21:25

#### There are numerous occasions where JavaScript behaves strangely.

I love the frameworks written on top of javascript but do not prefer to write code in javascript.

Please find below cases where javascript behave differently:

#### Scenario 1

As shown below, see addition and subtraction.

```
11+1 //12

'11'+1 //111

11-1 //10

'11'-1 //10 //What is hell? right?
```

#### Scenario 2

JavaScript is very loosely concerning data types.

```
let name="Sukhpinder";setTimeout(function(){ name="Singh"});

console.log(name); //Sukhpinder
```

[![](https://cdn-images-1.medium.com/max/800/1*69zPqLIzskYHHrxwwEl0lg.png)](https://cdn-images-1.medium.com/max/800/1*69zPqLIzskYHHrxwwEl0lg.png)

#### Scenario 3

I was overwhelmed with the event loop because JS does not merely execute code from top to bottom, waiting when interrupted.

```
function add(a,b){ return a+b;}

//One parameter missing it wont work add(3); //Nan

//One parameter extra don't care add(1,2,3); //3
```

[![](https://cdn-images-1.medium.com/max/800/1*J1Kv4SO1iykDtQLP6Xybbg.png)](https://cdn-images-1.medium.com/max/800/1*J1Kv4SO1iykDtQLP6Xybbg.png)

#### Scenario 4

Not only data types, everything is designed very loosely coupled in JavaScript.

```
0.1+0.2 //0.30000000000000004

2.3*100 //229.99999999999997
```

[![](https://cdn-images-1.medium.com/max/800/1*k5qCmw3iiEVfkZP4haKgLA.png)](https://cdn-images-1.medium.com/max/800/1*k5qCmw3iiEVfkZP4haKgLA.png)

#### Scenario 5

Imprecise operations in Javascript, the same problem can be seen in other programming languages like Python.

```
console.log(!![]) //true

console.log([]==true) //false
```

[![](https://cdn-images-1.medium.com/max/800/1*41ToxQuiMPBkxMKz6nLcXw.png)](https://cdn-images-1.medium.com/max/800/1*41ToxQuiMPBkxMKz6nLcXw.png)

#### Scenario 6

It does not know what to say about below, which is entirely illogical.

```
Array.prototype.push("Hello");

let empty=[];

console.log(empty[0]); //Hello

console.log(empty.length); //0
```

[![](https://cdn-images-1.medium.com/max/800/1*-nK8VaLyf57DHvAW2gRkiQ.png)](https://cdn-images-1.medium.com/max/800/1*-nK8VaLyf57DHvAW2gRkiQ.png)

Overall, JavaScript is more accessible to write because for several reasons. On the other hand, JavaScript makes you feel insecure, as described in different scenarios above.

Thank you for reading and I hope you liked the article..!! Please share your thoughts in the comment section.
  
  <a href="https://www.buymeacoffee.com/sukhpindersingh" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>
LeetCode 69. Sqrt(x)
(javascript solution)
Tags: algorithms, javascript
Published: 2021-05-12 05:20:02

###Description:
Given a non-negative integer x, compute and return the square root of x.

Since the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned.

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

```javascript
// Binary search approach
var mySqrt = function(x) {
    let left = 1;
    let right = x;
    // The square root of 0 or 1 is itself
    if(x < 2) return x;
    
    // Use binary search to find the square root or the whole number closest to the square root
    while(left < right) {
        // Find the mid point between left and right
        const mid = Math.floor((left + right) / 2)
        // Return the mid point if this is the square root
        if(mid*mid === x) return mid
        // If mid squared is greater than x then the answer must be on the left half of mid
        else if(mid*mid >x) right = mid
        // If mid squred is less than x then the answer must be on the right half of mid
        else left = mid+1
    }
    return left - 1
};
```
Highchart Donut Chart with PHP and MySQL Example Tutorial

Tags: php, laravel, mysql, programming
Published: 2021-05-12 05:12:49

<p>Here i will give you full example for highcharts donut chart in php with mysql. So let's optically discern the bellow example:</p>


https://codingtracker.blogspot.com/2021/05/highchart-donut-chart-with-php-and.html