This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
name: "Dwight Schrute", | |
email: "[email protected]", | |
avatar: "https://i.ibb.co/PYzBDTy/dwight.png" | |
}, { | |
name: "Kevin Malone", | |
email: "[email protected]", | |
avatar: "https://i.ibb.co/0n7D37f/kevin.png" | |
}, { | |
name: "Pam Beesly", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function freezeApp(duration) { | |
var now = new Date().getTime(); | |
var endTime = now + duration; | |
console.log('start freeze time', new Date().toISOString(), 'window is focused:', document.hasFocus()); | |
while(new Date().getTime() < endTime) document.querySelector('this.is > [very] > *[heavy] > .css[selector]'); | |
console.log('end freeze time', new Date().toISOString(), 'window is focused:', document.hasFocus()); | |
} | |
/** | |
* Freeze app for 5000ms with 2000ms delay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyComponent extends React.Component<IProps> { | |
shouldComponentUpdate(nextProps, nextState) { | |
const nextPropsKeys = Object.keys(nextProps) | |
const propsKeys = Object.keys(this.props) | |
if (nextPropsKeys.length !== propsKeys.length) { | |
console.warn(`[MyComponent]: Mismatch in prop's keys`) | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function RGBAtoRGB(r, g, b, a, r2,g2,b2){ | |
var r3 = Math.round(((1 - a) * r2) + (a * r)) | |
var g3 = Math.round(((1 - a) * g2) + (a * g)) | |
var b3 = Math.round(((1 - a) * b2) + (a * b)) | |
return "rgb("+r3+","+g3+","+b3+")"; | |
} | |
$("#result").html(RGBAtoRGB(225,110,0,0.5,255,255,255)); | |
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App extends React.Component { | |
shouldComponentUpdate(nextProps, nextState) { | |
const nextPropsKeys = Object.keys(nextProps); | |
const nextStateKeys = Object.keys(nextState); | |
for (let i = 0; i < nextPropsKeys.length; i++) { | |
const key = nextPropsKeys[i]; | |
if (nextProps[key] !== this.props[key]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request1 = () => new Promise((resolve, reject) => { | |
console.log('request1') | |
setTimeout(() => { | |
console.log('request1-resolved') | |
resolve(true) | |
}, 1000) | |
}) | |
const request2 = () => new Promise((resolve, reject) => { | |
console.log('request2') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bob(val) { | |
if (this === window) { | |
return (new bob(val)).factorInc(); | |
} | |
else { | |
this.v = val; | |
} | |
} | |
bob.prototype.inc = function(v) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
# ... | |
gzip on; | |
gzip_disable "msie6"; | |
gzip_vary on; | |
gzip_proxied any; | |
gzip_comp_level 6; | |
gzip_buffers 16 8k; | |
gzip_http_version 1.1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('myModule') | |
.directive('ngPhone', function() { | |
return { | |
require: 'ngModel', | |
link: function(scope, elem, attr, ngModel) { | |
function isPhone(str) { | |
var lengths = [7,10,11]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function eventThrottler(callback) { | |
if (!callback) { | |
return callback; | |
} | |
// @see http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/ | |
var requestAnimFrame = (function() { | |
return window.requestAnimationFrame || | |
window.webkitRequestAnimationFrame || | |
window.mozRequestAnimationFrame || |
NewerOlder