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
export default function $(strings, ...expressions) { | |
let selector = [strings[0]]; | |
expressions.forEach((expr, i) => selector.push(expr, strings[i + 1])); | |
return document.querySelector(selector.join("")); | |
} |
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 ext = url.slice(((url.lastIndexOf(".") - 1) >>> 0) + 2); |
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
function pageLoaded() { | |
return new Promise(resolve => { | |
if (document.readyState === "complete") { | |
resolve(); | |
} else { | |
window.addEventListener("load", () => { | |
resolve(); | |
}); | |
} | |
}); |
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
function applyBeforeExit(doBefore) { | |
document.addEventListener("click", async (event) => { | |
// Test for left click. | |
if (event.button !== 0) { | |
return; | |
} | |
let element = event.target; | |
// Go up through the DOM tree to search for a link |
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
function serialize(form) { | |
const inputs = form.querySelectorAll("input"); | |
const fields = {}; | |
for (const input of inputs) { | |
if (input.name && !input.disabled && input.type !== "file" && input.type !== "reset" && input.type !== "submit" && input.type !== "button") { | |
if ((input.type !== "checkbox" && input.type !== "radio") || input.checked) { | |
fields[input.name] = input.value; | |
} | |
} |
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
import Vue from "vue"; | |
// Create the event bus by creating a new Vue instance and | |
// binding it somehwere accessible. If you bind it to the | |
// Vue prototype, you can access it within your components | |
// like this: | |
// | |
// Emit an event | |
// this.$bus.$emit('myEvent', {data: true}) | |
// |
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
Show hidden characters
{ | |
"cmd": ["tsc", "-p", "jsconfig.json"], | |
"file_regex": "^(.+?)\\((\\d+),(\\d+)\\): (.+)$", | |
"working_dir": "${project_path:${folder}}", | |
"selector": "source.js" | |
} |
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
import time | |
from functools import wraps | |
# Use this function only if you need decorator parameters | |
def howmuchtime(limit=None): | |
def decorator(func): | |
@wraps(func) | |
def wrapper(*args, **kwargs): | |
start = time.time() |
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
/* --- Strategies --- */ | |
//=> network ? save : cache | |
async function networkFirst(cacheName, fetchEvent) { | |
const request = fetchEvent.request; | |
let fetchResponse; | |
return fetch(request) | |
.then(response => toCache(cacheName, request, fetchResponse = response)) | |
.then(response => response |
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
C:\msys64\msys2_shell.cmd -defterm -mingw64 -no-start -here -full-path |