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
<body bgcolor=black> | |
<canvas id='canvas1' width='1024' height='720'> | |
</canvas> | |
<button onclick="progress=Math.max(0.0,progress-0.1)"><</button> | |
<button onclick="progress=Math.min(1.0,progress+0.1)">></button> | |
</body> | |
<script id="vs" type="x-shader/x-vertex"> | |
attribute vec3 aPosition; | |
varying vec3 vPosition; |
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
{ // must be inside our own scope here so that when we are unloaded everything disappears | |
// we also define functions using 'let fn = function() {..}' for the same reason. function decls are global | |
let drawTimeout; | |
// Actually draw the watch face | |
let draw = function() { | |
var x = g.getWidth() / 2; | |
var y = g.getHeight() / 2; | |
g.reset().clearRect(Bangle.appRect); // clear whole background (w/o widgets) | |
g.setColor(0.2,0.2,1); |
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 approximate_pi = n => { | |
let pi = 0 | |
let denom = 1 | |
for(let i = 0;i<n;i++){ | |
pi += (i%2?-4:4)/denom | |
denom += 2 | |
} | |
return pi | |
} |
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 circDepReplacer(k,v){return k&&v==this?null:v} | |
// used like JSON.stringify(obj,circDepReplacer) | |
// only replaces references to main object, not sub-objects |
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
#!/bin/bash | |
function pair(){ | |
osascript <<'END' | |
use framework "IOBluetooth" | |
use scripting additions | |
set blueToothDevice to "Buds Pro" | |
on getFirstMatchingDevice(deviceName) |
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 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){ |
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
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}' | |
});`) |
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
# symlinking the node binary with whatever nvm has set it as | |
rm /usr/local/bin/node | |
ln -s $(which node) /usr/local/bin/node |
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 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> |
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
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 |
NewerOlder