Skip to content

Instantly share code, notes, and snippets.

View Levi-Lesches's full-sized avatar

Levi Lesches Levi-Lesches

View GitHub Profile
@Levi-Lesches
Levi-Lesches / schedule_search.dart
Created March 3, 2020 22:48
Searches for class in schedule
void main() {
for (int i = 0; i < 5; i++) {
print('hello ${i + 1}');
}
}
Map<Letters, List<int>> getSubjectInSchedule() {}
class Subject {
@Levi-Lesches
Levi-Lesches / sports_builder_admin.dart
Created February 21, 2020 18:09
Ram Life admin sports builder
import "package:flutter/material.dart";
enum Sport {baseball, basketball, hockey, tennis, volleyball, soccer}
const Map<String, Sport> stringToSports = {
"baseball": Sport.baseball,
"basketball": Sport.basketball,
"hockey": Sport.hockey,
"tennis": Sport.tennis,
"volleyball": Sport.volleyball,
@Levi-Lesches
Levi-Lesches / sports_page.dart
Last active February 21, 2020 03:37
Ram Life Sports Page
import "package:flutter/material.dart";
@immutable
class Time {
/// The hour in 24-hour format.
final int hour;
/// The minutes.
final int minutes;
@Levi-Lesches
Levi-Lesches / lost_and_found.dart
Last active February 20, 2020 16:14
Lost and Found page
import "package:flutter_web/material.dart";
import "package:flutter_web/cupertino.dart";
import "package:flutter_web_ui/ui.dart" as ui;
// Lines like these are comments (only read by people, ignored by computer)
/// Lines like these (three slashes) explain only the class/function/variable right underneath them
// Any part of a comment in [brackets] are either defined here in this file or
// can be searched for at https://api.flutter.dev
@Levi-Lesches
Levi-Lesches / Stocks.dart
Last active February 20, 2020 12:25
Simple stock market code
class Range {
final num buy, sell;
const Range(this.buy, this.sell);
}
Range maxProfit(List<double> points) {
// We want to find a range by examining a list of local minima and maxima
// We can assign a new list (think about what type it would hold) of those minima and maxima
// To find that list, we go through the list of points, two at a time, watching
// for changes in whether the points are increasing or decreasing.
@Levi-Lesches
Levi-Lesches / Sensor.ino
Last active February 20, 2020 05:45
Arduino Ultrasonic sensor
#define echo 2
#define trigger A0
#define threshold 6
long getDistance() {
// This function returns the distance of an object from the sensor in cm
//
// An ultrasonic sensor sends a sound wave pulse outwards, and then waits for it to hit an
// object and bounce back to the sensor.
//
@Levi-Lesches
Levi-Lesches / car_drive.ino
Created January 3, 2020 04:49
A sketch to control an H-Bridge
// These "#define" statements are *like* variables, but not really
// Variables can be changed to any other value, but these cannot
// They don't even stay in memory! What happens is, when you press compile,
// the Arduino replaces all the times the name comes up in the code with the
// value before sending it to the Arduino board. So it's not really a variable
// you can control, but rather just another name for a value.
//
// The define statement looks like this: #define NAME VALUE. Note that NAME can
// not contain spaces, because then it would be interpreted as VALUE.
@Levi-Lesches
Levi-Lesches / tutor.dart
Created February 4, 2020 23:07
RamLife Tutoring data types
enum Subject {history, english} // ...
enum Reviewer {teacher, student}
class User {
String first, last;
int rating;
}
class Tutor extends User {
int yearGraduated;
@Levi-Lesches
Levi-Lesches / nrf.ino
Last active February 20, 2020 05:45
Arduino NRF radio controls
/*
This script is for one NRF to send data to the other. The NRF sending the data
called the server, and the device receiving the data is called the client.
The setup for both devices is the same, the looping is what's different.
Here is a pinout for both devices:
* CE --> 9
* CSN --> 10
* MOSI --> 11