Skip to content

Instantly share code, notes, and snippets.

View makotom's full-sized avatar
👋
Huomiseen. Bye.

Makoto Mizukami makotom

👋
Huomiseen. Bye.
View GitHub Profile
@makotom
makotom / change-autoincr.html
Created November 9, 2019 11:25
`change` events on manipulated text input
<!doctype html>
<html lang="en">
<meta charset="UTF-8">
<title>Change events on text box</title>
<script>
window.addEventListener('DOMContentLoaded', () => {
const input = document.querySelector('input#autoincr-textbox');
const output = document.querySelector('div#autoincr-output');
@makotom
makotom / change-dnd.html
Created November 9, 2019 11:20
`change` events on drag-and-drop
<!doctype html>
<html lang="en">
<meta charset="UTF-8">
<title>Change events on text box</title>
<script>
window.addEventListener('DOMContentLoaded', () => {
const input = document.querySelector('input#dnd-textbox');
const output = document.querySelector('div#dnd-output');
@makotom
makotom / test2.js
Last active April 20, 2019 16:53
This is how to use jsdom repetitively without leaking memory
const jsdom = require('jsdom');
const domBuilder = (iter) => {
new jsdom.JSDOM(`${iter}`);
if (iter % 1000 === 0) {
console.log(iter); // eslint-disable-line no-console
}
setImmediate(domBuilder.bind(null, iter + 1));
@makotom
makotom / test.js
Last active April 20, 2019 16:06
Memory leak in JSDOM...???
const jsdom = require('jsdom');
for (let iter = 0; ; iter += 1) {
new jsdom.JSDOM(`${iter}`);
if (iter % 1000 === 0) {
console.log(iter); // eslint-disable-line no-console
}
}
@makotom
makotom / parse.js
Last active April 19, 2019 17:24
Generate TSV file from JMDict XML data
const fs = require('fs');
function getEntryStrings() {
const ret = [];
const text = fs.readFileSync('JMdict_e').toString();
const openPos = [];
const endPos = [];
{
@makotom
makotom / test.html
Created February 12, 2019 09:00
Bug in rasterizer? Try it with Chrome running on Windows with high-DPI (screen scaling).
<!doctype html>
<html lang="en">
<meta charset="UTF-8">
<title>ANGLE?</title>
<style>
body>div {
margin-bottom: 20em;
}
@makotom
makotom / master.html
Last active February 8, 2019 08:06
Let's play with window.postMessage()
<!doctype html>
<html lang="en">
<meta charset="UTF-8">
<title>Master</title>
<script>
window.addEventListener('DOMContentLoaded', function () {
document.querySelector('#triggerBtn').addEventListener('click', function () {
const slaveWindow = window.open('slave.html');
@makotom
makotom / test.c
Created January 29, 2019 12:32
Let's learn about open(2) (called by fopen(3))
#include <stdio.h>
#include <unistd.h>
#define TEST_TXT "test.txt"
void phase1(void) {
FILE * fp = fopen(TEST_TXT, "w");
fprintf(fp, "hoge\n");
fclose(fp);
@makotom
makotom / 20190108-test.html
Created January 8, 2019 13:42
Navigation within a box is not reproduced by back/next functionality in UA
<!doctype html>
<html lang="en">
<meta charset="UTF-8">
<title>Intra-page jump</title>
<style>
body {
position: absolute;
height: 1000vh;
}
@makotom
makotom / pre-repro.html
Created November 22, 2018 06:17
Dropbox Paper breaks CJK inputs (possibly) due to this well-known nature.
<!doctype html>
<html lang="en">
<meta charset="UTF-8">
<title>Pre-Repro</title>
<script>
document.addEventListener('DOMContentLoaded', () => {
const userInput = document.querySelector('div#textInput');
const logView = document.querySelector('textArea#logView');