Skip to content

Instantly share code, notes, and snippets.

View benoitjadinon's full-sized avatar

Benoit Jadinon benoitjadinon

View GitHub Profile
@benoitjadinon
benoitjadinon / README.md
Last active December 22, 2023 20:29
Svelte vs React vs Flutter : int stepper exercise

Svelte vs React vs Flutter

A int stepper exercise (from this great talk)

The goal is to compare technologies using a reactive form that has a 2-way twist (value can be changed manually, and be changed from different sources) results will be graded in terms of code readabilty and number of redraws needed

svelte repl

react playground

@benoitjadinon
benoitjadinon / main.dart
Last active July 21, 2020 10:22
filterin'
void main() {
final pairs = [
'BTC/USDT',
'BTCD/USDT',
'BTC/USD',
'USDT/BTC',
];
final search = 'BTCUS';
final r = search.replaceAll(' ', '').split('').join('.*?');
@benoitjadinon
benoitjadinon / enum.dart
Last active July 2, 2020 21:24
Dart enum to and from string
//Copyright (C) 2012 Sergey Akopkokhyants. All Rights Reserved.
//Author: akserg
/// Emulation of Java Enum class.
///
/// Example:
///
/// class Meter<int> extends Enum<int> {
///
@benoitjadinon
benoitjadinon / stream_debug_extension.dart
Created June 16, 2020 00:25
debugger breaks on any Stream event
extension StreamExtensions<T> on Stream<T> {
/// usage:
/// userStream
/// //.breakpoint() // to break on ALL events of the stream
/// .breakpoint(prefix:'user', whenKind(k) => k == EventKind.OnResume)
/// .listen();
Stream<T> breakpoint({
String prefix,
String message,
@benoitjadinon
benoitjadinon / keybase.md
Last active September 7, 2019 15:26
(personal) keybase proof

Keybase proof

I hereby claim:

  • I am benoitjadinon on github.
  • I am benoitjadinon (https://keybase.io/benoitjadinon) on keybase.
  • I have a public key ASB-I4oxAigtmDfVCqOjjiXEhPhhQ_ERLILKc6Fu22dfJAo

To claim this, I am signing this object:

@benoitjadinon
benoitjadinon / FireBaseApi.dart
Last active August 31, 2019 15:45
FirebaseApi dart `appsModel = FirebaseModel<App>("apps", App.fromFirebaseStatic);`
import 'package:cloud_firestore/cloud_firestore.dart';
import 'jsonable.dart';
class FireBaseApi {
final String path;
final Firestore _db = Firestore.instance;
CollectionReference _ref;
@benoitjadinon
benoitjadinon / BehaviorStreamBuilder.dart
Last active November 20, 2019 04:42
BehaviorStreamBuilder, no more flicker because of initialData ( https://twitter.com/filiphracek/status/1050798900968181761 )
class BehaviorStreamBuilder<T> extends StreamBuilder<T>
{
BehaviorStreamBuilder({
Key key,
BehaviorSubject<T> stream,
@required AsyncWidgetBuilder<T> builder
}) : assert(builder != null),
super
(
key: key,
import 'package:flutter/widgets.dart';
// (c) Didier Boelens
// https://www.didierboelens.com/2018/12/reactive-programming---streams---bloc---practical-use-cases/
Type _typeOf<T>() => T;
abstract class BlocBase {
void dispose();
}
@benoitjadinon
benoitjadinon / tv.dart
Last active October 18, 2018 15:28
TradingView Chart Dart JS Interop
@JS()
library tv.js;
import "package:js/js.dart";
@JS("TradingView.widget")
class widget {
external factory widget(WidgetOptions options);
}
@benoitjadinon
benoitjadinon / SkCanvasExtensions.cs
Last active August 27, 2018 10:54
DrawTextCenteredVertically
/// <remarks>https://stackoverflow.com/questions/27631736/meaning-of-top-ascent-baseline-descent-bottom-and-leading-in-androids-font</remarks>
public static void DrawTextCenteredVertically(this SKCanvas canvas, string text, SKPaint paint, SKPoint point)
{
var textY = point.Y + (((-paint.FontMetrics.Ascent + paint.FontMetrics.Descent) / 2) - (paint.FontMetrics.Descent /2)); // seems to work better with descent/2
canvas.DrawText(text, point.X, textY, paint);
}