Skip to content

Instantly share code, notes, and snippets.

@wonderful-panda
wonderful-panda / test.tsx
Last active December 6, 2021 22:32
difference behaviour between react and preact
/*
* With react@17.0.2, Effect-A is triggered, then Effect-B is triggered. (expected)
* With preact@10.6.2, Effect-B is triggered, then Effect-A is triggered.
*
* `useLayoutEffect` is more appropriate for Effect-A, maybe.
*
* BTW, behaviours will be same if removing React.memo call (line.39)
*/
const EditorWrapper_: React.VFC<{
@wonderful-panda
wonderful-panda / _runner.ts
Last active August 19, 2021 18:34
[TypeScript] 期待した通りのコンパイルエラーが出るかどうかテストするやつ
/*
* 1. ../tsconfig.json に設定ファイルを置く
* 2. ../cases/ の中に example.ts みたいなファイルを置く (/// TSXXXX: ~ でその行で期待するコンパイルを記述する。~の部分は正規表現)
* 3. _runner.ts を ava で実行すると、出力サンプルみたいな感じで結果が出力される
*/
import * as ts from "typescript/lib/typescript";
import * as fs from "fs";
import * as path from "path";
import * as glob from "glob";
import heapq
from typing import List, Tuple
def calc_costs(N: int, MAP: List[Tuple[int, int]], start: int) -> List[int]:
"""
指定された都市から各都市への最小コストを計算する
MAP: list of { index: 都市, value: (行先の都市, コスト) }
"""
from collections import deque
K = int(input())
TEXT = input()
N = len(TEXT)
ORD_A = ord('a') # 97
# a ~ z の文字ごとの出現位置
alphabets = [deque() for _ in range(26)]
min_index = 0
@wonderful-panda
wonderful-panda / weakevent.cs
Created July 8, 2014 22:12
オレオレWeakEvent
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Linq.Expressions;
using System.Diagnostics;
namespace WonderfulPanda.Gists
{
@wonderful-panda
wonderful-panda / document.md
Created June 26, 2019 03:33
vue-class-component + vue-property-decorator で作ったコンポーネントをなるべくストレスなくTSXで使いたい

vue-class-component + vue-property-decorator で作ったコンポーネントをなるべくストレスなくTSXで使うための仕組みを考えていて、 vue-tsx-supportにこんな感じのHelperを追加しようかと検討中

import Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
import { DefineProps, TsxEvent, InnerScopedSlot } from "vue-tsx-support";

@Component
class MyComponent extends Vue {
@wonderful-panda
wonderful-panda / output.txt
Created May 24, 2019 03:35
すえ爆の解を探索するやつ
SOLVED!
1 2 3 4 5
A ○ ○ ○ ○ ○
B ○ ○ ○ ○ ○
C ○ ○ ○ ○ ○
D ○ ○ ○ ○ ○
E ○ ○ ○ ○ ○
step 1: E5
@wonderful-panda
wonderful-panda / document.md
Last active February 10, 2019 11:21
Vue + JSXの環境でLibraryManagedAttributesを使って型付けする方法を考えてみるテスト

仮に、Vue.extendに渡されたオプションの型を出来上がったコンポーネントから参照可能になるとする。 これはそれを疑似的に可能にするためのヘルパ

/*
 * const Component = createComponentExperimental({ ... }); でコンポーネントを定義すれば
 * typeof Component["_options"] でオプションの型を取得できる
 */
import Vue, { VueConstructor } from "vue"; 
import { ThisTypedComponentOptionsWithRecordProps } from "vue/types/options";
@wonderful-panda
wonderful-panda / vueAsync.ts
Created October 30, 2018 06:49
[Vue.js] Helper function to make async component
import Vue, { VNode, CreateElement } from "vue";
import { RecordPropsDefinition } from "vue/types/options";
import { TsxComponent } from "vue-tsx-support";
export function vueAsync<Props>(definition: {
props?: RecordPropsDefinition<Props>;
renderAsync(this: Vue & Props, h: CreateElement): Promise<VNode>;
loading(this: Vue & Props, h: CreateElement): VNode;
}): TsxComponent<Vue, Props> {
const { props, renderAsync, loading } = definition;
@wonderful-panda
wonderful-panda / MainWindow.xaml
Created January 29, 2015 15:00
[WPF]ListView.SelectedItemsとListViewItem.IsSelectedの挙動を確認するテストプログラム
<Window x:Class="WpfTraning.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:WpfTraning"
Height="300" Width="400">
<Window.DataContext>
<my:ViewModel/>
</Window.DataContext>
<Grid>
<Grid.RowDefinitions>