Skip to content

Instantly share code, notes, and snippets.

View qnighy's full-sized avatar

Masaki Hara qnighy

View GitHub Profile
CREATE TEMP FUNCTION parseMessage(messageB64 BYTES)
RETURNS STRING
LANGUAGE js AS """
const toSextet = (ch) => {
if (0x41 <= ch && ch < 0x41 + 26) {
return ch - 0x41;
} else if (0x61 <= ch && ch < 0x71 + 26) {
return ch - (0x61 - 26);
} else if (0x30 <= ch && ch < 0x30 + 10) {
return ch + (52 - 0x30);
@qnighy
qnighy / rustc-phases.txt
Created May 19, 2019 14:15
rustc phases memo
- https://github.com/rust-lang/rust/blob/1.34.2/src/librustc_driver/driver.rs
- https://github.com/rust-lang/rust/blob/1.34.2/src/librustc_typeck/lib.rs
compile_input
phase_1_parse_input
parsing: syntax::parse::parse_crate_from_*
phase_2_configure_and_expand
attributes injection: syntax::attr::inject
(various setups like features, crate types and disambiguator)
recursion limit: rustc::middle::recursion_limit::update_limits
@qnighy
qnighy / Makefile
Last active May 5, 2019 06:00
GCJ2019 Round1C
#!/usr/bin/make -f
EXECS = a b c
CXX = g++
CXXFLAGS = -O2 -Wall -Wextra -g -std=gnu++14
all: $(EXECS)
clean:
$(RM) $(EXECS)
@qnighy
qnighy / Makefile
Created May 4, 2019 13:42
GCJ2019 Qual
#!/usr/bin/make -f
EXECS = a b d
CXX = g++
CXXFLAGS = -O2 -Wall -Wextra -g -std=gnu++14
all: $(EXECS)
clean:
$(RM) $(EXECS)
@qnighy
qnighy / boxed-closure-impls.md
Created February 11, 2019 01:39
Docs removed from https://github.com/rust-lang/rust/pull/55431 (under src/doc/unstable-book/src/library-features)

boxed_closure_impls

The tracking issue for this feature is #48055


This includes the following blanket impls for closure traits:

package main
func main() {
ch := make(chan int)
x := make([]int, 10)
go (func() {
y := make([]int, 10)
for i := 0; i < 1000000; i++ {
z := x
z[len(z)-1] = -1
// ==UserScript==
// @name BigQuery auto validate
// @namespace https://qnighy.info/
// @version 0.1
// @description saikou
// @author Masaki Hara
// @match https://bigquery.cloud.google.com/*
// @grant none
// ==/UserScript==
@qnighy
qnighy / rust-patterns.md
Last active March 6, 2025 19:03
Rustのパターンっぽいやつメモ

パターンとはその言語が抽象化できなかった敗北の歴史である。 しかしどんなに優れた言語であってもあらゆる繰り返しに勝てるわけではない。 人は必ずメタ繰り返しを欲するからだ。 そしてそれはRustも例外ではない。

ここでは、OOPでも知られているパターンよりも、Rustに特有のパターンを思いつく限りまとめてみた。名前は適当。

  • crate splitting
    • でかいcrateを分割して、見通しを良くする・再コンパイルの分量を削減する・並列コンパイルを可能にする
  • 親玉crate(全てにdependする)と殿crate(全てにdependされる)があることが多いので、だいたい束みたいな形になる。
@qnighy
qnighy / infer.rb
Created May 31, 2018 14:59
Great Ruby Type Inference
puts "BasicObject except Exception" if system("ruby -c "+ARGV[0])
@qnighy
qnighy / README.md
Created May 19, 2018 16:42
GCJ2018 Round2
  • A small/large
  • B small
  • C small
  • D small/large