Skip to content

Instantly share code, notes, and snippets.

@kerrishotts
kerrishotts / 20190711.js
Created July 12, 2019 07:00
2019-07-11 Dev.to Challenge
function dblLinear(n) {
const series = [1];
const calc = x => ({
y: 2 * x + 1,
z: 3 * x + 1
});
const ascendingOrder = (a, b) => a - b;
@kerrishotts
kerrishotts / 20190711.js
Created July 12, 2019 07:00
2019-07-11 Dev.to Challenge
function dblLinear(n) {
const series = [1];
const calc = x => ({
y: 2 * x + 1,
z: 3 * x + 1
});
const ascendingOrder = (a, b) => a - b;
@kerrishotts
kerrishotts / 20190710.js
Last active July 11, 2019 02:43
Dev.to daily challenge (2019-07-10)
const assert = expr => {
if (!expr) { throw new Error(`assertion failed`); }
};
const permute = arr => {
if (arr.length < 2) {
return (typeof arr === "string" ? [arr] : arr);
}
if (typeof arr === "string") {
@kerrishotts
kerrishotts / 20190630.js
Created July 1, 2019 20:13
June 30, 2019 Dev Challence
const assert = (expr) => { if (!expr) throw new Error("Assert Failed"); }
const charCounter = ({strToCount = "", chars = ""} = {}) => {
const charsToCount = chars.toLowerCase();
return Array.from(strToCount.toLowerCase())
.reduce((acc, candidate) => acc += charsToCount.includes(candidate)
? 1 : 0, 0)
}
const countVowels= strToCount => charCounter({strToCount, chars: "aeiou"});
const sanitize = str => str.replace(/[^0-9A-Za-z\.\s]/g, "");
const notBlank = str => str !== "";
const extract = str => {
const [ line, category, expense ] = str.split(/\s+/);
return { line: Number(line), category, expense: Number(expense) };
};
@kerrishotts
kerrishotts / twitter-sidebar-dimmer.js
Created June 25, 2019 21:16
Twitter Sidebasr Dimmer
document.head.appendChild(
(
() => {
const style = document.createElement("style");
style.innerText = `
nav a span, nav div span {
color: rgba(255,255,255,0.66) !important;
transition: color 0.3s ease-in-out;
font-size: 90% !important;
font-weight: normal !important;
<label class="row">
<input type="checkbox" id="save"/>
<span>Save as default</span>
</label
@kerrishotts
kerrishotts / XD-IO-P2.md
Last active February 4, 2019 00:47
XD Plugin Lab: Part Four, Step 2: File I/O

XD Plugin Lab: Part Four, Step 2: File I/O

Note: This is part of a longer series.

This demonstrates how File I/O works in XD. File I/O is all asynchronous, and so you'll need to use promises or async/await.

Sections to note in main.js:

  • Line 7: Access to the file system is via UXP's storage module.
  • Line 11: We're going to store settings globally.
@kerrishotts
kerrishotts / XD-IO-P1.md
Last active February 4, 2019 00:47
# XD Plugin Lab: Part Four, Step 1: File I/O

XD Plugin Lab: Part Four, Step 1: File I/O

Note: This is part of a longer series.

This serves as a checkpoint for File I/O.

@kerrishotts
kerrishotts / XD-UI-P4.md
Last active February 4, 2019 00:46
XD Plugin Lab: Part Three, Step 4: Validation (Optional)

XD Plugin Lab: Part Three, Step 4: Validation (Optional)

Note: This is part of a longer series.

This section covers how we can add some validation to our dialog. It's optional for the plugin lab.

NOTE: There are many ways to add validation; this section only presents a couple. Feel free to explore what works best for your plugin.

We're going to have two validation methods: