1595745540

# Laziness to the Rescue

In the previous pose(link below), I highlighted how functional programming simplifies the abstract idea of exploring graphs. I demonstrated one of the salient features of Haskell (a FP language) that unburdens us from explicitly managing states while gradually discovering paths between nodes.

## A holistic perspective into exploring graphs using functional programming

Before we start, let me ask you a question — when you encounter a complex problem, isn’t it tempting to start with…

medium.com

Here, I want to take this concept of “laziness” a bit further. Lazy evaluation or laziness as it is colloquially known is delayed evaluation of an expression until we really require its result. It’s like making a promise, fulfilling it only at the nick of time. It lets us define infinite data structures without explicit allocating memory to create and store them. Imagine you are given an infinite steam of large integers **I ( I :: Integer). **For some arcane reason, you want to sort them as they come in. How will you accomplish this? If you’re familiar with traditional sorting algorithms like QuickSort, Merge sort, you will jump and say use them. STOP! Both require data to be in memory. Your stream can look like this : 13,1,2,4,1,9,0,8,11,4,5,3,66,77,112,1091,99,11,2,3,4,5,6…

The only information you have is the bounds of this array, i.e., the lowest value and the highest one. A useful strategy in such a scenario is not to think about any comparison based sorting algorithms — they all have lower bound of Ω(n lg n) (note: unlike Big O, the Big Omega Ω denotes that our function is bounded below). Instead, if we could just ‘tag’ integers as they come by their respective keys which are just integers between lower and upper bound, we would be able to ‘almost’ solve this problem. It’s similar to counting the number of occurrences of each integer in incoming stream, tagging them as they come and accumulating the count of each element. Finally, in the last step we could just exapnd the respective count of each element in the stream to get the sorted array. Data.Array module in Haskell has accumArray function which takes a binary function, initial accumulator, and array to perform the above task.

accumArray :: Ix i = > (e → a → e) → e → (i, i) →[(i, a)] → Array i e

Here, Ix is the class of all **index **types(those that can be used as indices in arrays) — there must be a mapping of a value of type _a _to an offset in a linear array. (e → a →e) denotes the accumulating function, which in our case is simply (+) :: Num l=> l→ l→ l. It’s followed by initial entry at each index with type e (an Integer). (i,i) are bounds of the array. They must be indexable, i.e., have total order property. Finally, as the last argument, we have list of type [(i,a)], an association list of [(1, element1), (1, element2)…]. This is accomplished by zipping our list with 1’s — zip arr \$ iterate id 1

accumArray f e (l,u) list creates an array with indices l…u, in time proportional to u-l, provided f can be computed in constant time. The result is an array whose size is determined by bounds, and whose values are denoted by separating all the values in the list according to their index, and then performing a left-fold operation, using f, on each collection, starting with the value e. You might be thinking that this can be readily used for creating a histogram or performing sorting using bins; well, you’re right.

1601604000

## How to enable SSH access and configure network in rescue mode

### 01/ Enable and Configure network in rescue mode

01- Show available network devices:

``````sh-4.2## ip link

1: lo:  mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
2: eno16777984:  mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT qlen 1000
``````

02- Set the required network device `UP`:

``````sh-4.2## ip link set dev eno16777984 up
``````

– Now use the below command to check the state of the device:

``````sh-4.2## ip link
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
2: eno16777984:  mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
``````

#linux #rescue mode centos #rescue mode enable ssh #rescue mode ssh

1578928162

## cube-vue-image-lazy

A super simple Vue image lazy loader for Vue.

## Install

``````yarn add cube-vue-image-lazy
``````

Warning: You’ll need to install the w3c Intersection Observer polyfill in case you’re targeting a browser which doesn’t support it.

## Usage

You can register the component globally so it’s available in all your apps:

``````import Vue from 'vue'
import ImageLazy from 'cube-vue-image-lazy'

Vue.use(ImageLazy)

// Or you can override defaults
Vue.use(ImageLazy, {
delay: 500,
})
``````

Or use it locally in any of your components:

``````<template>
<div id="App">
<ImageLazy
class="photo"
src="https://source.unsplash.com/random/200x200"
srcset="https://source.unsplash.com/random/400x400 2x"
baseClass="image-lazy"
deferredClass="image-lazy-deferred"
:delay="500"
/>
</div>
</template>

