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 |
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
# below is my prompt-y bit of choice: `current-dir ~ ` | |
#export PS1="\[\e[33m\]\W \[\e[35m\]~ \[\e[m\]" | |
#export PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/~}\007"' | |
# or something a little fancier: `current-dir <random fruit>` | |
#FRUITS=(🍎 🍐 🍊 🍋 🍌 🍉 🍇 🍓 🍒 🍑 🍍 🥝) | |
#export PS1="\[\e[33m\]\W \[\e[35m\]${FRUITS[$(echo $RANDOM%12 | bc)]} \[\e[m\]" | |
# for a new fruit on each line, rather than one per session | |
# export PROMPT_COMMAND='echo -ne "${FRUITS[$(echo $RANDOM%12 | bc)]} "' | |
alias zed="open -a /Applications/zed.app" |
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) |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Hello World!</title> | |
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script> | |
</head> | |
<body> | |
<div id="hello-example"></div> |
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
<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 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 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 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 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 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}' | |
});`) |
NewerOlder