Skip to content

Instantly share code, notes, and snippets.

@Dobby89
Dobby89 / Productivity.md
Last active April 10, 2025 06:28
Tips & tricks for productivity / workflow

Windows

Tips

  • Remove desktop background (if your company enforces one)
    • If you search in the start menu for Ease of Access, you'll see a result for Ease of Access brightness setting.
    • Once that settings page has been opened, if you scroll down to the bottom, you’ll see an option to Show desktop background image. If you toggle this to off, it will set the background to the default black.

Keyboard shortcuts

@Dobby89
Dobby89 / htmlToElement.ts
Created January 24, 2021 11:28
htmlToElement / htmlToFragment - create HTML from a string
function htmlToElement(htmlString: string): HTMLElement {
const wrapper = document.createElement('div');
wrapper.innerHTML = htmlString;
document.body.appendChild(wrapper);
const el = wrapper.firstChild;
if (el && wrapper.parentNode) {
const elClone = el.cloneNode(true);
wrapper.parentNode.removeChild(wrapper);
return elClone as HTMLElement;
@Dobby89
Dobby89 / waitForAddedNode.ts
Last active January 31, 2021 16:41
Wait for an element to exist
function waitForAddedNode(params: {
query: string;
parent: HTMLElement;
recursive: boolean;
done: (el: HTMLElement) => void;
}): void {
if (!window.MutationObserver) {
return;
}
@Dobby89
Dobby89 / gist:b543cec9b97be6d16e9425989f1b7335
Last active November 11, 2020 08:16 — forked from jaydson/gist:1780598
How to detect a click event on a cross domain iframe
var iframeMouseOver = false;
window.addEventListener('blur',function(){
if(iframeMouseOver){
console.log('Wow! Iframe Click!');
}
});
document.getElementById('YOUR_CONTAINER_ID').addEventListener('mouseover',function(){
iframeMouseOver = true;
@Dobby89
Dobby89 / injectScriptTag.ts
Last active July 16, 2020 07:21
DOM utils / helpers
export function injectScriptTag(src: string, id: string): Promise<boolean> {
// eslint-disable-next-line consistent-return
return new Promise((resolve, reject) => {
if (document.getElementById(id)) {
// Already exists
return resolve(true);
}
const allScripts = document.getElementsByTagName('script');
const lastScriptTag = document.getElementsByTagName('script')[
allScripts.length - 1
@Dobby89
Dobby89 / launch.json
Created December 4, 2019 10:51
Debug VSCode typescript jest tests
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Jest Tests",
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)){ return; }
js = d.createElement(s); js.id = id;
js.onload = function(){
// remote script has loaded
};
js.src = "//domain.com/index.js";
fjs.parentNode.insertBefore(js, fjs);
@Dobby89
Dobby89 / mercurial-commands.sh
Created August 21, 2019 14:19
Useful Mercurial commands
Tell Mercurial you're renaming (not deleting) a file so it keeps the history
If you've already moved/renamed the file:
$ hg rename --after old-file.txt new-file.tx
$ hg rename --after olddir newdir
If you'd like Mercurial to rename the file for you
$ hg rename old-file.txt new-file.tx
$ hg rename olddir newdir
@Dobby89
Dobby89 / search.exclude
Created June 5, 2019 06:40
VS Code exlude patterns. Configured from within settings
**/node_modules
**/bower_components
./public
./coverage
@Dobby89
Dobby89 / Multiple css files
Created May 16, 2019 13:46
Multiple css files in webpack
https://stackoverflow.com/questions/50976979/output-2-or-more-css-files-with-mini-css-extract-plugin-in-webpack