Skip to content

Instantly share code, notes, and snippets.

View aptlyundecided's full-sized avatar
🐧
#PolarTempsWalMartClub

Alex aptlyundecided

🐧
#PolarTempsWalMartClub
View GitHub Profile
@aptlyundecided
aptlyundecided / attach-form-controls.html
Last active May 6, 2023 14:15
some code examples for my angular 15 reactive sandwich form
<form [formGroup]="sandwichForm">
<div>
<mat-form-field appearance="fill">
<mat-label>Sandwich Type</mat-label>
<mat-select [formControlName]="'selectedSandwich'">
<mat-option *ngFor="let food of sandwichTypes" [value]="food.value">
{{food.value}}
</mat-option>
</mat-select>
</mat-form-field>
@aptlyundecided
aptlyundecided / full-example.html
Last active May 6, 2023 13:35
examples of how to get web components working in Square Space
<div>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/aptlyundecided/angular-web-components/bundle/styles.css" onload="this.media='all'"></link>
<script src="https://cdn.jsdelivr.net/gh/aptlyundecided/angular-web-components/bundle/web-components-package_v0.0.1.js" id='myScript'></script>
</div>
@aptlyundecided
aptlyundecided / web-components-example-app.module.ts
Last active May 4, 2023 12:18
Basic example of a working app.module.ts in Angular 15 that produces a bundle that allows other apps to use angular component defined within as a web component.
import { Injector, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { createCustomElement } from '@angular/elements';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { FoodFormComponent } from './components/food-form/food-form.component';
@NgModule({
declarations: [
// This function takes three arguments:
// 1. soil_dryness: A floating-point number representing the current soil dryness level
// 2. dryness_limit: A floating-point number representing the maximum dryness level before the soil is considered too dry
// 3. interlocks: A boolean value representing whether any interlocks are currently engaged
// The function returns a boolean value indicating whether the soil is considered too dry
fn check_soil_dryness(
soil_dryness: f64,
dryness_limit: f64,
interlocks: bool
) -> bool {
#[derive(Debug, PartialEq)]
enum SoilDrynessLevel {
VeryDry,
Dry,
Medium,
Moist,
VeryMoist,
}
struct SystemState {
#[derive(Debug, PartialEq)]
pub enum PVLevel {
VeryLow,
Low,
Medium,
High,
VeryHigh
}
pub struct PVLevelConfig {
@aptlyundecided
aptlyundecided / anon_intro.rs
Last active February 12, 2023 14:56
A bunch of random rust trait stuff; just practicing
fn get_anon_intro<Person, Cat>(t: &Person, u: &Cat) -> String
where
Person: AgeHandler,
Cat: AgeHandler + NameHandler
{
let mut intro = String::new();
intro.push_str("Hello, I am Anonymous and I am ");
intro.push_str(t.get_age().to_string().as_str());
intro.push_str(" years old. I have a cat named ");
intro.push_str(u.get_name());
@aptlyundecided
aptlyundecided / 3_structs.rs
Last active February 10, 2023 12:40
All sortsa junk about Traits
pub struct Person {
first_name: String,
last_name: String,
stickittothemanness: u8,
age: u8,
hp: u8
}
pub struct Dog {
first_name: String,
@aptlyundecided
aptlyundecided / default_impl.rs
Created February 7, 2023 12:48
A default trait implementation vs. a struct instance implementation
asf
@aptlyundecided
aptlyundecided / greeting_node.rs
Last active February 8, 2023 12:07
Compose Instances Right Where They Are Needed with Rust Traits
pub trait GreetingNode {
fn new() -> MenuNode;
fn greet_text(n: &str) -> String;
}
impl GreetingNode for MenuNode {
fn new() -> MenuNode {
MenuNode {
node_id: 300,
next_ref: 0,