Skip to content

Instantly share code, notes, and snippets.

@tolo
tolo / nested_navigation_shell_route.dart
Last active March 23, 2024 07:49
Example showing how to use go_router to build persistent nested navigation (i.e. separate nested navigation trees) with a BottomNavigationBar.
// This temporary implementation is now obsolete, see instead:
// https://pub.dev/documentation/go_router/latest/go_router/StatefulShellRoute-class.html
@yut304
yut304 / brew-install-dnsmasq-macos-m1.md
Last active May 5, 2024 00:31
Install dnsmasq on macos m1

Install dnsmasq with brew:

$ brew install dnsmasq

Setup *.test hosts with:

$ echo 'address=/.test/127.0.0.1' >> /opt/homebrew/etc/dnsmasq.conf

If want to use other device to resolv nameserver ( default only 127.0.0.1 )

@thecodewarrior
thecodewarrior / App Icon Template.svg
Last active July 11, 2024 17:58
An SVG template for creating macOS app icons, including guides and the standard drop shadow
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@schultek
schultek / nested_will_pop_scope.dart
Last active March 26, 2024 15:24
An improved WillPopScope widget to allow for nested navigators. See https://github.com/flutter/flutter/issues/47088
import 'package:flutter/material.dart';
class NestedWillPopScope extends StatefulWidget {
const NestedWillPopScope({
Key? key,
required this.child,
required this.onWillPop,
}) : super(key: key);
final Widget child;
@ForceTower
ForceTower / article_dao.dart
Created May 8, 2020 23:11
Fetch relations using floor
@Query('SELECT * FROM article ORDER BY publishedAt DESC')
Stream<List<Article>> getAllArticles();
@Query('SELECT Author.*, _junction.articleId as articleId FROM ArticleAuthor AS _junction inner join Author ON (_junction.authorId = Author.id) WHERE _junction.articleId IN (:ids)')
Future<List<AuthorArticleId>> getAuthorsFromArticles(List<int> ids);
Stream<List<ArticleWithAuthor>> getAllArticlesWithAuthors() {
final stream = getAllArticles();
final controller = StreamController<List<ArticleWithAuthor>>.broadcast();
@Luoyayu
Luoyayu / gist:3c5f099dd1a453f049fced1df7bc7964
Created December 12, 2019 18:48
extract Xcode.xip to a customed volume
By default, when extracts the Xcode.zip,
macos will create tmp file in `/private/var/folders/v2/tbmrn60d2910x3w23ys5fgs00000gn/T/com.apple.AUHelperService`.
Sometimes, the /private has no ehough space to hold 19GB Xcode.app.
Thus we can create a soft link named `com.apple.AUHelperService` in the tmp dir.
Steps:
1. BACKUP `com.apple.AUHelperService` in `/private/var/folders/v2/tbmrn60d2910x3w23ys5fgs00000gn/T/` to `com.apple.AUHelperService_BACKUP`
2. mkdir named `com.apple.AUHelperService` wherever you have enough space,
3. ln -s /your/absolute/path/com.apple.AUHelperService /private/var/folders/v2/tbmrn60d2910x3w23ys5fgs00000gn/T
4. double click the Xcode.xip
class BlocProvider<Value, Bloc extends _bloc.Bloc<dynamic, Value>>
extends ValueDelegateWidget<Bloc> implements SingleChildCloneableWidget {
/// Allows to specify parameters to [BlocProvider].
BlocProvider({
Key key,
@required ValueBuilder<Bloc> builder,
UpdateShouldNotify<Value> updateShouldNotify,
UpdateShouldNotify<Value> blocUpdateShouldNotify,
Disposer<Bloc> dispose,
Widget child,
@felangel
felangel / main.dart
Created February 27, 2019 04:02
Bloc Exception Handling
import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
abstract class AuthenticationEvent extends Equatable {
AuthenticationEvent([List props = const []]) : super(props);
}
class LoginEvent extends AuthenticationEvent {
final String loginRequest;
@khalilgharbaoui
khalilgharbaoui / db.rake
Created February 3, 2019 21:29 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# Original source: https://gist.github.com/hopsoft/56ba6f55fe48ad7f8b90
# Merged with: https://gist.github.com/kofronpi/37130f5ed670465b1fe2d170f754f8c6
# Benefits of: https://gist.github.com/e12e/e0c7d2cc1d30d18c8050b309a43450ac
# And fixes of: https://gist.github.com/joelvh/f50b8462611573cf9015e17d491a8a92
namespace :db do
desc 'Dumps the database to backups'
task dump: :environment do
dump_fmt = ensure_format(ENV['format'])
dump_sfx = suffix_for_format(dump_fmt)
backup_dir = backup_directory(Rails.env, create: true)
@legowerewolf
legowerewolf / hyperstart.bat
Last active December 29, 2023 16:45
Selecting a shell on startup in the Hyper terminal emulator
@ECHO off
:top
CLS
ECHO Choose a shell:
ECHO [1] cmd
ECHO [2] bash
ECHO [3] PowerShell
ECHO [4] Python
ECHO.
ECHO [5] restart elevated