Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Nollie Nolence

🏠
Working from home
View GitHub Profile
@Nolence
Nolence / app.dart
Created Sep 1, 2021
Some unconnected router setup
View app.dart
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,
@Nolence
Nolence / lazy_list_builder.dart
Created Jul 7, 2021
a two way pagination builder for flutter Listviews
View lazy_list_builder.dart
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,
@Nolence
Nolence / playground.ts
Created Jun 23, 2021
Changes the text of questions
View playground.ts
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();
View playground.ts
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();
View simulator_card.dart
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';
@Nolence
Nolence / document.dart
Created May 19, 2021
A wrapper around a document reference to be used with Firebase
View document.dart
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
@Nolence
Nolence / icu_parser.dart
Created Mar 6, 2021
A parser for ICU style messages
View icu_parser.dart
// 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.
@Nolence
Nolence / message_format.dart
Created Mar 6, 2021
The message format for ICU and arb
View message_format.dart
enum ElementType { literal, argument, plural, gender, select }
class BaseElement {
final ElementType type;
final String value;
const BaseElement(this.type, this.value);
}
@Nolence
Nolence / combine_async.dart
Created Jan 9, 2021
Combines AsyncValues for use with Riverpod
View combine_async.dart
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);
@Nolence
Nolence / pytorch_vision_spacy_torchtext_jetson_nano.sh
Created Aug 24, 2020 — forked from lucidbeaming/pytorch_vision_spacy_torchtext_jetson_nano.sh
Installing PyTorch, torchvision, spaCy, torchtext on Jetson Nanon [ARM]
View pytorch_vision_spacy_torchtext_jetson_nano.sh
#!/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"