Skip to content

Instantly share code, notes, and snippets.

@shinayser
shinayser / pan_zoom_behavior.dart
Created April 4, 2026 03:03
A Behavior (flame_behavior) that adds a Pan and Zoom behavior to a Entity in Flame engine.
import 'dart:ui';
import 'package:flame/components.dart';
import 'package:flame/events.dart';
import 'package:flame/rendering.dart';
import 'package:flame_behaviors/flame_behaviors.dart';
/// A [Behavior] that adds pan and zoom to its parent entity,
/// simulating camera movement.
///
@shinayser
shinayser / pan_zoom_component.dart
Created April 4, 2026 02:59
A Component that adds Pan and Zoom behavior to a PositionedComponent in Flame
import 'dart:ui';
import 'package:flame/components.dart';
import 'package:flame/events.dart';
import 'package:flame/rendering.dart';
/// A component that adds pan and zoom behavior to its parent
/// [PositionComponent], simulating camera movement.
///
/// ```dart
@shinayser
shinayser / pan_zoom_mixin.dart
Last active April 4, 2026 02:58
A mixin that adds Pan and Zoom behaviors to a PositionedComponent from Flame engine.
import 'dart:ui';
import 'package:flame/components.dart';
import 'package:flame/events.dart';
/// Mixin that adds pan and zoom behavior to a [PositionComponent],
/// simulating camera movement within the component.
///
/// Uses [DragCallbacks] to capture pan (1 finger) and
/// pinch-to-zoom (2+ fingers) gestures automatically on the component itself.
@shinayser
shinayser / dio_freeze_interceptor.dart
Created October 2, 2024 14:05
Demo showing how dio can freeze/crash the app if an error occurs inside the interceptor
import 'package:dio/dio.dart';
Future<void> main() async {
final dio = Dio();
//Using the same dio instance: crash
dio.interceptors.add(InterceptorWithError(dio));
//Using different instance: works
//dio.interceptors.add(InterceptorWithError(Dio()));
@shinayser
shinayser / Start-Emulator.ps1
Created May 4, 2023 14:25
Starts an Android Emulator (with completions)
function Start-Emulator(
[ArgumentCompleter({
param(
$CommandName,
$ParameterName,
$WordToComplete,
$CommandAst,
$FakeBoundParameters
)
@shinayser
shinayser / Get-FlutterHotFixes.ps1
Last active April 1, 2023 21:17
Fetches all flutter hotfixes on stable branch
function Get-FlutterHotFixes([int]$Amount = 2) {
$url = "https://raw.githubusercontent.com/wiki/flutter/flutter/Hotfixes-to-the-Stable-Channel.md"
$regex = "###\s*\[?(?<Version>\d+.\d+.\d+)\]?(?<Url>.*)\s(?<Changes>[\s\S]+?)(?=#+)"
Invoke-RestMethod $url | Select-String -Pattern $regex -AllMatches | ForEach-Object {
$_.Matches | ForEach-Object { [pscustomobject]@{
Version = $_.Groups[1].Value
Url = $_.Groups[2].Value
Changes = $_.Groups[3].Value
}
}
@shinayser
shinayser / Normalizing GIT file endings.txt
Last active February 13, 2023 21:35
Normalizing git file endings to LF
git config --global core.autocrlf false
@shinayser
shinayser / Powershell toPascal-toSnakeCase.ps1
Last active February 7, 2023 01:33
Functions to convert text into Pascal or Snake case
function toPascalCase([string] $text) {
return $text -replace '(?:^|_)(\p{L})', { $_.Groups[1].Value.ToUpper() }
}
function toSnakeCase([string] $text) {
$text = $text -replace '\s+', '_' # Replace spaces with underscores
$text = $text -replace '[-\.]', '_' # Replace dashes and dots with underscores
$text = $text -creplace '(?<![-_A-Z])(?<!^)[A-Z]', { "_$_" } # Insert underscores before uppercase letters
return $text.ToLower()
}
# Looking for a object in path
Get-Command flutter
# Extracting a property from it
Get-Command flutter | Select-Object -ExpandProperty source
# Advanced String Interpolation (with expressions)
Get-ChildItem | ForEach-Object { Write-Output "The lenght: $($_.Length)" }
@shinayser
shinayser / kill_steam.ps1
Last active December 21, 2021 15:32
Kill steam process
$steam = Get-Process steam -ErrorAction Ignore
if ($null -eq $steam) {
Write-Output "Steam not found"
}
else {
$steam.Kill($true)
Write-Output 'Steam is dead'
}