Skip to content

Instantly share code, notes, and snippets.

@fisherds
fisherds / matching_game_tests.dart
Created September 19, 2023 13:17
My unit testing file for Matching Game
import 'package:exam1_emoji_matching/emoji_matching_game.dart';
import 'package:test/test.dart';
void main() {
late MatchingGame game3;
late MatchingGame game5;
late MatchingGame game10;
setUp(() {
game3 = MatchingGame(3);
game10 = MatchingGame(10);
@fisherds
fisherds / tic_tac_toe_game_test.dart
Last active September 8, 2023 02:24
Unit testing for the Tic-Tac-Toe model object
import "package:test/test.dart";
import "tic_tac_toe_game.dart";
void main() {
late TicTacToeGame game;
setUp(() {
game = TicTacToeGame();
});
test("Initial Game", () {
expect(game.state, equals(TicTacToeState.xTurn));
@fisherds
fisherds / rosefire.min.js
Created July 22, 2023 02:33
A file for using the Rosefire api for Rose-Hulman login
! function (e) {
var n = function (e) {
var n = e.split(".")[1];
if (n = JSON.parse(atob(n)), n.d) n = n.d;
else {
var r = n.uid;
n = n.claims, n.uid = r
}
return {
token: e,
@fisherds
fisherds / rosegraphics.py
Created April 6, 2023 18:54
Graphics helper library
"""
rosegraphics.py - a simple Graphics library for Python.
Its key feature is:
-- USING this library provides a simple introduction to USING objects.
Other key features include:
-- It has a rich set of classes, methods and instance variables.
In addition to classes like Circles that are natural for students,
it has other kinds of classes like RoseWindow and SimpleTurtle
@fisherds
fisherds / rosegraphics.py
Created March 2, 2023 19:07
Helper library used at Rose-Hulman for simple graphics
"""
rosegraphics.py - a simple Graphics library for Python.
Its key feature is:
-- USING this library provides a simple introduction to USING objects.
Other key features include:
-- It has a rich set of classes, methods and instance variables.
In addition to classes like Circles that are natural for students,
it has other kinds of classes like RoseWindow and SimpleTurtle
@fisherds
fisherds / firestore_model_utils.dart
Created January 13, 2023 15:08
I've been using this utility file to make getting fields un-crashable.
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
class FirestoreModelUtils {
// A few date time helpers that really don't belong here, but it's easy:
static DateTime fromTimestampToDateTime(Timestamp value) => value.toDate();
static Timestamp fromDateTimeToTimestamp(DateTime value) =>
Timestamp.fromDate(value);
static TimeOfDay fromDateTimeToTimeOfDay(DateTime value) {
DateTime epochDate = DateTime(1970, 1, 1, 0, 0);
// One possible solution
enum TicTacToeMark { none, x, o }
enum TicTacToeState { xTurn, oTurn, xWon, oWon, tie }
class TicTacToeGame {
var board = List<TicTacToeMark>.filled(9, TicTacToeMark.none);
var state = TicTacToeState.xTurn;
void pressedSquare(int index) {
// These methods could be added to your existing class.
/**
* Read button - Gets the state of the fake pushbutton (0 or 1)
* method: GET
* path: /api/readbutton
* expected request body: none
* side effects: none (the pushbutton is always random)
* response: {"button": 0} or {"button": 1}
*/
@fisherds
fisherds / main.js
Last active February 14, 2022 05:04
Code for the main.js starting point in the Pi Simulator
var rhit = rhit || {};
rhit.PiSimulatorController = class {
constructor() {
// No separate model object. Just do it within the controller.
this.button = 1;
this.leds = {red: 0, yellow: 1, green: 0};
this.servos = [-45, 0, 90];
@fisherds
fisherds / main.css
Created February 14, 2022 04:34
CSS file that goes along with the Pi Simulator given index.html file.
body {
background: #DDDDDD;
}
.navbar {
background-color: #800000;
color: white;
}
.page-container {