View intersection-detail.js
var observer = new IntersectionObserver(changes => {
for (const change of changes) {
console.log(change.time); // Timestamp when the change occurred
console.log(change.rootBounds); // Unclipped area of root
console.log(change.boundingClientRect); // target.boundingClientRect()
console.log(change.intersectionRect); // boundingClientRect, clipped by its containing block ancestors, and intersected with rootBounds
console.log(change.intersectionRatio); // Ratio of intersectionRect area to boundingClientRect area
console.log(change.target); // the Element target
}
}, {});
View intersection-intro.js
const observer = new IntersectionObserver(callback);
const target = document.querySelector('#target');
observer.observe(target);
function callback(entries) {
// Do action here
}
View setStateCallback.js
function handleChange(value) {
this.setState({
value: newValue
}, ()=>{
console.log(this.state.value);
});
}
View setState.js
function handleChange(value) {
this.setState({
value: newValue
});
console.log(this.state.value); //Why is my state not updated?
}
View gist:0a1e2c7dc4671735504912f83b44cf67
codemod "expect\((.*?)\.hasClass\(('.*?')\)\)\.to\.equal\(true\)" 'expect(\1.classes()).to.include(\2)'
codemod "expect\((.*?)\.hasClass\(('.*?')\)\)\.to\.equal\(false\)" 'expect(\1.classes()).to.not.include(\2)'
codemod "expect\((.*?)\.hasAttribute\(('.*?'),('.*?')\)\)\.to\.equal\(true\);" ''
View fibonacci.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script src="thengascript.js"></script>
View javascriptreact.json
{
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');"
],
"description": "Log output to console"
},
"Bind Function": {
"prefix": "bind",
View style.css
.container {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
View img_as_float.py
import cv2
import numpy as np
from skimage import img_as_float
#Read image from given direcotory
image = cv2.imread('C:\Python27\images\pic.jpg')
#Print pixel at (100,100)
print image[100,100]
#................ image converted to float.............
View database.py
import MySQLdb
# Open database connection
db = MySQLdb.connect("localhost","root","","dbName" )
# prepare a cursor object using cursor() method
cursor = db.cursor()
# execute SQL query using execute() method.
cursor.execute("SELECT VERSION()")