Skip to content

Instantly share code, notes, and snippets.

@cwoffenden
cwoffenden / dawn-linux.md
Created February 17, 2022 17:16
Building Dawn/WebGPU for Linux/Power9

Dawn Linux

Work-in-progress and notes for building Dawn for Linux on Power9 (x64 should be easier). Tested on Debian Bullseye.

  1. Depot Tools doesn't work, so CMake appears to be the only way. If this is of further interest Depot Tools fails because some prebuilt binaries aren't available for ppc64le (some are, some are out of date, and some are missing). Building gn manually (see building Chrome) then setting DEPOT_TOOLS_UPDATE=0 allows gn to generate the build scripts but this was still failing. CMake works so don't try any further.
  2. Install all the depdendencies. The ones to build Chrome were already added but also: sudo apt install libx11-dev xcb libxcb-xcb-dev x11-xkb-utils libx11-xcb-dev.
  3. GCC will build but with warnings (mostly ABI changes but also the UNREACHABLE() macro usage needs slightly reworking do be GCC friendly) so install Clang (which is what Dawn is developed with anyway).
  4. Clang needs setting as the default c
const { dirname, sep, join, resolve } = require('path')
const { build } = require('esbuild')
const { readFile } = require('fs/promises')
// TODO: Check how to solve when [dir] or [hash] are used
function pinoPlugin(options) {
options = { transports: [], ...options }
return {
name: 'pino',
@thomaspoignant
thomaspoignant / Makefile
Last active August 5, 2025 19:25
My ultimate Makefile for Golang Projects
GOCMD=go
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
BINARY_NAME=example
VERSION?=0.0.0
SERVICE_PORT?=3000
DOCKER_REGISTRY?= #if set it should finished by /
EXPORT_RESULT?=false # for CI please set EXPORT_RESULT to true
GREEN := $(shell tput -Txterm setaf 2)
@ccwasden
ccwasden / WithPopover.swift
Created February 5, 2020 13:39
Custom size popover in iOS SwiftUI
// -- Usage
struct Content: View {
@State var open = false
@State var popoverSize = CGSize(width: 300, height: 300)
var body: some View {
WithPopover(
showPopover: $open,
popoverSize: popoverSize,
@ansrivas
ansrivas / implementation.rs
Created January 28, 2020 21:30
Rust tokio-postgres example custom ToSql and FromSql implementation
use postgres_types::{Type, ToSql, FromSql, IsNull, to_sql_checked};
use bytes::BytesMut;
use std::error::Error;
#[derive(Debug)]
struct RawValue<'a> {
type_: Type,
raw: Option<&'a [u8]>,
}
@CatsMiaow
CatsMiaow / base62-bigint.ts
Last active June 1, 2024 11:30
BigInt Base62 Encoding
import * as assert from 'assert';
/**
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt
*/
export class Base62 {
private readonly base: bigint = BigInt(62);
private readonly charset: string[] = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
public encode(integer: string): string {
@gaearon
gaearon / uselayouteffect-ssr.md
Last active May 2, 2025 03:01
useLayoutEffect and server rendering

If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.

You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.

Option 1: Convert to useEffect

If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.

function MyComponent() {
/*
Adapted from https://github.com/sindresorhus/github-markdown-css
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@mersinvald
mersinvald / singleton.rs
Created November 12, 2018 14:21
Mutexed singleton example in Rust
use lazy_static::lazy_static;
use std::sync::{RwLock, Mutex};
use std::cell::Cell;
lazy_static! {
static ref SINGLETON: Mutex<Option<Singleton>> = Mutex::new(None);
}
#[derive(Debug, PartialEq)]
struct Singleton {
function toBaseN(num, base) {
if (num === 0) {
return '0';
}
var digits = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
var len = Math.min(digits.length, base);
var result = '';
while (num > 0) {
result = digits[num % len] + result;
num = parseInt(num / len, 10);