Skip to content

Instantly share code, notes, and snippets.

View Jacoby6000's full-sized avatar

Jacob Barber Jacoby6000

  • Plano, TX
View GitHub Profile
@Jacoby6000
Jacoby6000 / CurriedFunc.cs
Last active December 12, 2024 17:29
Curried Func vs SAM interface
public class ModdedChivalry2LauncherFactory {
public static Func<ModdedLaunchOptions, IEnumerable<string>, Either<ProcessLaunchFailure, Process>> CreateDefaultLauncher(IProcessLauncher, launcher, string workdir, IModManager modManager) => (moddedLaunchOpts, args) => {
// ... impl ...
}
}
public class SomeViewModel {
// ...
private Func<ModdedLaunchOptions, IEnumerable<string>, Either<ProcessLaunchFailure, Process>> Launcher { get; }

Requirements/Descriptions

  • An EON
    • The brains of openpilot, contains an LeEco LE Pro 3 with firmware that allows it to run openpilot and the battery removed
    • Should have a heat sink and fan on the rear
    • May/May not have IR LEDs and IR Filter removed from the front facing camera.
  • A connector
    • The connector intercepts signals on CAN and feeds it to the harness box
    • Connectors vary, even among the same manufacturer
  • A harness box
import requests
# max_records is there so you can get back partial result sets, if you want. Useful for testing.
def get_all_course_data(max_records=None):
page_number = 1
page_size = 100
more_records_exist = True
all_courses = []
while more_records_exist:
@Jacoby6000
Jacoby6000 / 0-observations.md
Last active October 8, 2018 20:46
Boolean logic with Recusion Schemes and hand-written interpreters.

Pros for recusion schemes

More fold methods: cata, cataM, gcata, gcataM, hylo, hyloM, ghylo, ghyloM, histo, histoM, ghisto, ghistoM, and more.

Easier to maintain; adding nodes means you just have to update your algebras and your functor instance. With the hand-written ones you’d have to update each of those methods, as well as your algebras.

If you want to mix together/extend the ADT, you can do so using a simple coproduct (like Either)

trait MathProvider[A] {
def plus(a: A, b: A): A
def minus(a: A, b: A): A
def divide(a: A, b: A): A
def multiply(a: A, b: A): A
}
Miss Bell
Lars Hupel
John DeGoes
Tony Morris
Emily Pilmore

BNF Grammar of Regular Expressions

Following the precedence rules given previously, a BNF grammar for Perl-style regular expressions can be constructed as follows.

  • <RE> ::= <union> | <simple-RE>
  • <union> ::= <RE> "|" <simple-RE>
  • <simple-RE> ::= <concatenation> | <basic-RE>
  • <concatenation> ::= <simple-RE> <basic-RE>
  • <basic-RE> ::= <star> | <plus> | <elementary-RE>
  • <star> ::= <elementary-RE> "*"
  • ::= "+"
import cats.implicits._
import cats.{FlatMap, Monad, Applicative, Apply, Functor}
/**
* A concretion/simplification of StateT for logging.
*/
class LoggerT[F[_], Ctx, A](val run: F[(Ctx, A)]) {
def value(implicit: F: Functor[F]): F[A] = run.map(_._2)
def context(implicit: F: Functor[F]): F[A] = run.map(_._1)
package scalaxb
import scala.xml.{Node, NodeSeq, NamespaceBinding, Elem, UnprefixedAttribute, PrefixedAttribute}
import javax.xml.datatype.{XMLGregorianCalendar}
import javax.xml.namespace.QName
import javax.xml.bind.DatatypeConverter
import scala.language.postfixOps
import scala.language.implicitConversions
import scala.language.existentials
case class Foo(a: Int, b: String, c: Bar)
case class Bar(x: Int, y: Baz)
case class Baz(z: String)
// Each case class can be generalized in to a product, where that product is just the parts of the case class
// Foo === Int :: String :: Bar :: HNil
// Bar === Int :: Baz :: HNil
// Baz === String :: HNil