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 / generate_all_paths.rs
Created April 27, 2024 17:15
Gets all paths of a dialogue
// Untested code!
fn generate_all_paths(
dialogue: &mut Dialogue,
progress: &mut Progress,
) -> Vec<GraphWalk> {
let mut all_paths = Vec::new();
let dialogue_events = match dialogue.continue_() {
Ok(events) => events,
@stargazing-dino
stargazing-dino / our_sort.c
Created July 18, 2022 19:34
sort comparison
uint16_t i = 0, j = 0;
uint32_t tmp = 0;
uint32_t sum = 0;
for (i = 0; i < size - 1; i++)
{
for (j = 0; j < size - 1; j++) // does not use i therefore probably touching the same data in every loop
{
if (dat[j] > dat[j + 1])
{
@stargazing-dino
stargazing-dino / use_undo_redo.dart
Created May 25, 2022 13:50
initial attempt at undo redo state
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:tuple/tuple.dart';
@immutable
class UndoRedoHandler {
const UndoRedoHandler({
required this.resetState,
@stargazing-dino
stargazing-dino / get_status_code_error.dart
Created April 21, 2022 15:11
Returns a string representation for common android status codes
/// Maps an error string to typical `developer` readable error messages.
/// See [getStatusCodeError]. For android only.
String _errorToHumanReadable(String errorMessage) {
final exp = RegExp(r':\s([0-9]+):');
final match = exp.firstMatch(errorMessage);
if (match == null) {
return errorMessage;
} else {
final group = match.group(1);
@stargazing-dino
stargazing-dino / yo.md
Created March 7, 2022 21:20
geometry nodes boolean'd mesh alternative

boolean'ing a mesh doesn't give proper results without high enough resolution (without some kind of threshold value addition).

@stargazing-dino
stargazing-dino / main.dart
Created February 24, 2022 20:21
Retrieve the user ids of those whose ages are an even number
import 'package:collection/collection.dart';
// Given an array of User HashMaps with keys of Id and Age,
// write in Dart the code to return an array of User Ids for
// users whose Age is an even number. Make the code as efficient and terse as possible.
List<int> evenAgedUserIds(List<Map<String, dynamic>> usersEntries) {
return usersEntries
// ignore: avoid_dynamic_calls
.where((userEntry) => userEntry['age'] % 2 == 0)
.map((userEntry) => userEntry['id'] as int)
@stargazing-dino
stargazing-dino / firebase_image_builder.dart
Created October 22, 2021 19:13
Lets user build an arbitrary image uploader and viewer
import 'dart:async';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:firebase_storage_hooks/firebase_storage_hooks.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_cache_manager_firebase/flutter_cache_manager_firebase.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
@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();