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
/** | |
* This script is used to run measurements on CodeSignal https://app.codesignal.com | |
* to use it simply open the dev tools, and paste in the console, | |
* it will automate the browser for you to run the tests and measure the times it took. | |
* be patient, there are measurements to prevent blocking from CodeSignal, | |
* and this script just automates the browser which means it cannot run tests in parallel | |
* so the tests will take a while, just run this and go grab a coffee. | |
* | |
* !!!CAUTION!!! this isn't an official script and might get you banned from CodeSignal | |
* even though there are measurements to try and prevent this, use caution. |
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
Adb shell # get into the phone's shell | |
> pm list packages # get the list of packages, skip if you know the package name | |
> pidof -s <package-name> # get the process ID of the package | |
> exit # exit the shell and go back to the pc shell | |
adb logcat --pid=<pid> # log only from a specific process ID |
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
// if you want a demo, just throw it in the console | |
// it won't work in github's console since they use {"connect-src": "self"} header, you can however do it in google.com | |
// or almost any other website | |
// | |
// yandex translation api is free for up to 1 million characters a day 🤩 | |
// you can set up a free key here: https://tech.yandex.com/translate/ | |
// or just use this, since it's from a fake account it might get blocked in the near future | |
const KEY = 'trnsl.1.1.20190308T095934Z.95ae5cf4e28588ea.9d108fb6e768af347464925e4e98b91edb0013f5'; | |
const FROM = 'nl'; // default source language | |
const TO = 'en'; // default target language |
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
// a simple utility function for normalizing return values | |
const returnValue = values => values.length === 1 ? values[0] : values;; | |
// a simple function to check existence | |
const exists = value => value !== undefined && value !== null; | |
const isString = value => typeof value === 'string'; | |
const isArray = value => Array.isArray(value); | |
// This is the actual class to hold all of our classes | |
class ElementAbstraction { | |
constructor(htmlElements) { |
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
// Let's check if the browser supports notifications | |
if (!("Notification" in window)) { | |
alert("This browser does not support desktop notification"); | |
} | |
function notify() { | |
new Notification("Hello world!"); | |
} | |
// Let's check whether notification permissions have already been granted |
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
// the example: | |
if('indexedDB' in window) { | |
// open the database | |
openDB(window.indexedDB, 'todos-db') | |
// add some todos | |
.then(({ db }) => addTodo(db, 'my todo text 1')) | |
.then(({ db }) => addTodo(db, 'my todo text 2')) | |
// get all the todos | |
.then(({ db }) => getTodos(db)) | |
.then(({ db, event }) => { |
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 { Worker } = require("worker_threads"); | |
const path = require("path"); | |
const os = require("os"); | |
const ora = require("ora"); | |
// this is how we can get the count of cpu's the computer has, | |
// using a larger number may result in the app crushing | |
const cpuCount = os.cpus().length; | |
// create some big array |
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 { parentPort, workerData, isMainThread } = require("worker_threads"); | |
// CPU consuming function (sorting a big array) | |
function sortBigArray(bigArray) { | |
return bigArray.sort((a, b) => a - b); | |
} | |
// check that the sorter was called as a worker thread | |
if (!isMainThread) { | |
// make sure we got an array of data |
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 { Worker } = require("worker_threads"); | |
const path = require("path"); | |
// create some big array | |
const elements = 1000000; | |
const bigArray = Array(elements) | |
.fill() | |
.map(() => Math.random()); | |
// we get the path of the script |
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 beforeHook = (...props) => { | |
console.log('before call') | |
return props; | |
}; | |
const afterHook = (response) => { | |
console.log('after call') | |
return response; | |
}; |
NewerOlder