Skip to content

Instantly share code, notes, and snippets.

View sunderee's full-sized avatar

Peter Aleksander Bizjak sunderee

View GitHub Profile
@sunderee
sunderee / expandable_bottom_sheet.dart
Created December 29, 2023 20:55
Adaptation of the expandable_bottom_sheet removing deprecated parameters + minor cleanups.
import 'package:flutter/material.dart';
/// [ExpandableBottomSheet] is a BottomSheet with a draggable height like the
/// Google Maps App on Android.
///
/// __Example:__
///
/// ```dart
/// ExpandableBottomSheet(
/// background: Container(
@sunderee
sunderee / equatable.dart
Created November 18, 2023 12:15
Miniature "equatable", good enough for majority of use cases
import 'package:collection/collection.dart';
import 'package:meta/meta.dart';
const DeepCollectionEquality _equality = DeepCollectionEquality();
@immutable
abstract class Equatable {
const Equatable();
List<Object?> get props;
@sunderee
sunderee / base.state.dart
Created October 23, 2023 11:17
Base state that can be used in Flutter apps using BLoC (inspired by Riverpod).
import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart';
sealed class BaseState<T> extends Equatable {
bool get isInitial;
bool get isLoading;
bool get isSuccessful;
bool get hasFailed;
T? get data;
Exception? get exception;
@sunderee
sunderee / install-flutter.sh
Last active February 16, 2024 08:01
Install stable version of Flutter on macOS (Apple Silicon chip)
#!/usr/bin/env bash
set -euo pipefail
readonly FLUTTER_VERSION="3.19.0"
readonly URL="https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_arm64_${FLUTTER_VERSION}-stable.zip"
readonly DIRECTORY="${HOME}/flutter"
# Function to download and extract flutter
download_flutter() {
local temp_file
@sunderee
sunderee / install-ros2.sh
Created October 14, 2023 16:19
Install ROS2 on Ubuntu
#!/bin/bash
# Set Locale
echo "Setting Locale..."
sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
# Setup Sources
@sunderee
sunderee / scope-functions.ts
Last active March 7, 2023 17:54
Scope functions in TypeScript
// Source: https://github.com/thedaviddelta/scope-extensions-js
declare global {
interface Object {
/**
* Calls the specified function block with `this` value as its argument and returns its result
* @param block - The function to be executed with `this` as argument
* @returns `block`'s result
*/
let<T, R>(this: T | null | undefined, block: (it: T) => R): R;
/**
@sunderee
sunderee / global-npm-check.sh
Last active August 26, 2023 19:52
Node.js scripts for macOS users
#!/usr/bin/env bash
GREEN="\033[0;32m"
BLUE="\033[0;34m"
CLEAR="\033[0m"
echo -e "${GREEN}Listing global NPM packages...${CLEAR}"
npm list -g --depth=0
echo -e "${GREEN}...updating & upgrading global NPM packages...${CLEAR}"
sudo npx npm-check --global --update-all