Skip to content

Instantly share code, notes, and snippets.

View trishume's full-sized avatar

Tristan Hume trishume

View GitHub Profile
@nathansobo
nathansobo / log-linear-goto-intuition.md
Last active June 27, 2019 08:11
Intuition for `merge_op` in Raph Levein's GOTO implementation

When merging an operation O, there may be several operations scattered through the local history that are concurrent to O. We need to rearrange our history so that all of these concurrent operations are moved to the end of the history. Then we can transform O against each of these concurrent operations and append it to the end.

Say we're adding O a history with the following suffix. The operations surrounded by vertical bars are concurrent to O. Otherwise the operations causally precede O.

EO0 |EO1| EO2 EO3 |EO4| |EO5| EO6

We need to rearrange this history so it looks like this.

@niklas-ourmachinery
niklas-ourmachinery / identifying-controls-in-an-imgui.md
Last active January 24, 2023 06:09
Identifying controls in an IMGUI

Identifying controls in an IMGUI

In an IMGUI we need a way to identify which control is active or hot. For example, when we press a key, which text box does the text go to.

Possible options:

  1. Sequential number (Unity)

Each control drawn gets a sequentially increasing number.

// frontend with abstract backend
void parse_expr(expr_t *expr);
void parse_base_expr(expr_t *expr) {
if (token == NUMBER) {
do_number_expr(expr, token_value);
next_token();
} else if (match_token('(')) {
parse_expr(expr);
@sagacity
sagacity / main.rs
Created July 25, 2017 15:46
A draft of the weld component system
use std::collections::HashMap;
use std::rc::Rc;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct Component {
events: HashMap<Event, Box<StateCallback>>,
children: Vec<Component>,
}
#pragma comment(lib, "SDL2")
#pragma comment(lib, "SDL2main")
#include "SDL.h"
#include <vector>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
@robinst
robinst / gh-releases-to-changelog.sh
Created September 8, 2017 05:49
Commands to help convert GitHub releases to CHANGELOG.md
# Get releases for your repository (change the URL and add user/password if necessary)
# If there's more than one page, you might have to do more requests with `?page=2` etc
curl https://api.github.com/repos/:owner/:repo/releases > releases.json
# Use jq! https://stedolan.github.io/jq/
# "v" is a prefix to strip from the release names, might not be necessary
jq -r '.[] | "## [" + (.name | ltrimstr("v")) + "] - " + .created_at[:10] + "\n" + .body' releases.json >> CHANGELOG.md
# Now edit the CHANGELOG.md, see here: http://keepachangelog.com/en/1.0.0/
// works as of 2019-03-02
(function() {
// This function forces rustdoc to collapse documentation for all items,
// except for the methods defined in an impl block and the primary type's
// declaration. This is the most natural view IMO, since it provides the
// primary type along with an easy to scan overview of available methods.
//
// rustdoc does seemingly have user settings that purport to make this the
// default, but I could never cause them to work in a reliably consistent
// way. This is especially useful when writing documents, where you commonly
@fabiovila
fabiovila / mcpwm.c
Last active March 28, 2024 11:05
How sync ESP32 Timers MCPWM?
// CHANGE the clock prescale in mcpwm.c file to make possible get 30000hz of pwm frequency (15Khz in center aligned mode)
#define MCPWM_BASE_CLK (2 * APB_CLK_FREQ) //2*APB_CLK_FREQ 160Mhz
#define MCPWM_CLK_PRESCL 1 //MCPWM clock prescale Original = 15 <---------------------
#define TIMER_CLK_PRESCALE 1 //MCPWM timer prescales Original = 9 <---------------------
#define MCPWM_CLK (MCPWM_BASE_CLK/(MCPWM_CLK_PRESCL +1))
#define MCPWM_PIN_IGNORE (-1)
#define OFFSET_FOR_GPIO_IDX_1 6
#define OFFSET_FOR_GPIO_IDX_2 75