Skip to content

Instantly share code, notes, and snippets.

@menduz
menduz / actionlist.vim
Created April 19, 2024 13:22 — forked from zchee/actionlist.vim
IdeaVim actionlist
--- Actions ---
$Copy <M-C>
$Cut <M-X> <S-Del>
$Delete <Del> <BS> <M-BS>
$LRU
$Paste <M-V>
$Redo <M-S-Z> <A-S-BS>
$SearchWeb <A-S-G>
$SelectAll <M-A>
$Undo <M-Z>
@menduz
menduz / gi.c
Created December 6, 2023 20:33 — forked from futureengine2/gi.c
Radiance Cascades 2d GI implementation
static void gi_on_gpu(u8* in_bitmap, int w, int h) {
#define num_cascades 7
static bool initialized;
static gpu_bindgroup_t texture_bindgroup[2];
static gpu_bindgroup_t cascade_uniform_bindgroup[num_cascades];
static gpu_bindgroup_t render_uniform_bindgroup;
static gpu_buffer_t vertex_buffer;
static gpu_buffer_t uniform_buffer;
static gpu_pipeline_t pipeline;
@menduz
menduz / build.zig
Last active September 20, 2023 20:16
zig dependency checker
const DependencyChecker = struct {
/// map(module_name -> set(module_hash))
package_name_to_hashes: std.StringHashMap(std.StringHashMap(bool)),
const Self = @This();
const dependencies = @import("root").dependencies;
fn check_transitive_dependency(self: *Self, comptime module_name: []const u8, comptime module_hash: []const u8, comptime level: comptime_int) void {
const package = @field(dependencies.packages, module_hash);
const BITS = 32
export function queryBit(data: Uint32Array, index: number) {
const mask = 1 << (index % BITS)
return (data[(index / BITS) | 0] & mask) != 0
}
export function turnOnBit(data: Uint32Array, index: number) {
const mask = 1 << (index % BITS)
return (data[(index / BITS) | 0] |= mask)
}
Use cases:
- Edition mode, needs component schemas and IDs
```
entity0: {
position: { x y z }
}
```
- If the devs define the component number, libraries may have conflicting numbers
export function asnEcdsaSignatureParser(signature: Uint8Array): {
r: BigNumber
s: BigNumber
} {
// 30 — type tag indicating SEQUENCE
// 46 — length in octets of value that follows
// 02 — type tag indicating INTEGER
// 21 — length in octets of value that follows
// 00 b15232269023d8c65689f816996f6af874b484347f1e7a537df1230cb1b12d76 R
import { ILoggerComponent, IMetricsComponent } from '@well-known-components/interfaces'
import { validateMetricsDeclaration } from '@well-known-components/metrics'
import PQueue from 'p-queue'
export type ISequecuentialJobExecutorComponent = {
/**
* Runs sequential jobs with a max concurrency of 1 per jobName.
*/
run<T>(jobName: string, fn: () => Promise<T>): Promise<T>
}
@menduz
menduz / game.ts
Last active February 3, 2021 14:04
loading kernel modules from Decentraland's SDK scene
executeTask(async () => {
const module = await dcl.loadModule('@decentraland/CommunicationsController')
const rpcResult = await dcl.callRpc(module.rpcHandle, 'send' /* remote method */, [message /* argument list */])
/**
The code avobe is the same as:
import {send} from "@decentraland/CommunicationsController"
@menduz
menduz / readme.md
Last active January 22, 2021 15:23
Unified NFT naming for blockchain based Metaverses

A common way to refer to assets across the metaverse projects

Identifying a blockchain asset is difficult. Wallets, exchanges, tools and other pieces of software need to know the specifics about how to interact with the project's infrastructure to get images or to render content. This proposal shows a temptative solution to the content addressing mechanisms to embed our crypto-art, assets, wearables and avatars into metaverse(s).

URN

@menduz
menduz / url-parser.ts
Last active January 5, 2021 16:03
url-parser-types.ts
/**
* Creates object types compliant with https://github.com/pillarjs/path-to-regexp
*
* ParseUrlParams<"/users/:user_id/:test+"> = { user_id: string, test: string | string[] }
*
* @public
*/
export type ParseUrlParams<State extends string, Memo extends Record<string, any> = {}> = string extends State
? ParseUrlParams.ParserError<"ParseUrlParams got generic string type">
: State extends `${infer _}:${infer Rest}`