Skip to content

Instantly share code, notes, and snippets.

View aperezdc's full-sized avatar
🛋️
Couch-potatoing

Adrian Perez aperezdc

🛋️
Couch-potatoing
View GitHub Profile
@aperezdc
aperezdc / unwindtest.c
Created October 17, 2017 15:18
Example on how to dump stack trace on SIGUSR2, useful if program gets stuck
/*
* unwindtest.c
* Copyright (C) 2017 Adrian Perez <aperez@igalia.com>
*
* Distributed under terms of the MIT license.
*/
#define _GNU_SOURCE
#include <ucontext.h>
#include <dlfcn.h>
@aperezdc
aperezdc / local.conf
Created March 13, 2023 10:08
Patch to build meta-webkit with WPE WebKit 2.39.91 and Cog 0.17.1
# To be added in the local.conf file for a configured Yocto build
EXTRA_IMAGE_FEATURES += "debug-tweaks tools-profile"
INHIBIT_PACKAGE_STRIP = "1"
PREFERRED_VERSION_cog = "0.17.%"
PREFERRED_VERSION_wpewebkit = "2.39.%"
PACKAGECONFIG:pn-wpewebkit:append = " mediastream mediasource"
PACKAGECONFIG:pn-wpewebkit:remove = "experimental-features"
@aperezdc
aperezdc / apicall.js
Created March 6, 2023 11:38
Injected script to use Promise-based async calls with WebKit user script message handlers
// SPDX-License-Identifier: MIT
(function (_console, _window, _Map, _Promise) {
"use strict";
let currentTxnId = 0;
const txnMap = new _Map();
const warning = _console.warn;
function makeTxnId() {
@aperezdc
aperezdc / minicog.c
Last active March 6, 2023 11:23
Minimal WPE launcher, with user message handler to poweroff/reboot a device
/*
* SPDX-License-Identifier: MIT
*
* cc -o minicog minicog.c $(pkg-config wpe-webkit-1.1 cogcore --cflags --libs)
*/
#include <cog/cog.h>
#include <sys/reboot.h>
static const char *s_starturl = NULL;
@aperezdc
aperezdc / minicog-urihandler-cors.c
Last active March 5, 2023 23:31
Minimal WPE launcher
/*
* SPDX-License-Identifier: MIT
*
* cc -o minicog minicog.c $(pkg-config wpe-webkit-1.1 cogcore --cflags --libs)
*/
#include <cog/cog.h>
static const char *s_starturl = NULL;
@aperezdc
aperezdc / minicog.c
Created March 2, 2023 14:49
Minimal WPE launcher using libcogcore
/*
* SPDX-License-Identifier: MIT
*
* cc -o minicog minicog.c $(pkg-config wpe-webkit-1.1 cogcore --cflags --libs)
*/
#include <cog/cog.h>
static const char *s_starturl = NULL;
@aperezdc
aperezdc / lpegxml.lua
Last active September 26, 2022 18:21
Fairly complete LPeg grammar for parsing XML
--
-- LPeg-based XML parser.
--
-- * Grammar term names are the same as in the XML 1.1
-- specification: http://www.w3.org/TR/xml11/
-- * Action functions are missing.
--
-- Copyright (C) 2012 Adrian Perez <aperez@igalia.com>
-- Distribute under terms of the MIT license.
--
@aperezdc
aperezdc / aur-muon-meson-bootstrap.diff
Last active December 21, 2021 08:58
Make AUR package meson-muon-git bootstrap instead of using Ninja
commit be9c283f963b844bd71d9735ac1707ec4c28395e
Author: Adrian Perez de Castro <aperez@igalia.com>
Date: Sun Nov 14 23:04:49 2021 +0200
Local changes
diff --git a/PKGBUILD b/PKGBUILD
index 8b663ef..8a73fcd 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@aperezdc
aperezdc / 00-HOWTO.md
Last active January 30, 2021 20:58
How to patch DB Set XL to work on arctic climate

DB Set XL on Arctic

This shows how to patch DB Set XL v0.82 so it won't disable itself when starting a game in arctic climate. The resulting patched file was tested with OpenTTD.

Requisites

  • Original dbsetxlw.grf, downloadable from here
  • grfcodec
  • patch
@aperezdc
aperezdc / atomic.h
Created October 11, 2014 12:55
Replacement for the Linux kernel asm/atomic.h header using GCC built-ins
#ifndef _ATOMIC_H
#define _ATOMIC_H
/* Check GCC version, just to be safe */
#if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC_MINOR__ < 1)
# error atomic.h works only with GCC newer than version 4.1
#endif /* GNUC >= 4.1 */
/**