<script>
import ImageLazy from 'cube-vue-image-lazy'

export default {
components: {
ImageLazy
},
data () {
return {
}
}
}
</script>

<style>
.image-lazy {
opacity: 0;
}
transform: translateX(100vh);
}
transition: opacity 1s ease;
opacity: 1;
}
</style>
``````

## Props

Name Required Type Default Description
delay false Number 0 The delay before loading the image when it appears in the viewport.
baseClass false String ‘image-lazy’ The name of the class always added to the image.
deferredClass false String ‘image-lazy-deferred’ The name of the class added while the loading of the image is deferred.

Name Description

## Development Setup

``````# Project setup
yarn install

# Compiles and hot-reloads for development – Run the demo
yarn serve

# Compiles and minifies for production
yarn build

# Builds the npm ready packages
yarn bundle

# Watches for file changes and builds the npm ready packages accordingly
yarn watch

# Lints and fixes files
yarn lint

# Run the unit tests
yarn test:unit
``````

1627383120

## Spring Boot 2.2 Lazy initialization | Spring Eager Vs Lazy Loading

You will learn what is the difference between spring eager vs lazy loading and spring boot 2.2 lazy initialization

#spring boot #spring eager #lazy

1626941700

For More Videos:

Best Practises & Common Mistakes: https://www.youtube.com/watch?v=Qtrl0OEzvMo&list=PL20fyMtMStyHL0uMGRLACViz8-04mhxcC

#react.lazy #react

1595745540

## Laziness to the Rescue

In the previous pose(link below), I highlighted how functional programming simplifies the abstract idea of exploring graphs. I demonstrated one of the salient features of Haskell (a FP language) that unburdens us from explicitly managing states while gradually discovering paths between nodes.

## A holistic perspective into exploring graphs using functional programming

Before we start, let me ask you a question — when you encounter a complex problem, isn’t it tempting to start with…

medium.com

Here, I want to take this concept of “laziness” a bit further. Lazy evaluation or laziness as it is colloquially known is delayed evaluation of an expression until we really require its result. It’s like making a promise, fulfilling it only at the nick of time. It lets us define infinite data structures without explicit allocating memory to create and store them. Imagine you are given an infinite steam of large integers **I ( I :: Integer). **For some arcane reason, you want to sort them as they come in. How will you accomplish this? If you’re familiar with traditional sorting algorithms like QuickSort, Merge sort, you will jump and say use them. STOP! Both require data to be in memory. Your stream can look like this : 13,1,2,4,1,9,0,8,11,4,5,3,66,77,112,1091,99,11,2,3,4,5,6…

The only information you have is the bounds of this array, i.e., the lowest value and the highest one. A useful strategy in such a scenario is not to think about any comparison based sorting algorithms — they all have lower bound of Ω(n lg n) (note: unlike Big O, the Big Omega Ω denotes that our function is bounded below). Instead, if we could just ‘tag’ integers as they come by their respective keys which are just integers between lower and upper bound, we would be able to ‘almost’ solve this problem. It’s similar to counting the number of occurrences of each integer in incoming stream, tagging them as they come and accumulating the count of each element. Finally, in the last step we could just exapnd the respective count of each element in the stream to get the sorted array. Data.Array module in Haskell has accumArray function which takes a binary function, initial accumulator, and array to perform the above task.

accumArray :: Ix i = > (e → a → e) → e → (i, i) →[(i, a)] → Array i e

Here, Ix is the class of all **index **types(those that can be used as indices in arrays) — there must be a mapping of a value of type _a _to an offset in a linear array. (e → a →e) denotes the accumulating function, which in our case is simply (+) :: Num l=> l→ l→ l. It’s followed by initial entry at each index with type e (an Integer). (i,i) are bounds of the array. They must be indexable, i.e., have total order property. Finally, as the last argument, we have list of type [(i,a)], an association list of [(1, element1), (1, element2)…]. This is accomplished by zipping our list with 1’s — zip arr \$ iterate id 1

accumArray f e (l,u) list creates an array with indices l…u, in time proportional to u-l, provided f can be computed in constant time. The result is an array whose size is determined by bounds, and whose values are denoted by separating all the values in the list according to their index, and then performing a left-fold operation, using f, on each collection, starting with the value e. You might be thinking that this can be readily used for creating a histogram or performing sorting using bins; well, you’re right.