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 / 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() {
@neopunisher
neopunisher / speechCommands.js
Created May 26, 2018 22:47
control stuff with your voice in the browser
(function(url, inj) {
inj(url).then(function() {
if (annyang) {
// Let's define a command.
var commands = {
'hello': function() { alert('Hello world!'); }
};
// Add our commands to annyang
@neopunisher
neopunisher / screenshotHtml.js
Created May 26, 2018 20:02
take a pic of the current html with svg magic
(function(url, inj) {
inj(url).then(function() {
html2canvas(document.body).then(function(canvas) {
document.body.appendChild(canvas);
});
})
})('https://html2canvas.hertzen.com/dist/html2canvas.min.js', (src, head = true) => new Promise(function(c, d) {
@neopunisher
neopunisher / youtube-screencap.js
Created May 25, 2018 05:30
take high quality screen stills from youtube with a button
(function(a){var b=a.createElement("button");b.innerText="Screencap";b.onclick=function(){var d=a.querySelector("video"),e=a.createElement("canvas"),b=e.getContext("2d"),c=a.createElement("a");e.width=d.videoWidth;e.height=d.videoHeight;b.drawImage(d,0,0);c.download=[ytcsi.data_.info.docid,d.currentTime,".png"].join("-");c.href=e.toDataURL();a.body.appendChild(c);c.click();a.body.removeChild(c)};a.querySelector("h1.title").appendChild(b)})(document);
@neopunisher
neopunisher / voicejammer.js
Created May 24, 2018 04:00
put on headphones and try and talk
var AudioContext = window.AudioContext || window.webkitAudioContext;
var audioContext = new AudioContext();
var synthDelay = audioContext.createDelay(0.2);
synthDelay.connect(audioContext.destination)
// request audio stream from the user's webcam
navigator.mediaDevices.getUserMedia({
audio: true
})
.then(function (stream) {
@neopunisher
neopunisher / injectSientinal.js
Created May 23, 2018 18:02
does stuff when things are added to the page... via https://github.com/muicss/sentineljs
(function(style, func){
document.addEventListener('sentinel-load', function(){
sentinel.on(style, func);
})
var a=document.createElement("script");a.src='//cdn.rawgit.com/muicss/sentineljs/0.0.4/dist/sentinel.min.js';a.type="text/javascript";
document.head.appendChild(a);
})('.my-div', function(el) {
el.innerHTML = 'The sentinel is always watching.';
})