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 buf = new ArrayBuffer(maxBufferLen); | |
const dv = new DataView(buf); | |
class MagicWindow { | |
constructor(name, getter, setter) { | |
Object.defineProperty (window, name, { | |
get: getter, | |
set: setter | |
}); | |
} |
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
[...Array(256).keys()].map((idx)=>{idx=Number(idx);return{char:String.fromCharCode(idx), hex: idx.toString(16), dec: idx, bin: (idx >>> 0).toString(2).padStart(8,'0')}}) |
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
async (clipboardContentString) => { | |
try { | |
const response = await fetch("https://api.openai.com/v1/completions", { | |
method: "POST", | |
headers: { | |
"Content-Type": "application/json", | |
"Authorization": "Bearer YOUR API KEY HERE" | |
}, | |
body: JSON.stringify({ | |
model: "text-davinci-003", |
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
// String stuff | |
const encodeStr = (str)=>new TextEncoder().encode(str) | |
const strLen = (str)=> encodeStr(str).length | |
const stoa = (str)=>Uint8Array.from(str, x => x.charCodeAt(0)) | |
const atos = (arr)=>String.fromCharCode.apply(null, arr) | |
// Base 2 stuff | |
const getBaseLog = (x, y) => (Math.log(y) / Math.log(x)) | |
const baseTwoLog = (y) => getBaseLog(2,y) | |
const powTwo = (x)=>Math.pow(2,x) |
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
// extracts data from https://imgflip.com/popular-meme-ids | |
console.log("./imgflip-single.sh " + Array.from(document.querySelectorAll('table.admin-table tr td:nth-child(2n)')).map((a)=>a.innerText.replace(/[\W]+/g," ").split(' ').join('-')).join("\n./imgflip-single.sh ")) |
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
// Im doing this "standalone" from the js console in an about:blank page | |
const tsconn = await import('https://cdn.jsdelivr.net/npm/@tailscale/[email protected]/pkg.js') | |
const wasmURL = 'https://cdn.jsdelivr.net/npm/@tailscale/[email protected]/main.wasm' | |
const ipn = await tsconn.createIPN({wasmURL}) | |
ipn.run({ | |
notifyState: (state)=>console.log('notifyState:', state), | |
notifyNetMap: (netMap)=>console.log('notifyNetMap:', netMap), | |
notifyBrowseToURL: (url)=>console.log('notifyBrowseToURL:', url), | |
notifyPanicRecover: (err)=>console.log('notifyPanicRecover:', url), |
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
document.addEventListener('yourCustomEvent', function (e) { | |
var data = e.detail; | |
console.log('received', data); | |
}); | |
var data = { | |
allowedTypes: 'those supported by structured cloning, see the list below', | |
inShort: 'no DOM elements or classes/functions', | |
}; |
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
var EventSource = require("eventsource"); | |
var es = new EventSource( | |
"https://horizon-testnet.stellar.org/accounts/GB7JFK56QXQ4DVJRNPDBXABNG3IVKIXWWJJRJICHRU22Z5R5PI65GAK3/payments", | |
); | |
es.onmessage = function (message) { | |
var result = message.data ? JSON.parse(message.data) : message; | |
console.log("New payment:"); | |
console.log(result); | |
}; | |
es.onerror = function (error) { |
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
var data = require('./data.json'); #transaction with operations downloaded saved as json | |
var ops = data._embedded.records.map((r)=>[r.name, new Buffer.from(r.value, 'base64')]) | |
var StellarSdk = require("stellar-sdk"); | |
var server = new StellarSdk.Server("https://horizon-testnet.stellar.org"); | |
var key = StellarSdk.Keypair.fromSecret( | |
#secret key here | |
); | |
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
{ | |
__type(name: "Node") { | |
name | |
kind | |
fields { | |
name | |
type { | |
kind | |
ofType { | |
name |