Skip to content

Instantly share code, notes, and snippets.

View neopunisher's full-sized avatar
🎯
Focusing

Carter Cole neopunisher

🎯
Focusing
View GitHub Profile
const buf = new ArrayBuffer(maxBufferLen);
const dv = new DataView(buf);
class MagicWindow {
constructor(name, getter, setter) {
Object.defineProperty (window, name, {
get: getter,
set: setter
});
}
[...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')}})
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",
// 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)
// 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 "))
@neopunisher
neopunisher / browser-webserver.js
Last active December 17, 2022 16:31
An attempt at serving a simple website using tailscale's beta funnel feature from a browser tab
// 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),
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',
};
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) {
@neopunisher
neopunisher / ans_stellar_quest_nft.js
Last active May 22, 2021 01:41
Stellar quest nft solution
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
);
{
__type(name: "Node") {
name
kind
fields {
name
type {
kind
ofType {
name