Skip to content

Instantly share code, notes, and snippets.

<!-- LICSENSE: NC-BY-SA -->
<p>Here are the sites and resources that attendees at the Learn to Code with Us events had found to be the most helpful:</p>
<table class="c11" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<th width="33%">What do you want to do?</th>
<th width="33%">What languages does this use?</th>
<th width="33%">Helpful Beginner Online Resources</th>
</tr>
@carlynorama
carlynorama / Matrix2D.swift
Last active December 13, 2024 22:23
For advent of code 2024 Day13... there is a simpler way! (code is very messy, apologies)
struct MatrixSystem {
//Ax = b
//See also the stand alone. It's faster, I suspect.
static func solveLinearPair(x1:Int, y1:Int, r1:Int, x2:Int, y2:Int, r2:Int) -> (x:Int, y:Int)? {
// x1 y1 X r1
// x2 y2 Y r2
let b = Vector2D(x: r1, y: r2)
@carlynorama
carlynorama / bink_main.s
Created April 14, 2024 22:55
Pulled from bigger project for reference.
.cpu cortex-m0
.fpu softvfp
.thumb
.section .text.program_code
.equ portA_address, 0x41004400
.equ portA_DIRSET, 0x41004400+0x08
.equ portA_OUTTGL, 0x41004400+0x1C
@carlynorama
carlynorama / FixedSizeArray.swift
Last active February 3, 2024 07:09
FixedArray
//
// FixedWidth.swift
// TestingTwo
//
// Created by Carlyn Maw on 2/2/24.
// Inspired by 25:52 of WWDC 2020 "Safely Manage Pointers in Swift."
// In the subscript, using .load(fromByteOffset:as) prevents rebinding of memory for access. This struct can point to memory bound as a different type without overriding.
//TODO: Add tuplebride to help with C
//examples: https://github.com/carlynorama/UnsafeWrapCSampler/blob/main/Sources/Swift/TupleBridge.swift
@carlynorama
carlynorama / AdventOfCode_2023_Day12.swift
Last active December 17, 2023 02:53
Day 12 a la gregtitus. I made a super crazy switch statement in my original code, but when I went back to do the whole memoize dance... someone else had shown you didn't have to! This felt much nicer.
//https://adventofcode.com/2023/day/12
//Based on https://forums.swift.org/t/advent-of-code-2023/68749/61
//Intro video Lydia
//https://www.youtube.com/watch?v=PK3wL7DXuuw
//Compterphile: Computers Without Memory
//https://www.youtube.com/watch?v=vhiiia1_hC4
@carlynorama
carlynorama / String+Int.swift
Last active December 9, 2023 23:18
Int Extraction Sampler
//So MyString[3] just works. Don't use in projects with real input.
extension StringProtocol {
subscript(offset: Int) -> Character {
self[index(startIndex, offsetBy: offset)]
}
}
extension StringProtocol {
//Ignores negative signs.
public extension ClosedRange<Int> {
func crop(by other: ClosedRange<Int>) -> [ClosedRange<Int>] {
//print("cropping...")
guard self.overlaps(other) else {
//return [self]
fatalError("No overlap")
}
print("they overlap")
//
// SwiftUIStyle.swift
//
//
// Created by Carlyn Maw on 8/1/23.
//
import Foundation
//https://talk.objc.io/episodes/S01E225-view-protocols-and-shapes
@carlynorama
carlynorama / vm_setup.sh
Last active July 24, 2023 20:49
Linux-VM History (Labtanza)
sudo apt update
sudo apt upgrade
sudo apt install clang libicu-dev build-essential pkg-config
apt install git gh
apt install libpng-dev
## NOTE THIS WAS DELETED LATER
apt install cmake
mkdir ~/swift