Skip to content

Instantly share code, notes, and snippets.

View jameswomack's full-sized avatar
📈

James J. Womack jameswomack

📈
View GitHub Profile
@jameswomack
jameswomack / knutshell.sh
Created February 26, 2021 00:58
Function composition in a Knut shell
> foo = (...s) => `foo${s.join()}`
[Function: foo]
> bar = (...s) => `${s.join()}bar`
[Function: bar]
> qux = s => Math.ceil(Number(s))
[Function: qux]
> compose(foo, bar, qux)(1.27890)
'foo2bar'
> fooBarQux = compose(foo, bar, qux)
undefined
@jameswomack
jameswomack / diff.diff
Created January 14, 2020 18:25
Looked into unused dependencies & wanted to see if this looks right
diff --git a/package.json b/package.json
index 40439456..96cd7f13 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,6 @@
]
},
"resolutions": {
- "mux.js": "^5.5.1",
"@material-ui/icons": "^4.5.1",
@jameswomack
jameswomack / application_ld-json.html
Created December 15, 2017 13:23
Example implementation of the Schema.org spec for Google/Bing to display a search bar to users to search our site from within Google
<!-- Schema.org spec for Google/Bing to display a search bar to users to search our site from within Google -->
<!-- See: https://developers.google.com/webmasters/structured-data/slsb-overview -->
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "http://www.showtimeanytime.com",
"potentialAction": {
"@type": "SearchAction",
"target": "http://www.showtimeanytime.com/#search/{search_term_string}",
@jameswomack
jameswomack / o.js
Created December 14, 2017 00:54
Observing Undefined Custom Elements / Web Components
o = new MutationObserver(mutationRecords => {
const shouldCheck = mutationRecords.some(mutationRecord => mutationRecord.type === 'childList' && mutationRecord.addedNodes.length)
const addedNodes = mutationRecords.reduce((aN, mutationRecord) => aN.concat(...mutationRecord.addedNodes), [])
const undefinedNodes = document.querySelectorAll(':not(:defined)')
if (shouldCheck) {
console.info(undefinedNodes, addedNodes);
@jameswomack
jameswomack / grouping.js
Created December 8, 2017 02:46
Grouping content elements w/ their required parents
Reflect.defineProperty(DOMimatrix, 'groupingElements', {
value: { div:'div', figure:'figure', main:'main', ul:'ul', dd: [ 'dl' ], dt: [ 'dl' ], br:'br', hr:'hr', figcaption: [ 'figure' ], ol:'ol', li: ['menu','ul','ol'], pre:'pre', dl:'dl' }
})
@jameswomack
jameswomack / non-objects-on-window.js
Last active December 6, 2017 06:06
Get all non-object-inherited-from values on window
window.__previousTypeOfBucketTable__ = window.__typeOfBucketTable__ ? window.__typeOfBucketTable__ : { }; Reflect.ownKeys(window).filter(aWindowOwnedKey => {
return !({}).constructor[Symbol.hasInstance](window[aWindowOwnedKey])
}).reduce((typeOfBucketTable, aWindowOwnedKeyForNonObjects) => {
const typeOfThisWIndowOwnedKey = typeof window[aWindowOwnedKeyForNonObjects]
typeOfBucketTable[typeOfThisWIndowOwnedKey] || (typeOfBucketTable[typeOfThisWIndowOwnedKey] = { length: 0 })
typeOfThisWIndowOwnedKey === 'object' && typeOfBucketTable[typeOfThisWIndowOwnedKey].length === 0 && (typeOfBucketTable[typeOfThisWIndowOwnedKey].__everyObjectIsNull__ = true)
typeOfBucketTable[typeOfThisWIndowOwnedKey][aWindowOwnedKeyForNonObjects] = window[aWindowOwnedKeyForNonObjects]
typeOfBucketTable[typeOfThisWIndowOwnedKey].length = typeOfBucketTable[typeOfThisWIndowOwnedKey].length + 1
typeOfThisWIndowOwnedKey === 'object' && window[aWindowOwnedKeyForNonObjects] != null && (typeOfBucketTable[typeOfThisWIndowOwnedKey].
@jameswomack
jameswomack / plain-jane.sh
Created December 5, 2017 03:58
Post plain text w/ cURL
curl -s -H "Content-Type: text/plain" --data "Message w/ cURL" -X POST http://localhost:7101/slack
@jameswomack
jameswomack / accept-pipe_cli-execute-mode.js
Created December 3, 2017 22:54
Accept Unix pipes w/ Node.js & pure CLI coding
echo 'foo' | node -e "let data='';process.stdin.isTTY?console.info(process.argv):process.stdin.on('readable',()=>{data+=process.stdin.read()||''}).on('end',()=>console.info(data.trim()))"
@jameswomack
jameswomack / async-await_ternary_navigator-share.js
Created December 3, 2017 09:51
Async Squared: You know that we are developing in a ternary world & I am a ternary girl
const Shareability = { ofURI() { return Promise.resolve(location.href) }}
const canShare = ({ canonical = false } = { }) => {
if (!navigator.share)
return Promise.resolve(false)
return Shareability.ofURI(canonical?document.querySelector('link[rel="canonical"]'):location.href)
}
const beSelfish = () =>
Promise.reject(new Error('Sharing unavailable'))
const shareAttempt = async ({ title, text }, url) =>
await (url = await canShare({ canonical: true }) ?