Skip to content

Instantly share code, notes, and snippets.

View neopunisher's full-sized avatar
🎯
Focusing

Carter Cole neopunisher

🎯
Focusing
View GitHub Profile
@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/connect@1.33.0-t2be951a58/pkg.js')
const wasmURL = 'https://cdn.jsdelivr.net/npm/@tailscale/connect@1.33.0-t2be951a58/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

Keybase proof

I hereby claim:

  • I am neopunisher on github.
  • I am cartercole (https://keybase.io/cartercole) on keybase.
  • I have a public key ASCPIeW-of9tc6dFejusNKs7pFm2B-vR_G-fmCmSZVMPfQo

To claim this, I am signing this object:

93126901297815151078288992669518296329218393850654840958127279229911535598978898481635657822531972453651883340618864736759734542679037288413645544246236468657813005590075680252114746033092465493223366471048615346938198314256353419369541307392862912693187785033844054069740144373254706726814612710750178624771990754917602298093521436484064007164284387402867130625133132836281563051896500940516375440328178636152123679634003876766266442445314985666400256314065685651584153149055968640618546932146414
https://tuppers-formula.tk/
function toggleFullScreen() {
if ((document.fullScreenElement && document.fullScreenElement !== null) ||
(!document.mozFullScreen && !document.webkitIsFullScreen)) {
if (document.documentElement.requestFullScreen) {
document.documentElement.requestFullScreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullScreen) {
document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
}
@neopunisher
neopunisher / webTorrent.js
Last active August 29, 2018 18:48
Inject default webtorrent
(function(url, inj) { // https://webtorrent.io/docs
inj(url).then(function() {
var client = new WebTorrent()
client.on('torrent', function (torrent) {
console.log('clientorrent:', torrent)
})
var findIP = new Promise(r=>{var w=window,a=new (w.RTCPeerConnection||w.mozRTCPeerConnection||w.webkitRTCPeerConnection)({iceServers:[]}),b=()=>{};a.createDataChannel("");a.createOffer(c=>a.setLocalDescription(c,b,b),b);a.onicecandidate=c=>{try{c.candidate.candidate.match(/([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g).forEach(r)}catch(e){}}})
/*Usage example*/
findIP.then(ip => document.write('your ip: ', ip)).catch(e => console.error(e))