Skip to content

Instantly share code, notes, and snippets.

View stargazing-dino's full-sized avatar
🏠
Working from home

Rex Magana stargazing-dino

🏠
Working from home
View GitHub Profile
@stargazing-dino
stargazing-dino / app.dart
Created September 1, 2021 13:52
Some unconnected router setup
class App extends HookConsumerWidget {
const App({Key? key}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
final router = useMemoized(() => Router());
final locale = ref.watch(localeProvider);
return MaterialApp.router(
debugShowCheckedModeBanner: !_kIsTakingScreenshots && kDebugMode,
@stargazing-dino
stargazing-dino / lazy_list_builder.dart
Created July 7, 2021 00:12
a two way pagination builder for flutter Listviews
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
extension LoadingWidgets on List<Widget> {
// TODO: This will likely fail the requirements of a [ListView.builder]
/// Adds [loadingWidgetAfter] and [loadingWidgetBefore] to the list.
List<Widget> addLoadingIndicators(
Widget? loadingWidgetAfter,
@stargazing-dino
stargazing-dino / playground.ts
Created June 23, 2021 21:10
Changes the text of questions
import admin = require('firebase-admin');
const serviceAccount: { [key: string]: any } = require('../service_key.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: 'https://remac-test-prep.firebaseio.com',
});
const firestore = admin.firestore();
@stargazing-dino
stargazing-dino / playground.ts
Created June 23, 2021 21:05
Copy questions
import admin = require('firebase-admin');
const serviceAccount: { [key: string]: any } = require('../service_key.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: 'https://remac-test-prep.firebaseio.com',
});
const firestore = admin.firestore();
import 'package:async_button_builder/async_button_builder.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_utils/flutter_utils.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:nremt_paramedic_prep/data/profile/profile.dart';
import 'package:nremt_paramedic_prep/models/doc/doc.dart';
import 'package:nremt_paramedic_prep/models/test/test.dart';
import 'package:nremt_paramedic_prep/providers/categories.dart';
import 'package:nremt_paramedic_prep/providers/question_count.dart';
@stargazing-dino
stargazing-dino / document.dart
Created May 19, 2021 19:18
A wrapper around a document reference to be used with Firebase
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'document.freezed.dart';
typedef RestoreData<T> = Future<void> Function();
/// To generate updated model code, run:
/// flutter pub run build_runner build
@freezed
@stargazing-dino
stargazing-dino / icu_parser.dart
Created March 6, 2021 02:11
A parser for ICU style messages
// This file incorporates work covered by the following copyright and
// permission notice:
//
// Copyright 2013, the Dart project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
@stargazing-dino
stargazing-dino / message_format.dart
Created March 6, 2021 02:05
The message format for ICU and arb
enum ElementType { literal, argument, plural, gender, select }
class BaseElement {
final ElementType type;
final String value;
const BaseElement(this.type, this.value);
}
@stargazing-dino
stargazing-dino / combine_async.dart
Created January 9, 2021 20:22
Combines AsyncValues for use with Riverpod
import 'package:hooks_riverpod/all.dart';
import 'package:tuple/tuple.dart';
AsyncValue<Tuple2<T, R>> combineAsync2<T, R>(
AsyncValue<T> asyncOne,
AsyncValue<R> asyncTwo,
) {
if (asyncOne is AsyncError) {
final error = asyncOne as AsyncError<T>;
return AsyncError(error.error, error.stackTrace);
@stargazing-dino
stargazing-dino / pytorch_vision_spacy_torchtext_jetson_nano.sh
Created August 24, 2020 04:20 — forked from lucidbeaming/pytorch_vision_spacy_torchtext_jetson_nano.sh
Installing PyTorch, torchvision, spaCy, torchtext on Jetson Nanon [ARM]
#!/bin/bash
# This script will install pytorch, torchvision, torchtext and spacy on nano.
# If you have any of these installed already on your machine, you can skip those.
# Tailored for virtual environments created with python3 -m venv [name]
if [ -z ${VIRTUAL_ENV+x} ]
then
echo "Not in a virtual environment"