Skip to content

Instantly share code, notes, and snippets.

View michael-wang's full-sized avatar

Michael Wang michael-wang

View GitHub Profile
@michael-wang
michael-wang / 1_generic_notifier.dart
Last active January 16, 2024 05:51
[Dart] Multi-value notifier & consumer
import 'package:flutter/widgets.dart';
import 'package:provider/provider.dart';
class MultiValueNotifier<E extends Enum, T> extends ChangeNotifier {
// Map of name to value.
final values = <E, T>{};
add(E name, T value) {
values[name] = value;
notifyListeners();
@michael-wang
michael-wang / auth.dart
Created September 7, 2023 16:08
[riverpod] Auth async provider as Listener (for RoRouter.refreshListenable)
part 'auth.g.dart';
// The key to become Listenable, is to implement Listenable...
// And notify listener when state changed of course.
@Riverpod(keepAlive: true)
class Auth extends _$Auth implements Listenable {
VoidCallback? _callback;
@override
void addListener(VoidCallback listener) {
Description:
mit-scheme don't support Mac with M1 chip
A work around here:
https://kennethfriedman.org/thoughts/2021/mit-scheme-on-apple-silicon/
In case above website gone, here are steps:
1. Download x86 Scheme
2. Run Terminal in Emulation Mode (Rosetta mode)
3. Fix the Source Code
@michael-wang
michael-wang / keybase.md
Created October 14, 2019 02:48
To verify keybase profile.

Keybase proof

I hereby claim:

  • I am michael-wang on github.
  • I am michaelwang (https://keybase.io/michaelwang) on keybase.
  • I have a public key ASDbx619up2f69orMLmWxFmDVparpOEJTRE7YI_yxQcWYQo

To claim this, I am signing this object:

set nocompatible
set number
"set cursorline
"set cursorcolumn
set showmatch
set hlsearch
set tabstop=4
set shiftwidth=4
public class FrameRateCalculator extends Observable {
private static final long DEFAULT_NOTIFY_INTERVAL = 1000L;
public FrameRateCalculator() {
this(DEFAULT_NOTIFY_INTERVAL);
}
public FrameRateCalculator(long notifyObserverIntervalInMs) {
NOTIFY_OBSERVER_INTERVAL = notifyObserverIntervalInMs;
public class Foo {
private static class InstanceHolder {
public static final Foo instance = new Foo();
}
public static Foo getInstance() {
return InstanceHolder.instance;
}
}