Skip to content

Instantly share code, notes, and snippets.

function getAll(request) {
return request.then(function (response) {
if (!response._paging || !response._paging.next) {
return response;
}
// progress is next / total pages * 10
let _next = response._paging.next._options.endpoint.split("=")[1];
let _total = response._paging.totalPages;
let _progress = (_next / _total) * 10;
function saySomething(thingToSay){
const {isHelpful, isPositive, statement} = thingToSay
if(!isHelpful || !isPositive ) return `...🤐`
return `${statement} 👍`
}
const positiveStatement = {
statement: "You did a great job so far. I'm happy to help you finish.",
isHelpful: true,
isPositive: true
const products = [
{ name: 'apples', category: 'fruits', count: 1 },
{ name: 'oranges', category: 'fruits', count: 2 },
{ name: 'potatoes', category: 'vegetables', count: 1 },
{ name: 'kettle chips', category: 'snacks', count: 3 },
];
const groupByCategory = products.reduce((group, product) => {
const { category } = product;
group[category] = group[category] ?? [];
group[category].push(product);
@killa-kyle
killa-kyle / styles.css
Created October 17, 2021 01:01
base styles for decent layout
html {
max-width: 38rem;
padding: 2rem;
margin: auto;
line-height: 1.5rem;
font-size: 24px;
}
@killa-kyle
killa-kyle / string-utils.js
Created October 15, 2021 02:20 — forked from jonlabelle/string-utils.js
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str) {
return str.toLowerCase();
// Handle form submission
document.querySelector("form").addEventListener("submit", e => {
// Cancel default behavior of sending a synchronous POST request
e.preventDefault();
// Create a FormData object, passing the form as a parameter
const formData = new FormData(e.target);
// Send form data to the server with an asynchronous POST request
fetch("https://thejsway-server.herokuapp.com/animals", {
method: "POST",
body: formData
window.indefiniteArticle = function(phrase) {
// Getting the first word
var match = /\w+/.exec(phrase)
if (match) var word = match[0]
else return "an"
var l_word = word.toLowerCase()
// Specific start of words that should be preceeded by 'an'
var alt_cases = ["honest", "hour", "hono"]
#include <Joystick.h>
#include <Keypad.h>
//config variables
#define NUM_BTN_COLUMNS (4)
#define NUM_BTN_ROWS (4)
#define MAX_DEBOUNCE (3)
// Global variables
console.log(`%c
_ _ _ _ _ _
| | (_) | | (_) | | |
_____ ___ __ ___ _ __| |_ _ _ __ ___| |_ _| |_ _ _| |_ ___
/ _ \\ \\/ / '_ \\ / _ \\ '__| __| | | '_ \\/ __| __| | __| | | | __/ _ \\
| __/> <| |_) | __/ | | |_ | | | | \\__ \\ |_| | |_| |_| | || __/
\\___/_/\\_\\ .__/ \\___|_| \\__| |_|_| |_|___/\\__|_|\\__|\\__,_|\\__\\___|
| |
|_|
console.log(`%c
________________________.___._____________________________
\\_ ___ \\______ \\__ | |\\______ \\__ ___/\\_____ \\
/ \\ \\/| _// | | | ___/ | | / | \\
\\ \\___| | \\\\____ | | | | | / | \\
\\______ /____|_ // ______| |____| |____| \\_______ /
\\/ \\/ \\/ \\/`, `font-family: monospace`);