View circDepReplacer.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
function circDepReplacer(k,v){return k&&v==this?null:v} | |
// used like JSON.stringify(obj,circDepReplacer) | |
// only replaces references to main object, not sub-objects |
View bluetooth.10s.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
#!/bin/bash | |
function pair(){ | |
osascript <<'END' | |
use framework "IOBluetooth" | |
use scripting additions | |
set blueToothDevice to "Buds Pro" | |
on getFirstMatchingDevice(deviceName) |
View getBytes.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 getBytes = (bytes,{unit=null,binary=false,toFixed=1} = {}) => { | |
const divisor = binary?1024:1000; | |
let value = bytes; | |
let sizeLevel=-1; | |
const sizeArray=['KB','MB','GB','TB','PB']; | |
if(unit){ | |
sizeLevel=sizeArray.indexOf(unit); | |
value=(bytes/Math.pow(divisor,sizeLevel+1)).toFixed(toFixed) | |
} | |
else while(value>=divisor){ |
View kofi-widget.jsx
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 {useEffect} from 'preact/hooks'; | |
export default function Kofi({name='davidsharp',text='Tip Me',backgroundColor='#fcbf47',textColor='#323842'}){ | |
const widgetScript = (`console.log('Donate @ ko-fi.com/${name}') | |
kofiWidgetOverlay.draw('${name}', { | |
'type': 'floating-chat', | |
'floating-chat.donateButton.text': '${text}', | |
'floating-chat.donateButton.background-color': '${backgroundColor}', | |
'floating-chat.donateButton.text-color': '${textColor}' | |
});`) |
View nvm-symlink.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
# symlinking the node binary with whatever nvm has set it as | |
rm /usr/local/bin/node | |
ln -s $(which node) /usr/local/bin/node |
View autolink.jsx
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 AutoLink({ text }) { | |
const delimiter = /((?:https?:\/\/)?(?:(?:[a-z0-9]?(?:[a-z0-9\-]{1,61}[a-z0-9])?\.[^\.|\s])+[a-z\.]*[a-z]+|(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})(?::\d{1,5})*[a-z0-9.,_\/~#&=;%+?\-\\(\\)]*)/gi; | |
return ( | |
<React.Fragment> | |
{text.split(delimiter).map((word,i) => { | |
const isUrl = i%2; | |
return isUrl ? (<a href={word.startsWith("http") ? word : `http://${word}`}>{word}</a>) : word; | |
})} | |
</React.Fragment> |
View force-xhr-status-with-proxy.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
XMLHttpRequest = new Proxy(XMLHttpRequest, { | |
construct:function(t,a){ | |
const req = new t(); | |
return new Proxy(req, { | |
get:function(o,p){ | |
if(p=='status')return 9001 | |
return typeof o[p] == 'function'?o[p].bind(o):o[p] | |
}, | |
set: function(target, prop, value) { | |
Reflect.set(target, prop, value) // or target[prop] = value |
View rot13.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 rot13 = str => str.replace(/[a-z]/gi,x=>{ | |
const c=x.charCodeAt(0) | |
const a=c>=97?97:65 | |
return String.fromCharCode( | |
a+((c-a+13)%26) | |
) | |
}) |
View triangular-number.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 fn = x => x + (x * ((x-1)/2)) |
View remark-star-wipe.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
@-webkit-keyframes wipe { | |
0% { | |
-webkit-mask-size: 0% 0%; | |
} | |
100% { | |
-webkit-mask-size: 550% 550%; | |
} | |
} | |
.remark-visible .remark-slide-content { |
NewerOlder