git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git
cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
div { | |
background : url(../assets/images/); // don't use quotes in url like url('') | |
// and use paths relative to the file editing | |
} |
// Reference: https://stackblitz.com/edit/vue-watch-only-once?file=index.js | |
import Vue from 'vue'; | |
// Watch "isLive" via $watch to invoke the returned unwatch | |
// handler after the component went live for the first time. | |
// Because the websocket stays live and only die visualization | |
// is stopped. | |
const Child = Vue.component('child', { | |
props: { |
// modify react childrens while rendering in class component (can also be done in FCs) | |
render() { | |
if (this.props.children) { | |
return React.Children.map(this.props.children, (childElement) => { | |
if (childElement.type === 'string') return childElement; // return non React components as it is | |
return React.cloneElement(childElement, { | |
// pass additional props implicitly to the child react components | |
prop1: this.state.prop1, | |
prop2: this.prop2 | |
}) |
canvas.toBlob((blob) => { | |
const anchor = document.createElement('a'); | |
anchor.download = 'my-file-name.jpeg'; // optional, but you can give the file a name | |
anchor.href = URL.createObjectURL(blob); | |
anchor.click(); // ✨ magic! | |
URL.revokeObjectURL(anchor.href); // remove it from memory and save on memory! | |
}, 'image/jpeg', 0.9); |
def removeDuplicates(nums): | |
nums[:] = [x for idx, x in enumerate(nums) if idx == 0 or x != nums[idx - 1]] | |
return len(nums) |
def maxp3(self, A): | |
A.sort() | |
maxp3 = 1 | |
max3 = A[-3:] | |
for x in max3: | |
maxp3 *= x | |
edge = A[0] * A[1] * A[-1] | |
return max(edge, maxp3) |
def maximumGap(self, A): | |
# step 0: make a list of touples (value, index) and sort it by value (O(nlogn)) | |
sortedA = sorted(((v, i) for i, v in enumerate(A))) | |
# step 1: init maxGap to store maximum gap between 2 indices | |
# and minNum to store the minimum index so far in the loop | |
maxGap = 0 | |
minNum = sortedA[0][1] | |
#step 2: loop through sortedA to find maximum index gap (O(n)) | |
for i in range(1,len(sortedA)): | |
if sortedA[i][1] < minNum: |
def hotel(self, arrive, depart, K): | |
arrive.sort() | |
depart.sort() | |
n = len(arrive) | |
i,j = 0,0 | |
booked = 0 | |
while i < n and j < n: | |
if arrive[i] < depart[j]: |