Skip to content

Instantly share code, notes, and snippets.

View neopunisher's full-sized avatar
🎯
Focusing

Carter Cole neopunisher

🎯
Focusing
View GitHub Profile

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))
@neopunisher
neopunisher / deepSearch.js
Last active June 8, 2018 14:57
recursive search the window like deep(window, 3500, 'window')
function deep(o, q, p = '.', d = 0, s = new Set()) {
try {
if (d > 5 || s.has(o)) {
console.log('depth met or seen', s.has(o), d)
} else if (Array.isArray(o)) {
s.add(o)
return [].concat(...o.map((a, b) => deep.apply(this, [a, q, p + ['[', ']'].join(b), d + 1, s])))
} else if (o instanceof Object) {
s.add(o)
@neopunisher
neopunisher / combinators.js
Created June 7, 2018 19:04 — forked from Avaq/combinators.js
Common combinators in JavaScript
const I = x => x;
const K = x => y => x;
const A = f => x => f(x);
const T = x => f => f(x);
const W = f => x => f(x)(x);
const C = f => y => x => f(x)(y);
const B = f => g => x => f(g(x));
const S = f => g => x => f(x)(g(x));
const P = f => g => x => y => f(g(x))(g(y));
const Y = f => (g => g(g))(g => f(x => g(g)(x)));
(function(url, inj) {
inj(url).then(function() {
const node = new Ipfs()
node.on('error', errorObject => console.error(errorObject))
node.on('ready', () => {
console.log('nodeready')
node.stop(() => {
console.log('node gone')
})
@neopunisher
neopunisher / generateWorker.js
Created May 29, 2018 16:05
generates a web worker from a function
(function(){
function aWorker(){
onmessage = function(e) {
console.log('Message received from main script');
var workerResult = 'Result: ' + (e.data[0] * e.data[1]);
console.log('Posting message back to main script');
postMessage(workerResult);
}
var i = 0;
@neopunisher
neopunisher / injectUltrasonics.js
Created May 29, 2018 05:03
ultrasonicsoundcontrol
(function(url, inj) {
inj(url).then(function() {
var ALPHABET = '0123456789';
var MESSAGE = '314159';
var button = document.createElement('button');
document.body.appendChild(button)
button.addEventListener('click', onButton);
function onButton() {