Skip to content

Instantly share code, notes, and snippets.

View ErnWong's full-sized avatar
🦆

Ernest Wong ErnWong

🦆
View GitHub Profile
@ErnWong
ErnWong / zigzag.js
Created July 21, 2019 09:21
Zigzag CSS pattern
function generateZigZag(size, thickness) {
const ratio = (thickness / size / 2) * 100;
const quadrantMain = `transparent ${25 - ratio}%, black ${25 - ratio}%, black 25%, transparent 25%`;
const quadrantTip = `black ${ratio}%, transparent ${ratio}%`;
return {
background: [
`linear-gradient(-45deg, ${quadrantTip}) ${-size}px ${size}px`,
`linear-gradient(-45deg, ${quadrantTip}) 0 ${size}px`,
`linear-gradient(-135deg, ${quadrantTip}) ${-size}px ${-size}px`,
`linear-gradient(-135deg, ${quadrantTip}) 0 ${-size}px`,
@ErnWong
ErnWong / STM_controller.v0.map
Last active November 11, 2019 08:00
BeatBot memory map before optimising for space
Component: ARM Compiler 5.06 update 6 (build 750) Tool: armlink [4d35ed]
==============================================================================
Section Cross References
startup_stm32f103xb.o(RESET) refers to startup_stm32f103xb.o(STACK) for __initial_sp
startup_stm32f103xb.o(RESET) refers to startup_stm32f103xb.o(.text) for Reset_Handler
startup_stm32f103xb.o(RESET) refers to stm32f1xx_it.o(i.NMI_Handler) for NMI_Handler
startup_stm32f103xb.o(RESET) refers to stm32f1xx_it.o(i.HardFault_Handler) for HardFault_Handler
@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

Grid of buttons
That can light up
Behaving like a finite state machine
But obfuscate the state machine logic
In a large neural network
Just for fun
And get the player
To get all buttons lit up
And have lots of fun designing
The CSS and animations

People look at reviews and show ratings for show recommendation
Rating is 1 dimensional
People who like one highly ranked show
May not like another highly ranked show
Some people like watching lowly ranked shows
Not all shows are good because of their
Story-Character-Art-Music combination
Then
Why not
Get users to share what they expect

  • Selection has a cursor
  • Selection has an origin
  • Selection, when dragging, can snap to certain points to select various granularity, such as whole words, whole sentences, etc.
    • Granularity can be specified by a custom getSnapPoints function or something similar.
      • Or infer granularity from single/double/triple click?
    • Preset getSnapPoints functions for common mediums such as text can be provided
    • Selection starts off without snapping, and snapping is only activated once it passes the first snap point.
  • Dragging the selection backwards could still snap, but if the backward motion is slow enough, the selection snapping will be disabled until selection is dragged to the right past a snapping point.
  • When snapping is activated, both the cursor and origin is snapped in opposite directions to extend the selection. Is this a desired user feature?
  • When selection cursor is brought back close to the origin, between the origin and the first snapping point, then snapping is disabled for that d
environment_genome.from_flattened({
'water_genes': [
{
'amount': 2.58712292237539,
'smell_signature': [-0.28899390479502074, -0.00830629590648524, 0.09767028130163857, -0.05182467021560022, 0.7185100142896303]
},
{
'amount': 1.439923830198761,
'smell_signature': [ 0.38302337370748285, -0.617770547361407, 0.8557760937332404, -0.7526113883887016, -0.34273501187112054]
}

Ideally we want the following behaviour:

  • Feel the inertia of the hammer
  • Feel the "bump" as the action mechanism reaches the escapement stage
  • Re-engage above the escapement stage without a full reset
  • The keys should feel lighter when the damper pedal is pressed
  • Key should have an appropriately large radius of rotation as it is pressed so that the effective "weight" is roughly uniform regardless where the key is pressed from.

Essential components:

Tokens From below From horizontal From above To below To horizontal To above
+ Yes ✔️ Yes ✔️ Yes ✔️ Yes ✔️ Yes ✔️ Yes ✔️
< No ❌ Yes ✔️ No ❌ Yes ✔️ Yes ✔️ Yes ✔️
> Yes ✔️ Yes ✔️ Yes ✔️ No ❌ Yes ✔️ No ❌
.,_ Yes ✔️ Yes ✔️ No ❌ Yes ✔️ Yes ✔️ No ❌
'`^* No ❌ Yes :hea