Skip to content

Instantly share code, notes, and snippets.

View hasenbanck's full-sized avatar

Nils Hasenbanck hasenbanck

  • Hamburg, Germany
View GitHub Profile
@hasenbanck
hasenbanck / gist:31f74926b92c3abf01944911adeb99fd
Created May 23, 2017 05:38 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
@hasenbanck
hasenbanck / gist:1e40681b7d74e942a0dd21de8d97bc5e
Created August 8, 2018 06:53
How to use the Backup SRAM of a STM32F7 / STM32
This might also work for other STM32 chips. I use the HAL, so it also might be supported by your chip.
To use the Backup SRAM (most of the time 4 Kb), you need to add a backup power source (like a battery or a supercap)
to the VBAT pin of your STM32. I use a simple CR2032 battery.
Use following code to get access to the Backup SRAM:
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWR_EnableBkUpAccess();
__HAL_RCC_BKPSRAM_CLK_ENABLE();
@hasenbanck
hasenbanck / bash output
Last active June 11, 2020 11:27
Instanced rendering with vertex arrays
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Stage { flag: VERTEX, error: Input { location: 4, error: WrongType } }', C:\Users\Username\.cargo\git\checkouts\wgpu-rs-40ea39809c03c5d8\7b866b1\src\backend\direct.rs:460:9
@hasenbanck
hasenbanck / upsert_for_hecs.rs
Created July 6, 2020 16:39
Simple `upsert` implementation for the rust ECS hecs
/// Trait to extend hecs to support upsert operations.
/// ```rust
/// use Upsert;
/// let mut world = hecs::World::new();
/// struct s(u32);
///
/// world.upsert(player_entity, |mut c| c.0 = 42, s(42))?;
/// ```
pub trait Upsert {
fn upsert<F, T: 'static>(&mut self, entity: Entity, update: F, insert: T) -> Result<()>
@hasenbanck
hasenbanck / intersection.wgsl
Last active October 28, 2024 11:04
very fast cone / sphere intersection test
/// While implementing a tile based light culling shader, I stumbled uppon the bachelor thesis from Jonathan W. Hale:
/// "Dual-Cone View Culling for Virtual Reality Applications" (2018). While lookin at his final version, I
/// realized that his code could be even further simplified, if the cone's tip is the origin of the coordinate system.
/// By creating a "world to cone view space" transformation matrix, that aligns the code to the positive +Z axis and
/// also set's the cone's tip as the origin, this matrix can then be used to transform the world coordinates into the
/// "cone view space". The following code uses a left handed coordinate system.
/// The test itself only uses 10 instructions:
///
/// - 2 scalar multiplications
/// - 2 additions