This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface Base { | |
| foo: { [key: string]: any }; | |
| bar: any; | |
| baz: any; | |
| } | |
| interface Hoge { | |
| hoge: string; | |
| fuga: string; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // in vue.d.ts | |
| declare class Vue { | |
| $emit(event: string, ...args: any[]): this; | |
| } | |
| // in user code | |
| interface Emit<T> { | |
| <K extends keyof T>(event: K, payload: T[K]): any; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface Test { | |
| foo: string; | |
| bar: number; | |
| } | |
| // これはOK (Testそのものだけど) | |
| const t1: { [K in keyof Test]: Test[K] } = { | |
| foo: "", | |
| bar: 0 | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as Electron from "electron"; | |
| export const vuexActions = { | |
| <% | |
| VuexActions.methods.forEach((m, index) => { | |
| const paramListWithType = m.parameters.map(p => `, ${p.prefix}${p.name}${p.postfix}: ${p.typeName}`).join(""); | |
| const paramList = m.parameters.map(p => `, ${p.prefix}${p.name}`).join(""); | |
| const last = index == VuexActions.methods.length - 1; | |
| -%> | |
| <%- m.name %>(target: Electron.WebContents<%- paramListWithType -%>): void { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as Vue from "vue"; | |
| export default { | |
| name: "Render", | |
| functional: true, | |
| props: { | |
| method: { required: true, type: Function }, | |
| args: { type: Array } | |
| }, | |
| render(h: typeof Vue.prototype.$createElement, context: Vue.RenderContext): Vue.VNode { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import functools | |
| def kamekoopa(f): | |
| @functools.wraps(f) | |
| def call(*args, **argd): | |
| # upd-sta H.Iwata セミコロンを削除 | |
| # print("完全にマスター"); | |
| print("完全にマスター") | |
| # upd-end H.Iwata セミコロンを削除 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Main() | |
| { | |
| var x = 4; | |
| var y = 2; | |
| Expression<Func<int>> exp = () => x; | |
| Expression<Func<int, int>> twice = n => n * y; | |
| var param = twice.Parameters[0]; | |
| var exp2 = new Visitor(exp.Body, twice.Body).Visit(exp); | |
| var exp3 = (Expression<Func<int>>)new Visitor(param, exp.Body).Visit(exp2); | |
| var f = exp3.Compile(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // OrderBy(x => x.Id).ThenBy(x => x.Name) みたいな比較をするComparer | |
| // var comparer = KeyComparer<Foo>.CreateBy(x => x.Id).ThenBy(x => x.Name); みたいに使う | |
| public class KeyComparer<T> : IComparer<T> | |
| { | |
| readonly List<Comparison<T>> comparisons_; | |
| private KeyComparer(params Comparison<T> []comparisons) | |
| { | |
| comparisons_ = comparisons.ToList(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| import ast | |
| class _MakeFunction(ast.NodeTransformer): | |
| def __init__(self, name, args, body): | |
| self.name = name | |
| self.args = args | |
| self.body = body | |
| def run(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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> |