Skip to content

Instantly share code, notes, and snippets.

@nexpr
nexpr / add.js
Last active December 18, 2023 13:45
Deno で Gist のテストを動かす
const add = (a, b) => a + b
export default add
@nexpr
nexpr / dnf.log
Created December 10, 2023 17:36
dnf vs dnf5 / install git in docker container (fedora38)
[root@af929bf74005 /]# time dnf install git -y
Fedora 38 - x86_64 9.5 MB/s | 83 MB 00:08
Fedora 38 openh264 (From Cisco) - x86_64 1.1 kB/s | 2.5 kB 00:02
Fedora Modular 38 - x86_64 3.2 MB/s | 2.8 MB 00:00
Fedora 38 - x86_64 - Updates 3.8 MB/s | 36 MB 00:09
Fedora Modular 38 - x86_64 - Updates 1.5 MB/s | 2.1 MB 00:01
Dependencies resolved.
========================================================================================================================
Package Architecture Version Repository Size
========================================================================================================================
@nexpr
nexpr / sort-domain.js
Created November 26, 2023 12:44
sort domain
export const sortDomain = (domains) => {
return domains.map(x => x.split(".")).sort((a, b) => {
const max = Math.max(a.length, b.length)
const recur = (i = 0) => {
if (i >= max) return 0
return (a.at(-i - 1) ?? "").localeCompare(b.at(-i - 1) ?? "") || recur(i + 1)
}
return recur()
}).map(x => x.join("."))
}
<!DOCTYPE html>
<meta charset="utf-8" />
<script type="module">
import { html, render } from "https://cdn.jsdelivr.net/npm/uhtml@4.1.20/node.js"
const page = async () => {
const valueFormat = (value) => {
try {
@nexpr
nexpr / time-input.js
Created November 19, 2023 12:13
lit example: time input
import { LitElement, css, html } from "lit"
import { live } from "lit/directives/live.js"
export class TimeInput extends LitElement {
static styles = css`
.container {
display: flex;
gap: 10px;
}
input {
@nexpr
nexpr / vue3-htm.html
Created October 30, 2023 13:53
Vue3 + htm example
<!doctype html>
<meta charset="utf-8" />
<script type="module">
import { createApp, ref, h } from "https://unpkg.com/vue@3.3.7/dist/vue.esm-browser.js"
import htm from "https://cdn.jsdelivr.net/npm/htm@3.1.1/mini/index.module.js"
const html = htm.bind(
(type, props, ...children) =>
h(type, props, typeof type === "string" ? children : () => children)
)
@nexpr
nexpr / document-only-style.css
Last active October 29, 2023 07:05
ShadowDOM を使う CustomElement にグローバルスタイルを適用する
foo-bar {
display: block;
margin: 10px;
}
/* not applied */
.box {
color: red;
}
import { html } from "lit"
import { StylitElement } from "./StylitElement.js"
class ExampleElement extends StylitElement {
static properties = {
n: {}
}
constructor() {
super()
this.n = 0
@nexpr
nexpr / example.js
Created October 28, 2023 12:02
Lit の Directive でホストになるカスタム要素への参照をもたせる
import {html, LitElement} from "lit"
import { directive, Directive } from "lit/directive.js"
const customElementDirective = (element, Directive) => {
return directive(
class extends Directive {
host = element
}
)
}
@nexpr
nexpr / description.md
Last active October 26, 2023 14:52
ワード抽出用

これは?

ライブドアブログのダンプデータからワードを抽出するためのページ

JavaScript とか Node.js とか Web Components とか C# とか .NET とか...
主にプログラミング言語やライブラリやツールや機能などの名前を取り出すのが目的

HTML データから不要なタグを除外した上で改行を維持して文字列として取得したいのでブラウザを使う

半角スペースや記号を名前に含むものがあるのでほとんどの記号を含む半角文字列を正規表現で取り出して除外パターンと一致しないのを残す