This file contains hidden or 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
var measure = function(fn, iterations, timeout) { | |
iterations || (iterations = 10000); | |
timeout || (timeout = 5000); | |
var i, end, total; | |
var timeoutMsg = ""; | |
var start = performance.now(); | |
for (i = 0; i < iterations; i++) { | |
fn(); | |
end = performance.now(); |
This file contains hidden or 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
export default (number, parts) => { | |
if (!parts) { | |
return []; | |
} | |
let left = number; | |
const result = []; | |
const fullMin = Math.floor(number / parts); |
This file contains hidden or 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 React = require("react"); | |
const { render } = require("react-dom"); | |
const root = document.querySelector("#r"); | |
const itemA = { | |
key: "A", | |
name: "Item A", | |
}; | |
const itemB = { |
This file contains hidden or 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 React = require("react"); | |
const { render } = require("react-dom"); | |
const root = document.querySelector("#r"); | |
// const log = (text) => { | |
// document.querySelector("#log").textContent += "\n" + text; | |
// } | |
// const heavyCalc = () => { |
This file contains hidden or 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 log = (text) => { | |
if (text instanceof Error) { | |
text = "ERROR: " + text.message; | |
} | |
document.querySelector("#log").textContent += "\n" + JSON.stringify(text, null, 4); | |
} | |
const randomTime = () => Math.round(Math.random() * 1000); | |
const notNull = item => item !== null; |
This file contains hidden or 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 u = (item) => { | |
console.log(isNaN(item.name) === false); | |
console.log(item.name !== item.name); | |
} |
This file contains hidden or 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
new Promise((resolve) => { | |
console.log("inside"); | |
resolve() | |
}).then(() => { console.log("then") }); | |
console.log("outside"); |
This file contains hidden or 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
When building an adnroid app, you might stumble upon this error: | |
`Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE...`. Here's how to fix it: | |
That's because the app you're trying to test was already installed on the device and the signatures are different now, so it's complaining. The full error will look like something like this: | |
`Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.example signatures do not match the previously installed version; ignoring!` | |
You can see that the package ID is `com.example`, well, simply run this command: |
This file contains hidden or 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 save = () => JSON.stringify(Object.keys(localStorage).reduce((acc, curr) => { acc[curr] = localStorage.getItem(curr); return acc; }, {})); | |
// Usage in console: | |
copy(save()); | |
// new console | |
o = CTRL+V | |
restore(o); | |
const clean = () => { Object.keys(localStorage).forEach(k => localStorage.removeItem(k)); return true }; |