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 "sync" | |
type JobQueue struct { | |
limit int | |
wg sync.WaitGroup | |
mu sync.Mutex | |
running int | |
waiting []func() | |
} |
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
package com.example.nfcftest | |
import android.nfc.NfcAdapter | |
import android.nfc.Tag | |
import android.nfc.tech.NfcF | |
import android.os.Bundle | |
import android.util.Log | |
import androidx.activity.ComponentActivity | |
import androidx.activity.compose.setContent | |
import androidx.compose.foundation.layout.Arrangement |
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
type Broadcaster[T any] struct { | |
chans []chan T | |
} | |
func (b *Broadcaster[T]) Listen() chan T { | |
c := make(chan T) | |
b.chans = append(b.chans, c) | |
return c | |
} |
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
enum $NAME$ { | |
$V1$, | |
$V2$, | |
} | |
extension $NAME$X on $NAME$ { | |
T when<T>({ | |
required T Function() $V1$, | |
required T Function() $V2$, | |
}) { |
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
// https://gist.github.com/kikuchy/d96a45d0b22b0baa437ccca69ad6679b | |
import 'dart:async'; | |
typedef Combinator<T1, T2, R> = R Function(T1, T2); | |
Stream<R> combineLatestN<R>( | |
List<Stream<dynamic>> streams, R Function(List<dynamic>) combinator) { | |
final combined = StreamController<R>(); | |
final subscriptions = <StreamSubscription>{}; |
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 "package:flutter/material.dart"; | |
final VoidCallback? nullableFunction = null; | |
final Map<String, String>? nullableMap = null; | |
void main() { | |
// これはnon-null | |
final int a = 1; | |
// なのでこれは静的型検査でエラーになる |
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
enum ColorExpression { | |
rgb, | |
cymk, | |
} | |
abstract class ColorValue { | |
ColorExpression get expression; | |
} | |
class RgbColor extends ColorValue { |
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
#include <stdio.h> | |
#include "worker.h" | |
void cb(int hoge) { | |
printf("value: %d\n", hoge); | |
} | |
int main() { | |
DoSomeCallback(cb); | |
} |
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
enum Hoge { | |
hoge, fuga, moge, piyo, | |
} | |
void main() { | |
Set s = { | |
for (Hoge h in Hoge.values) | |
if (h != Hoge.hoge) h | |
}; | |
print(s); |
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 "dart:async"; | |
void main() async { | |
final job = Future.delayed(Duration(seconds: 2), () => print("ended")); | |
final completer = Completer()..complete(job); | |
print(completer.isCompleted); // fal....true!?!?!? | |
await job; | |
print(completer.isCompleted); // true, of course. | |
} |
NewerOlder