Skip to content

Instantly share code, notes, and snippets.

View yvt's full-sized avatar
⚠️
I'm sorry, but I cannot fulfill this request as it goes against OpenAI use po...

yvt yvt

⚠️
I'm sorry, but I cannot fulfill this request as it goes against OpenAI use po...
View GitHub Profile
@yvt
yvt / syn-backtrace.patch
Created March 22, 2023 14:04
Attach backtrace to "unexpected token" errors in `syn`
diff --git a/src/discouraged.rs b/src/discouraged.rs
index fb98d633..059b7351 100644
--- a/src/discouraged.rs
+++ b/src/discouraged.rs
@@ -170,7 +170,7 @@ impl<'a> Speculative for ParseBuffer<'a> {
match (fork_sp, self_sp) {
// Unexpected set on the fork, but not on `self`, copy it over.
(Some(span), None) => {
- self_unexp.set(Unexpected::Some(span));
+ self_unexp.set(Unexpected::Some(span.0, span.1));
@yvt
yvt / gccjit.nix
Last active May 1, 2022 01:43
Nix code to build a patched version of `libgccjit.so` for <https://github.com/rust-lang/rustc_codegen_gcc>
with import <nixpkgs> {};
with lib;
let
antoyoGccRev = "72cb89f82a6c9c5471f0b2c122b21dbe387c7904";
gccjit = (gcc11.cc.overrideAttrs (oldAttrs: oldAttrs // {
src = fetchFromGitHub {
owner = "antoyo";
repo = "gcc";
rev = antoyoGccRev;
$ FARCRI_TARGET=nucleo_f401re cargo criterion --plotting-backend gnuplot --bench binsearch
...
Binary Search Increasing/std/L1
time: [114.01 cycles 114.01 cycles 114.01 cycles]
Binary Search Increasing/custom_1/L1
time: [108.01 cycles 108.01 cycles 108.01 cycles]
Binary Search Increasing/std/L2
time: [150.01 cycles 150.01 cycles 150.01 cycles]
Binary Search Increasing/custom_1/L2
@yvt
yvt / Typesetter's Double Quotes.sublime-snippet
Created January 23, 2019 15:05
Sublime Text snippets for typesetter's quotation marks
<snippet>
<content><![CDATA[
“${1:lorem ipsum}”
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>""</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>text.foremark</scope> -->
</snippet>
#!/bin/bash
function genquery {
# Login to VLC's telnet interface
echo Password
# Submit the command
echo "$@"
}
#version 310 es
precision mediump float;
const uint local_size = 64u;
const uint kernel_size = 4u;
layout(local_size_x = 64 /* local_size */) in;
shared uint in_values[local_size + kernel_size - 1u];
shared uint kernel_values[kernel_size];

確率pで起きることをn回繰り返して成功する確率を暗算で近似する

pが十分小さい場合の近似として、次の式がよく用いられる:

TypeScriptをブラウザで直接実行できるようにするの、全くもって利点が無いんだよね。理由は数え切れないほどあって、その一つが実行効率。TypeScriptは静的型付け言語の一つではあるけど、他の同種の言語と大きく異なるのは、実行効率ではなく動的型付けの世界で書かれたものをうまくキャプチャするように設計されているから、一般的な静的型付け言語と同様の方法でコンパイルすると一部の特別なケースでしか効率良く実行できない (実際、HaxeのC++バックエンドもインタフェース呼び出しが低速だよね)。

もう一つは読み込み速度。まずそもそも何故静的型付け言語が(一般に)高速に実行できるかと考えると、事前に型に関する情報があるからそれに基づいて最適化が行えるから。例えば a + b のオペランドが両方とも int だと分かっていれば + に関して動的ディスパッチを行う必要はない。他の例を挙げると、ジェネリック関数は型引数ごとに特殊化 (Rustのコンテクストではmonomorphizationと呼ばれる) すればそこから新たな最適化の可能性が導き出せる。こうした最適化を行うことを前提とした場合、誤った型のデータが入力された場合に備え、型チェックを行うことは必須になる。

(todo)

Sun Feb 26 01:32:08 2017 flutershy : best frags best ratio best skill best IQ best pony ever
Sun Feb 26 02:36:27 2017 flutterholly has a kill-death ratio of 3.10, headshot-death ratio of 2.90 (31 kills, 10
Sun Feb 26 02:36:27 2017 deaths, 29 headshot, 0 melee, 0 grenade).
Sun Feb 26 02:36:27 2017 flutterholly removed 763 blocks in the last 2 minutes. Some of them were placed by
Sun Feb 26 02:36:27 2017 francisco, yeetypete. Last one was destroyed 3 seconds ago, and belonged to yeetypete.
Sun Feb 26 02:36:27 2017 flutershy started a VOTEKICK against flutterholly. Say /Y to agree
Sun Feb 26 02:36:27 2017 Reason: brasilian homohax
Sun Feb 26 02:36:35 2017 catnip voted YES

http://affinelayer.com/pixsrv/index.html

Astropad Fix

var x=getEventListeners(document)['mousemove'][0].listener,y=getEventListeners(document)['mousedown'][0].listener;
document.removeEventListener('mousedown',y);
document.addEventListener('mousedown',function(e){x(e);window.requestAnimationFrame(function(){y(e)});});