In T4 Template, ASPX .tt files are code seeds.
In Razor Code Template, Razor .cshtml files are seeds!
This file contains 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
const { data } = useQuery(["pets", 1], fetch(`/pets`), { map: (v) => v }); | |
const useQuery = (key, fetcher, { map }) => { | |
const [payload, setPayload] = useRecoilState(cacheState(key)); | |
const promise = payload ? Promise.resolve() : fetcher().then(setPayload); | |
const data = useMemo( | |
() => (payload ? map(payload) : undefined), | |
[map, payload] | |
); |
This file contains 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
/// <reference types="jest" /> | |
declare namespace jest { | |
interface Expect { | |
that(fn: (target: any) => void): any; | |
} | |
interface InverseAsymmetricMatchers { | |
that(fn: (target: any) => void): any; | |
} |
This file contains 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
// Moved to https://github.com/occar421/ProgrammingContest/tree/master/templates/src/standard_io.rs , sorry! |
This file contains 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 { AssertTrue, Has, IsExact } from "conditional-type-checks"; | |
// interface A<T1 extends { [key: string]: any }, T2 extends T1> { | |
// a: T1; | |
// // b: (keyof T2)[]; // 現実解 | |
// b: Workaround<keyof T2>[]; // 現実解 | |
// // b: TupleAtMost3<T2>; // 重複を防ぐようにするにはすべての組み合わせを列挙する? | |
// } | |
// interface A<T1 extends { [key: string]: any }, T2 extends T1> { |
This file contains 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
const fs = require('fs-extra'); | |
const path = require('path'); | |
const {spawn} = require('child_process'); | |
(async () => { | |
const base = path.join(__dirname, 'sandbox'); | |
await fs.mkdirp(base); | |
await fs.outputFile(path.join(base, 'foo.txt'), 'FOO'); | |
await fs.outputFile(path.join(base, 'bar.txt'), 'BAR'); | |
const results = await fs.readdir(base) |
This file contains 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
class SN<T>(val value: T) | |
class B<T>(val value: T) | |
infix fun <T> T.should(right: B<T>): Unit { | |
println("$this is ${right.value}") | |
} | |
fun <T> be(value: () -> T): B<T> { | |
return B(value()) | |
} |
This file contains 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
class Event<T> { | |
private val handlers = arrayListOf<(Event<T>.(T) -> Unit)>() | |
operator fun plusAssign(handler: Event<T>.(T) -> Unit) { handlers.add(handler) } | |
operator fun invoke(value: T) { for (handler in handlers) handler(value) } | |
} | |
val e = Event<String>() // define event | |
fun main(args : Array<String>) { | |
e += { println(it) } // subscribe |
This file contains 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
fun main(args: Array<String>) { | |
setup() | |
} | |
inline fun <reified T : Agent> ask(noinline job: T.() -> Unit): Unit { | |
for (t in AgentsManager.getAgent<T>()) { | |
job(t) | |
} | |
} |
This file contains 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
fun main(args: Array<String>) { | |
setup() | |
} | |
var turtles = arrayOf<Turtle>() | |
infix inline fun <T : Turtle> T.ask(job: T.() -> Unit): Unit = job(this) | |
infix inline fun <T : Turtle> Array<T>.ask(job: T.() -> Unit): Unit { | |
for (t in this) { |
NewerOlder