Skip to content

Instantly share code, notes, and snippets.

@mmis1000
mmis1000 / -License
Last active June 24, 2022 08:23
Patch to workaround @nuxt/framework#4475
MIT License
Copyright (c) [year] [fullname]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@mmis1000
mmis1000 / EdgeTabSeparater.userChrome.css
Last active June 8, 2021 00:30
Add the tab seperator of Edge browser 89 to Firefox directly
/**
* Copyright 2021 Mmis1000 (mmis10002@gmail.com)
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
/*
Selections:
@mmis1000
mmis1000 / GithubDarkThemePatch.user.css
Last active March 26, 2021 04:19
Sane github dark theme text color
/* ==UserStyle==
@name Sane github dark theme text color
@namespace mmis1000.me
@version 0.0.4
@license CC0
@updateURL https://gist.githubusercontent.com/mmis1000/95f29ba3c7ff513536eb81ae52e11fb5/raw/GithubDarkThemePatch.user.css
@preprocessor stylus
@var select theme "Theme" ["near_white:Near White", "pure_white:Pure white", "whiter:Whiter"]
==/UserStyle== */
@mmis1000
mmis1000 / StructualSharing.js
Last active August 27, 2020 02:20
Immutable Structual Sharing
/// <reference path="./weak-ref.ts" />
// The finalizationRegistry must be keep alive or nothing will ever works
globalThis.finalizationRefs = globalThis.finalizationRefs || [];
let Tuple, Record;
{
const valueSymbol = Symbol('value')
const LinkMap = new Map()
@mmis1000
mmis1000 / Overflow attack.html
Created December 14, 2019 04:54
Use stack overflow to expose RangeError prototype in other context
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
@mmis1000
mmis1000 / 8 queen problem.js
Created November 6, 2019 09:52
Bitwise magic 8 queen problem resolver
/**
* @param {number} n
* @return {number}
*/
var totalNQueens = function(n) {
var width = n
var total = 0
function run(x, ltu, ltr, ltd) {
if (x >= width) {
@mmis1000
mmis1000 / AbortablePromise.ts
Last active March 18, 2020 04:50
Abortable promise
import AbortController from "abort-controller"
import { AbortSignal } from "abort-controller"
import { AbortablePromise } from "."
var controller = new AbortController()
function sleep (signal: AbortSignal, time: number) {
return AbortablePromise(signal, function (resolve, reject, handleCancel) {
var id = setTimeout(resolve, time)
handleCancel(() => {
@mmis1000
mmis1000 / v8-detect.js
Created July 18, 2019 05:52
Detect v8 js engine using undefined behavior of v8
var isChrome = (() => {
with ({}) {
var a = new ArrayBuffer(16)
new Float64Array(a)[0] = NaN
new Uint8Array(a)[0] = 1
new Float64Array(a)[1] = new Float64Array(a)[0]
return new Uint8Array(a)[8] === 1
}
})
@mmis1000
mmis1000 / SimpleFormat.ts
Last active June 1, 2019 17:26
Regex is fun (
function unescape(str) {
return str.replace(/\\.|./g, (str)=>str.slice(str.length - 1))
}
function format(template: string, obj: {[key: string]: string}) {
return template.replace(/\\.|\{(?:\\.|[^\}])+\}|./g, function (str) {
if (/^\{.+\}$/.test(str)) {
return obj[
unescape(str.slice(1, str.length - 1))
@mmis1000
mmis1000 / WebComponentAutoWired.ts
Last active January 25, 2019 09:42
Typescript to web component experiment
const camelToKebab = (string: string) => {
return string.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
};
interface Callback {
(this: HTMLElement, newValue: string|null, oldValue: string|null): void
}
interface Transformer<T> {
fromAttribute(attr: string|null): T,