Skip to content

Instantly share code, notes, and snippets.

View sujang958's full-sized avatar
✏️
Lethargic, Aimless, and Hopeless

Songhun Cho sujang958

✏️
Lethargic, Aimless, and Hopeless
View GitHub Profile
@zbraniecki
zbraniecki / README.md
Last active July 14, 2024 08:01
Rust <--> C/C++ FFI for newbies

As Gecko is moving toward more Rust code, the cases where Rust and C code interoperate will become more common.

This document is an attempt to ease the learning curve for engineers facing it for the first time. It assumes no prior experience with cross-language C interfaces (called FFI).

It also assumes that Rust code is already built into Gecko. If you need help with that, read Introducing Rust code in Firefox.

What can you transfer across the fence

// Simple example code to load a Wav file and play it with WASAPI
// This is NOT complete Wav loading code. It is a barebones example
// that makes a lot of assumptions, see the assert() calls for details
//
// References:
// http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html
// Handmade Hero Day 138: Loading WAV Files
#include <windows.h>
@sujang958
sujang958 / main.ts
Created February 27, 2023 11:16
Tauri remember a window's position in TypeScript
import { LogicalPosition, appWindow } from "@tauri-apps/api/window"
appWindow.onMoved((position) => {
localStorage.setItem(
POSITION_KEY,
JSON.stringify({
x: position.payload.x,
y: position.payload.y,
})
)
// page.tsx
import PaginationControls from '@/components/PaginationControls'
import Image from 'next/image'
const data = [
'entry 1',
'entry 2',
'entry 3',
'entry 4',