Skip to content

Instantly share code, notes, and snippets.

Avatar

Gil Tayar giltayar

View GitHub Profile
View async-stack-trace.mjs
const delay = () => new Promise(r => setTimeout(r, 0))
async function returnsPromiseDirectly() {
console.log('returnsPromiseDirectly')
await delay()
// ******* TRY CHANGING THIS:
// With await:
// return await throwsException()
View more-prettier-failed-to-load-logs.log
["INFO" - 6:51:53 AM] Extension Name: "prettier-vscode".
["INFO" - 6:51:53 AM] Extension Version: "3.11.0".
["INFO" - 6:51:53 AM] Loaded module 'prettier@1.19.1' from '/Users/giltayar/code/mono/packages/execute-rendering/node_modules/prettier/index.js'
["ERROR" - 6:51:53 AM] Failed to load prettier from ''
Cannot find module 'prettier' from '/Users/giltayar/code/mono/packages/azure-management-client/package.json'
Error: Cannot find module 'prettier' from '/Users/giltayar/code/mono/packages/azure-management-client/package.json'
at Function.e.exports [as sync] (/Users/giltayar/.vscode/extensions/esbenp.prettier-vscode-3.11.0/dist/extension.js:1:318316)
at t.ModuleResolver.findPkg (/Users/giltayar/.vscode/extensions/esbenp.prettier-vscode-3.11.0/dist/extension.js:1:245352)
at t.ModuleResolver.findPkg [as findPkgMem] (/Users/giltayar/.vscode/extensions/esbenp.prettier-vscode-3.11.0/dist/extension.js:1:245710)
at t.ModuleResolver.requireLocalPkg (/Users/giltayar/.vscode/extensions/esbenp.prettier-vscode-3.11.0
View another-prettier-fail.log
[INFO - 8:45:57 PM] Extension Name: "prettier-vscode".
[INFO - 8:45:57 PM] Extension Version: "3.9.0".
[INFO - 8:45:57 PM] Loaded module 'prettier@1.19.1' from '/Users/giltayar/code/mono/browser-images/selenium-image/node_modules/prettier/index.js'.
[INFO - 8:45:57 PM] Failed to load prettier from .
[INFO - 8:45:57 PM] Failed to load prettier from .
[INFO - 8:45:57 PM] Loaded module 'prettier@1.18.2' from '/Users/giltayar/code/mono/packages/azure-service-bus-commons/node_modules/prettier/index.js'.
[INFO - 8:45:58 PM] Failed to load prettier from .
[INFO - 8:45:58 PM] Loaded module 'prettier@1.16.4' from '/Users/giltayar/code/mono/packages/azure-service-bus-testkit/node_modules/prettier/index.js'.
[INFO - 8:45:58 PM] Loaded module 'prettier@1.18.2' from '/Users/giltayar/code/mono/packages/build-commons/node_modules/prettier/index.js'.
[INFO - 8:45:58 PM] Loaded module 'prettier@1.19.1' from '/Users/giltayar/code/mono/packages/cdt-page-renderer/node_modules/prettier/index.js'.
View prettier-fail.log
[INFO - 8:10:31 AM] Extension Name: "prettier-vscode".
[INFO - 8:10:31 AM] Extension Version: "3.7.0".
[INFO - 8:10:31 AM] Loaded module 'prettier@1.18.2' from '/Users/giltayar/code/mono/packages/rendering-worker-farmer/node_modules/prettier/index.js'.
[INFO - 8:10:31 AM] Failed to load prettier from .
[INFO - 8:10:31 AM] Failed to load prettier from .
[INFO - 8:10:31 AM] Loaded module 'prettier@1.18.2' from '/Users/giltayar/code/mono/packages/azure-service-bus-commons/node_modules/prettier/index.js'.
[INFO - 8:10:31 AM] Failed to load prettier from .
[INFO - 8:10:31 AM] Loaded module 'prettier@1.16.4' from '/Users/giltayar/code/mono/packages/azure-service-bus-testkit/node_modules/prettier/index.js'.
[INFO - 8:10:31 AM] Loaded module 'prettier@1.18.2' from '/Users/giltayar/code/mono/packages/build-commons/node_modules/prettier/index.js'.
[INFO - 8:10:31 AM] Loaded module 'prettier@1.19.1' from '/Users/giltayar/code/mono/packages/cdt-page-renderer/node_modules/prettier/index.js'.
View setInterval-bunching.js
let i = 0
const start = Date.now()
setInterval(() => console.log(++i, Date.now() - start), 1000)
console.time('bigcalc')
for (let i = 0; i < 10000000000; ++i) {
Math.cos(37863443 * Math.exp(23749374))
}
console.timeEnd('bigcalc')
View computeIntensiveRunner.js
const {promisify} = require('util')
const crypto = require('crypto')
function randomString() {
return crypto.randomBytes(100).toString('hex');
}
function* computeIntensiveCode() {
const hash = crypto.createHash('sha256');
for (let i=0; i < 100; i++) {
View cypress-example.js
'use strict'
describe(`TodoMVC using Cypress`, function () {
it('can add todos and then delete them', () => {
cy.visit('http://todomvc.com/examples/react/#/')
cy.get('.new-todo').type('Cook dinner{enter}')
cy.get('.view > label').should('have.text', 'Cook dinner')
cy.get('.new-todo').type('Clean house{enter}').then(() => {debugger})
View cypress-good-conditional-code.js
cy.contains('item left')
// do the following code on the element that contains "item left".
.then(countItemsLeft => {
// if the text in the element is "1 items left", log it.
if (countItemsLeft.innerText === '1 items left') {
console.log('lalala!')
}
})
View cypress-bad-conditional-code.js
const countItemsLeft = cy.contains('item left')
if (countItemsLeft.innerText === '1 items left') {
// do something...
}
View cypress-todomvc-example_spec.js
describe(`TodoMVC using Cypress`, function () {
it('can add todos and then delete them', () => {
// visit the todomvc application
cy.visit('http://todomvc.com/examples/react/#/')
// type a new todo into the "new todo" input field.
cy.get('.new-todo').type('Cook dinner{enter}')
// ensure that a new todo was created correctly
cy.get('.view > label').should('have.text', 'Cook dinner')
You can’t perform that action at this time.