Skip to content

Instantly share code, notes, and snippets.

View PlugFox's full-sized avatar
🦊
🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊

Plague Fox PlugFox

🦊
🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊
View GitHub Profile
@PlugFox
PlugFox / jwt.dart
Last active November 21, 2023 14:24
Centrifugo JWT
import 'dart:convert';
import 'package:crypto/crypto.dart';
import 'package:meta/meta.dart';
/// {@template jwt}
/// A JWT token consists of three parts: the header,
/// the payload, and the signature or encryption data.
/// The first two elements are JSON objects of a specific structure.
/// The third element is calculated based on the first two
@PlugFox
PlugFox / example.dart
Last active April 23, 2024 13:40
Flutter Shimmer & Skeleton
void main() => runZonedGuarded<void>(
() => runApp(const App()),
(error, stackTrace) => log('Top level exception $error'),
);
class App extends StatelessWidget {
const App({super.key});
@override
Widget build(BuildContext context) => MaterialApp(
@PlugFox
PlugFox / dependencies.dart
Last active March 2, 2024 09:23
Log collector and application initialization with dependencies
/// Dependencies
abstract interface class Dependencies {
/// The state from the closest instance of this class.
factory Dependencies.of(BuildContext context) => InheritedDependencies.of(context);
/// Database
abstract final Database database;
}
final class $MutableDependencies implements Dependencies {
@PlugFox
PlugFox / main.dart
Last active January 5, 2024 14:27
Performance benchmark of different ways to append data to a list in dart, BytesBuilder vs AddAll vs Spread vs Concatenation
// ignore_for_file: curly_braces_in_flow_control_structures
/*
* Performance benchmark of different ways to append data to a list.
* https://gist.github.com/PlugFox/9849994d1f229967ef5dc408cb6b7647
*
* BytesBuilder | builder.add(chunk) | 7 us.
* AddAll | list.addAll(chunk) | 594 us.
* Spread | [...list, ...chunk] | 1016446 us.
* Concatenation | list + chunk | 1005022 us.
@zs-dima
zs-dima / Dockerfile
Last active February 27, 2023 08:52
Runtime environment variables for Flutter Web + Update Flutter Web app JS as soon as app version updated
FROM dart:stable AS build_dart
WORKDIR /app
COPY ./tool/ ./tool/
RUN dart compile exe tool/web_env.dart -o tool/web-env
FROM plugfox/flutter:stable-web AS build_web
@PlugFox
PlugFox / tokens.md
Created October 4, 2022 19:30 — forked from zmts/tokens.md
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@PlugFox
PlugFox / listenable_selector.dart
Last active January 16, 2024 10:00
Listenable --- selector & filter --> ValueListenable<Value>
import 'package:flutter/foundation.dart' show Listenable, ValueListenable, VoidCallback, ChangeNotifier;
/// Selector from [Listenable]
typedef ListenableSelector<Controller extends Listenable, Value> = Value Function(
Controller controller,
);
/// Filter for [Listenable]
typedef ListenableFilter<Value> = bool Function(Value prev, Value next);
@PlugFox
PlugFox / main.dart
Last active May 16, 2022 16:17
Dart data class example
/*
* Dart data class example
* https://gist.github.com/PlugFox/6a6d73a7822001af7f8558df89dbc60d
* https://dartpad.dev/6a6d73a7822001af7f8558df89dbc60d
* Matiunin Mikhail <plugfox@gmail.com>, 16 May 2022
*/
import 'package:meta/meta.dart';
void main() =>
@PlugFox
PlugFox / main.dart
Last active May 1, 2022 06:54
Custom circular progress indicator
/*
* Custom progress indicator
* https://gist.github.com/PlugFox/d2274f2d4278473774b79b0020cbd618
* https://dartpad.dev/d2274f2d4278473774b79b0020cbd618
* Matiunin Mikhail <plugfox@gmail.com>, 1 May 2022
*/
import 'dart:async';
import 'dart:math' as math;
@PlugFox
PlugFox / Dockerfile
Last active April 20, 2022 16:47
How to build flutter app totally without internet with artifactory
# ------------------------------------------------------
# Dockerfile
# ------------------------------------------------------
# image: gitlab-registry.domain.tld/mobile/app/flutter
# authors: plugfox@gmail.com
# license: MIT
# ------------------------------------------------------
ARG VERSION="stable"