Skip to content

Instantly share code, notes, and snippets.

@methyl
methyl / iframe-capture-clicks-pass-other.js
Created March 14, 2022 19:33
Capture clicks in iframe but pass on :focus and :hover to the underlying element
const Demo = () => {
const handleTriggerRef = (el) => {
if (el == null) {
return
}
rect == null && setRect(el.getBoundingClientRect())
el.setAttribute('inert', '')
const anyDescendantMatches = (selectorText) =>
Array.from(el.querySelectorAll('*')).some((descendant: HTMLElement) =>
descendant.matches(selectorText),
<body>
<script>
document.write(Array.from(new Intl.Segmenter("en", {granularity: "word"}).segment("asd'asd'as'd zxczxc zxc zx z")).map(a => a.segment))
</script></body>
@methyl
methyl / live_data.ex
Created October 11, 2020 21:14
Alternative implementation of LiveData basing on ideas borrowed from Phoenix.Channel and LiveView
defmodule LiveData.Server do
use GenServer
def init({_endpoint, {pid, _}}) do
{:ok, Process.monitor(pid)}
end
def handle_info({Phoenix.Channel, auth_payload, {pid, _} = from, socket}, ref) do
Process.demonitor(ref)
fastlane = {:fastlane, socket.transport_pid, socket.serializer}
@methyl
methyl / observable_genserver.ex
Created October 9, 2020 18:19
Observable GenServer
defmodule ObservableGenServer do
defmacro __using__(opts) do
quote do
defmodule Server do
use GenServer
def start_link(n) do
GenServer.start_link(__MODULE__, n)
end
This file has been truncated, but you can view the full file.
function _loadWasmModule (sync, src, imports) {
var buf = null
var isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null
if (isNode) {
buf = Buffer.from(src, 'base64')
} else {
var raw = globalThis.atob(src)
var rawLength = raw.length
buf = new Uint8Array(new ArrayBuffer(rawLength))
for(var i = 0; i < rawLength; i++) {
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Surfer Guidelines Minimal Implementation</title>
<style>
.surfer-guidelines { height: 100%; border: 0; position: fixed; right: 0; top: 0; bottom: 0; width: 400px }
.surfer-guidelines.surfer-guidelines-wide { width: 80vw }
textarea { width: 100%; height: 100% }
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Keyword Comparison Tool</title>
<link rel="stylesheet" href="style.css" />
<script src="https://cdn.jsdelivr.net/npm/papaparse@5.1.1/papaparse.min.js"></script>
</head>
@methyl
methyl / a.txt
Last active February 25, 2020 13:08
a
<body>
<div style="background-image: url('https://upload.wikimedia.org/wikipedia/commons/7/71/Nothing_whitespace_blank.png'); background-color: #000; color: #fff;">
Cloaked text
</div>
</body>