Skip to content

Instantly share code, notes, and snippets.

View ErnWong's full-sized avatar
🦆

Ernest Wong ErnWong

🦆
View GitHub Profile

Disclaimer: I have no idea what I'm doing. This gist is a scratchpad for me to hopefully one make sense of things. Expect nonsensical notes jotted on this page.

@ErnWong
ErnWong / gui-library-considerations.md
Last active March 22, 2023 07:35
GUI library considerations
  • Drawing:
    • Coordinate System: Pixels, logical pixels, dpi scaling, device-independent pixels, inches, logical inches, dpi logical dpi, points, zoom,
    • Color:
      • rgb, hsv, hsl, etc
      • Colorspaces: Device independent (e.g. sRGB), Deviced dependent (monitor specific)
      • Gamma, linear colorspace
      • High dynamic range, tone-mapping
    • Blending:
      • blend modes
  • Blending in the right colorspace https://observablehq.com/@mootari/color-blending-is-broken

Awesome List of Rust Footguns

This will be a living document where I will ocassionally add new "gotchas" I discover with Rust. Do note that I am still learning Rust. I mean, who isn't?

Drops are not guaranteed

8 May 2021.

Dear diary,

@ErnWong
ErnWong / thicc idris types.md
Created December 12, 2022 06:51
Thicc Idris Types
Main> :r
1/1: Building src.Main (src/Main.idr)
Loaded file src/Main.idr
Main> :ti todo
   input : List Nat
   x : ErasedThing (Equal {a = Nat} {b = Nat} (.fst {type = Nat} {pred = \returnValue : Nat =>
 Equal {a = Nat} {b = Nat} returnValue (foldr {acc = Nat} {elem = Nat} maximum 0 (reverseOnto {a = Nat} ([] {a = Nat}) input))} (let Element {type = returnOut} {pred = \returnValue : returnOut =>
                                                                                                                                       ComposedReturnProof {returnOut} {streamOut = Void} {streamIn = Void} {streamMid = streamIn} {returnMid = ()} (fromListReturnInvariant {streamOut = streamIn} list) (ExhaustsInputAnd {returnOut} {streamOut = Void} {streamIn} returnInvariant) (Yes () ()) ([] {a = Void}) ([] {a = Void}) returnValue} returnValue proofs =
                                                                                                                                       .runIdentity {a = Subset Nat (\ret
namespace thisWorks
testMyErased : Exists {type = (Nat, String)} (\y => (String, (Nat, Nat)))
0 testMyUse : String
testMyUse = Builtin.fst $ snd $ testMyErased
0 testMyUse2 : (Nat, Nat)
testMyUse2 = Builtin.snd $ snd testMyErased
error[E0599]: no function or associated item named `generatee_random` found for struct `ConsCell` in the current scope
--> src/main.rs:803:36
|
66 | struct ConsCell<ElementType, TypeListType: TypeList>(ElementType, TypeListType);
| ---------------------------------------------------- function or associated item `generatee_random` not found for this struct
...
803 | println!("{}", EnglishGrammar::generatee_random::<Sentence>());
| ^^^^^^^^^^^^^^^^ function or associated item not found in `ConsCell<(Sentence, ConsCell<ConsCell<NounPhrase, ConsCell<VerbPhrase, ConsCell<Terminal<".">, Empty>>>, ConsCell<ConsCell<VerbPhrase, ConsCell<Terminal<".">, Empty>>, ConsCell<ConsCell<AuxiliaryVerb, ConsCell<NounPhrase, ConsCell<VerbPhrase, ConsCell<Terminal<"?">, Empty>>>>, Empty>>>), ConsCell<(ComplementizerPhrase, ConsCell<ConsCell<Complementizer, ConsCell<Sentence, Empty>>, Empty>), ConsCell<(PrepositionalPhrase, ConsCell<ConsCell<Preposition, ConsCell<NounPhrase, E
import java.util.function.Function;
// Learning exercise - porting the following ideas:
// https://github.com/moonad/FormCoreJS/blob/master/FormCore.js
// https://github.com/Soonad/Formality-Core/blob/master/Whitepaper.md
// https://github.com/Kindelia/Kind/blob/master/base/Kind/Core.kind
// https://github.com/yatima-inc/yatima-lang-alpha/blob/main/core/src/term.rs
// TODO
@ErnWong
ErnWong / README.markdown
Last active January 18, 2022 03:35
Git rebase and merge hybrid workflow: git remap

Shower thought: Rebase and merge each have their strengths and weaknesses.

  • Rebase results in a clean, linear history and allows the developer to resolve conflicts within the context of the commit being replayed. Git bisects are also easier Nevermind - apparently, git bisects work with merge-based workflows.
  • Merge never loses the old history, and commits the merging step as if it was a legitiment piece of work and effort that needs to be documented. Indeed, some merges can be non-trivial and resolving conflicts are often cases where bugs are introduced.

Then, why not have a different kind of "merge" command that merges each commit one by one, so that, if you only log the commits from the first parent of every merge commit, you'll get a very clean linear git history, and if you need to, you can traverse throught the merge commit's second parents to look back at the original commits. Here, the merge commits fully describe how the "old" commits map into the "new" commits.

Best of both worlds?

@ErnWong
ErnWong / Version Control Wishlist.markdown
Last active December 4, 2021 06:34
Version Control Wishlist