Skip to content

Instantly share code, notes, and snippets.

@andras-hegedus
andras-hegedus / increment-numbers-with-generator.ts
Last active July 30, 2020 15:09
TypeScript: increment numbers with generator function
// based on MDN's generator example
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*
function* incNumbers(): Generator<number, never, number> {
let index = 0;
while (true) {
yield index++;
}
}
@andras-hegedus
andras-hegedus / change-auth-user.js
Created June 15, 2020 17:23
Bookmarklet for changing authuser (or any) query parameter
javascript: (function () {
const url = new URL(location.href);
if (url.searchParams.has('authuser')) {
return;
}
url.searchParams.append('authuser', '1');
location.replace(url.toString());
})();
@andras-hegedus
andras-hegedus / javascript.json
Created December 8, 2017 14:51
VS Code logging snippet
{
"Print to console": {
"prefix": "logvar",
"body": [
"console.log('Filename: ${TM_FILENAME} Line: ${TM_LINE_NUMBER}', $1)"
],
"description": "Log variable to console"
},
"JSON Print to console": {