Skip to content

Instantly share code, notes, and snippets.

@priezz
priezz / disable all macos animations
Last active September 27, 2023 17:30 — forked from j8/disable all macos animations
disable all macos animations for high performance
# https://www.chriswrites.com/boost-your-macs-performance-by-disabling-unnecessary-animations/
defaults write -g NSScrollViewRubberbanding -int 0
defaults write -g NSAutomaticWindowAnimationsEnabled -bool false
defaults write -g NSScrollAnimationEnabled -bool false
defaults write -g NSWindowResizeTime -float 0.001
defaults write -g QLPanelAnimationDuration -float 0
defaults write -g NSScrollViewRubberbanding -bool false
defaults write -g NSDocumentRevisionsWindowTransformAnimation -bool false
defaults write -g NSToolbarFullScreenAnimationDuration -float 0
defaults write -g NSBrowserColumnAnimationSpeedMultiplier -float 0
@priezz
priezz / main.dart
Last active January 11, 2023 09:14
observers
import 'dart:async';
typedef Listener = void Function();
int _actionsProcessing = 0;
Set<Observable>? _currentReactives;
Set<Observable>? _scheduledReactives;
class Observable<T> {
Observable(T initialValue) : _value = initialValue;
@priezz
priezz / main.dart
Created December 23, 2022 12:24
null checks
extension on int? {
p() => print('int, ${this.runtimeType}');
}
extension on Null {
p() => print('null');
}
const _defaultNull = null;
// class Ii implements int {}
@priezz
priezz / main.dart
Last active December 21, 2022 09:42
Pattern matching 6
@sealed
abstract class _CarPart {
Engine(int cylinders, int horsepower);
Transmission(int gears, bool isManual);
}
class Car {
const Car(
this.model, {
required this.parts,
@priezz
priezz / main.dart
Created December 21, 2022 09:01
Pattern matching 5
abstract class CarPart {}
class Engine implements CarPart {
const Engine({
required this.cylinders,
required this.horsepower,
});
final int cylinders;
final int horsepower;
}
@priezz
priezz / main.dart
Created December 21, 2022 01:15
Pattern matching 4
class CarPart {
const CarPart();
// METHOD COULD BE GENERATED
T match<T>({
required T Function(Engine v) engine,
required T Function(Transmission v) transmission,
}) {
// ignore_for_file: curly_braces_in_flow_control_structures
if (this is Engine) return engine(this as Engine);
@priezz
priezz / main.dart
Last active December 21, 2022 00:00
Pattern matching 3
abstract class CarPart {}
class Engine implements CarPart {
const Engine({
required this.cylinders,
required this.horsepower,
});
final int cylinders;
final int horsepower;
}
@priezz
priezz / main.dart
Last active December 20, 2022 23:51
Pattern matching 2
class CarPart {
const CarPart(this.type);
final CarPartType type;
}
enum CarPartType<T extends CarPart> {
engine<Engine>(),
transmission<Transmission>(),
}
@priezz
priezz / main.dart
Last active December 20, 2022 23:54
Pattern matching
abstract class CarPart {
CarPartType get type;
}
enum CarPartType<T extends CarPart> {
engine<Engine>(),
transmission<Transmission>(),
}
class Engine implements CarPart {
@priezz
priezz / main.dart
Last active December 20, 2022 17:29
Typed data classes
import 'package:data_classes/data_classes.dart';
import 'package:common/const.dart';
part 'change_log.g.dart';
typedef FieldValueGetter<T> = T Function(dynamic);
enum EntityType {
series,