Skip to content

Instantly share code, notes, and snippets.

View word-length.rb
def f(*)
yield 64 if block_given?
end
def g(*)
yield 32 if block_given?
end
f g((((((((((((((((((((((((((((((((((((((((((((((((
0
)))))))))))))))))))))))))))))))))))))))))))))))) do |x|
p x
View ruby-syntax.md

parse.y

字句解析状態

基本の字句解析状態はlex_state_bits, lex_state_eにある。

  • EXPR_BEG
    • 式の開始位置
  • EXPR_END
  • リテラル・識別子の終了位置
View ssh_config
Host example.com
Port 22
User qnighy
Host github.com
CheckHostIP no
Host *
# Share connections among processes
ControlMaster auto
ControlPath ~/.ssh/mux-%r@%h:%p
ControlPersist 10
@qnighy
qnighy / html-states.txt
Last active May 4, 2022
HTML basic parser states
View html-states.txt
<!-- initial -->
<!-- Ignored: whitespace -->
<!-- Relocated: comment -->
<!DOCTYPE html>
<!-- before html -->
<!-- Ignored: whitespace -->
<!-- Ignored: DOCTYPE -->
<!-- Ignored: end tags other than </head>, </body>, </html>, </br> -->
<!-- Relocated: comment -->
<html>
@qnighy
qnighy / contentmodel.md
Created Apr 26, 2022
HTML elements in content model Venn diagram
View contentmodel.md

https://html.spec.whatwg.org/multipage/dom.html#kinds-of-content

  • Node
    • Flow content (a, abbr, address, area (if it is a descendant of a map element), article, aside, audio, b, bdi, bdo, blockquote, br, button, canvas, cite, code, data, datalist, del, details, dfn, dialog, div, dl, em, embed, fieldset, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, i, iframe, img, input, ins, kbd, label, link (if it is allowed in the body), main (if it is a hierarchically correct main element), map, mark, MathML math, menu, meta (if the itemprop attribute is present), meter, nav, noscript, object, ol, output, p, picture, pre, progress, q, ruby, s, samp, script, section, select, slot, small, span, strong, sub, sup, SVG svg, table, template, textarea, time, u, ul, var, video, wbr, autonomous custom elements, text)
      • Sectioning (article, aside, nav, section)
      • Heading (h1, h2, h3, h4, h5, h6, hgroup)
  • Phrasing (a, abbr, area (if it is a descendant of a map element), audio, b, bdi, bdo, br, bu
@qnighy
qnighy / html.md
Last active Apr 17, 2022
HTML構文メモ
View html.md
@qnighy
qnighy / zippy-type-predicates.ts
Created Apr 4, 2022
TypeScript type testing util less than in 40 lines
View zippy-type-predicates.ts
// Copyright 2022 Masaki Hara
// Licensed in MIT https://opensource.org/licenses/MIT
type Predicate<T> = {
co?: (() => T) | undefined;
contra?: ((x: T) => void) | undefined;
};
function expectType<T>() {
return {
@qnighy
qnighy / juxtaposition-application.md
Created Feb 22, 2022
並置による関数適用に関する所感
View juxtaposition-application.md

並置による関数適用

並置による関数適用の善し悪しについて盛り上っているので、自分の意見を表明しておく。以下の2本立て。

  • 純粋に構文論的な議論 (構文拡張の余地を残す)
  • 意味論との関係での議論 (副作用の表示)

先に結論だけ書くと、私はどちらかといえば括弧による関数適用のほうが好みです。

そもそも並置による関数適用とは

View html-script-data-table.txt
"" ... "" + script data
"." ... "." + script data
"<" ... "" + script data less-than sign
"</" ... "" + script data end tag open
"</." ... "</." + script data
"</a" ... "" + script data end tag name
"</script " ... "" + before attribute name
"</foo " ... "</foo " + script data
"</script/" ... "" + self-closing start tag
"</foo/" ... "</foo/" + script data
@qnighy
qnighy / main.rs
Created Mar 28, 2021
stdin.scan() for competitive programming
View main.rs
use std::io::{self, BufRead};
use std::str::{self, FromStr};
fn from_buf<T: FromStr>(buf: &[u8]) -> io::Result<T>
where
T::Err: std::error::Error + Send + Sync + 'static,
{
let s = str::from_utf8(buf).map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?;
T::from_str(s).map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))
}