This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def selection_sort_mmix(records): | |
| """ | |
| Sorts a list of records in place using the selection sort algorithm | |
| as described in the MMIX assembly program. | |
| The algorithm finds the maximum element in the unsorted portion | |
| and exchanges it with the element at the current end position (j). | |
| """ | |
| N = len(records) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local function isInGit() | |
| local checkGit = vim.fn.system("git rev-parse --is-inside-work-tree") | |
| return string.find(checkGit, "true", 1, true) == 1 | |
| end | |
| local plugins = { | |
| -- Just an experiment | |
| { "justinhj/whid", | |
| dir = '~/projects/whid', | |
| lazy = false, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Species = 'hobbit' | 'orc' | 'elf' | 'man'; | |
| interface MiddleEarthDenizen { | |
| name: string | |
| species: Species | |
| } | |
| interface Hobbit extends Omit<MiddleEarthDenizen, 'species'> { | |
| burrow: string | |
| species: 'hobbit' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <vector> | |
| #include <ranges> | |
| #include <algorithm> | |
| using namespace std; | |
| class Solution { | |
| public: | |
| string m2(string num1, int multiplier, int zeros) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Follow these instructions after you have Rustup, Scoopy and cmder installed. | |
| https://jrhawley.ca/2020/05/25/rust-toolchain-windows | |
| One extra bit of info is to set the path in cmder follow these instructions | |
| https://jonathansoma.com/lede/foundations-2019/terminal/adding-to-your-path-cmder-win/ | |
| Find msys in the scoop folder and add the path, mine was here... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Found 546487 words in the book | |
| Words with the most uncommon occurence in the English words found on the web | |
| See https://www.kaggle.com/rtatman/english-word-frequency | |
| sibilance (12720) | |
| hubristic (12760) | |
| hellishly (12784) | |
| jerkily (12785) | |
| antimissile (12799) | |
| mildews (12801) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.justinhj | |
| object Scala2WriterTWithCats extends App { | |
| // Implement WriterT using Cats implementation of Monad and Monoids | |
| import cats.{Monad, Monoid} | |
| case class WriterT[F[_]: Monad,W,A](val wrapped: F[(W,A)]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object WriterTest extends App { | |
| trait Semigroup[A]: | |
| def combine(al: A, ar: A): A | |
| object Semigroup: | |
| def apply[A](using s: Semigroup[A]) = s | |
| trait Monoid[A] extends Semigroup[A]: | |
| def zero: A |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.justinhj | |
| object WriterTOldSchool extends App { | |
| import cats.{Monad, Monoid} | |
| case class WriterT[F[_]: Monad,W,A](val wrapped: F[(W,A)]) | |
| implicit def writerTMonad[F[_]: Monad,W: Monoid] = new Monad[WriterT[F,W,?]] { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Macro that crashes the compiler | |
| import scala.quoted._ | |
| def takeOptionImpl[T](o: Expr[Option[T]], default: Expr[T])(using Quotes, Type[T]): Expr[T] = '{ | |
| $o match { | |
| case Some(t1) => t1 | |
| case None: Option[T] => $default | |
| } | |
| } |
NewerOlder