View strip.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
export const strip = (html: string) => { | |
const doc = new DOMParser().parseFromString(html, 'text/html') | |
return (doc.body.textContent || '').trim() | |
} |
View Editor.vue
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
<template> | |
<div ref="editor" class="notranslate"> | |
<div v-show="showSuggestions" ref="suggestions"> | |
<template v-if="(filteredSuggestions || []).length"> | |
<div | |
v-for="(item, index) in filteredSuggestions.slice(0, 10)" | |
:key="index" | |
:class="[$style.suggestion, navigatedSuggestionIndex === index && $style.selected]" | |
@click="selectSuggestion(item)" | |
> |
View debounce.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
export function debounce(func, timeout = 300){ | |
let timer; | |
return (...args) => { | |
clearTimeout(timer); | |
timer = setTimeout(() => { func.apply(this, args); }, timeout); | |
}; | |
} |
View stringToHtml.ts
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 function stringToHtml(html: string): ChildNode { | |
var template = document.createElement('template') | |
html = html.trim() // Never return a text node of whitespace as the result | |
template.innerHTML = html | |
return template.content.firstChild | |
} | |
// usage: | |
const div = stringToHtml('<div><span>nested</span> <span>stuff</span></div>') |
View style.css
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
.toaster { | |
display: block; | |
position: fixed; | |
left: 50%; | |
transform: translateX(-50%); | |
bottom: 16px; | |
width: 100%; | |
height: 0; | |
z-index: 11; | |
} |
View vueQuerySync.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 Vue from "vue"; | |
function setupWatchers(data = []) { | |
if (!(this instanceof Vue)) throw new Error("Persistence plugin needs to be called from a Vue component"); | |
if (!data) return; | |
const query = new URLSearchParams(location.search); | |
data.forEach((name) => { | |
const key = `${this.$options.name}_${name}`; | |
if (query.has(key)) this[name] = JSON.parse(query.get(key)); |
View sheets_slack_notification.gs
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 buildReport() { | |
const ss = SpreadsheetApp.getActive(); | |
const data = ss.getSheetByName('SUMMARY').getRange("A1").getValues(); | |
const payload = buildAlert(data); | |
Logger.log(data); | |
sendAlert(payload); | |
} | |
function buildAlert(data) { | |
const mrr = data[0][0]; |
View ordinal.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
export const ordinal = (num) => { | |
const suffix = ['th', 'st', 'nd', 'rd'] | |
const value = val % 100 | |
return val + (suffix[(value - 20) % 10] || suffix[value] || suffix[0]) | |
} |
View HandleChunkLoadFailurePlugin.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
const prettier = require("prettier"); | |
const pluginName = "HandleChunkLoadFailurePlugin"; | |
/** | |
* This Webpack plugin calls `window._chunkHandler.handleVersionChange()` when loading a chunk fails | |
*/ | |
class HandleChunkLoadFailurePlugin { | |
constructor(options = {}) { | |
this.options = Object.assign({}, options); |
View apache_utils.sh
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
# Command to check access count per unique IP | |
tail -n 10000 /var/log/apache2/access.log | awk '{print $1}'| sort| uniq -c| sort -nr| head -n 10 | |
# Command to check access per unique pathname | |
awk {'print $7'} /var/log/apache2/access.log | sort -nk1 | uniq -c | less |
NewerOlder