This file contains hidden or 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 spaceCase = txtWithNoSpaces => | |
| txtWithNoSpaces | |
| .split(/_|-/g) // snake_case & kebab-case | |
| .join(' ') | |
| .replace(/([A-Z])/g, ' $1') // PascalCase & camelCase | |
| .split(' ') | |
| .map(word => word.charAt(0).toUpperCase() + word.slice(1)) | |
| .join(' ') | |
| .replace(/\s+/, ' ') // dashed entries create two spaces, bump that down to one | |
| .replace(/([A-Z])\s(?=[A-Z]\b)/g, '$1') // e.g. "U U I D" => "UUID" |
This file contains hidden or 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
| .hue-gradient | |
| { | |
| background:linear-gradient(to right, | |
| #f00 0%, | |
| #ff0 16.66%, | |
| #0f0 33.33%, | |
| #0ff 50%, | |
| #00f 66.66%, | |
| #f0f 83.33%, | |
| #f00 100% |
This file contains hidden or 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
| <!Doctype html> | |
| <style> | |
| div | |
| { | |
| background:linear-gradient(to right, | |
| #f00 0%, | |
| #ff0 16.66%, | |
| #0f0 33.33%, | |
| #0ff 50%, | |
| #00f 66.66%, |
This file contains hidden or 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
| await new Promise(done=>setTimeout(done,seconds*1000)) | |
| //note: replace "seconds" with a number to use this | |
| //hint: this will only work inside an async function |
This file contains hidden or 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
| .parent | |
| { | |
| align-items:center; | |
| display:flex; | |
| justify-content:center; | |
| } |
This file contains hidden or 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 callback2promise(func,...args) | |
| { | |
| return new Promise(function(res,rej) | |
| { | |
| func(...args,(err,data)=>err?rej(err):res(data)) | |
| }) | |
| } |
This file contains hidden or 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 curry=(fn,...xs)=>xs.length>=fn.length?fn(...xs):(...ys)=>curry(fn,...xs,...ys) |
This file contains hidden or 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 asyncMap=(arr,cb)=>arr.reduce(async (arr,...args)=>[...(await arr),await cb(...args)],[]) | |
| const wait=async ms=> | |
| new Promise(res=> | |
| setTimeout(()=> | |
| { | |
| const newVal=ms+"ms"; | |
| console.log(newVal); | |
| res(newVal); | |
| }, ms) | |
| ) |
NewerOlder