Skip to content

Instantly share code, notes, and snippets.

View bluca's full-sized avatar

Luca Boccassi bluca

View GitHub Profile
@bluca
bluca / gist:5028bae1768c01d587dabe51f7877750
Created December 16, 2016 16:41
python zmq unit test mock
import zmq
import unittest
from unittest.mock import patch
from unittest.mock import MagicMock
class MockZmqSocket(MagicMock):
def __init__(self, **kwds):
super().__init__(**kwds)
@bluca
bluca / repro.c
Created March 26, 2021 15:46
dwfl crash
#include <dwarf.h>
#include <elfutils/libdwelf.h>
#include <elfutils/libdwfl.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <assert.h>
#include <errno.h>
@bluca
bluca / note.c
Created March 26, 2021 16:08
Get custom note out of core file
#include <dwarf.h>
#include <elfutils/libdwelf.h>
#include <elfutils/libdwfl.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <assert.h>
#include <errno.h>
#include <stdio.h>
@bluca
bluca / gist:1fa56692456a022d411303a33267421d
Created March 26, 2021 16:18
linker script to add custom note to elf - LDFLAGS="-Wl,-T,$PWD/script"
SECTIONS
{
.note.package : ALIGN(4) {
BYTE(0x04) BYTE(0x00) BYTE(0x00) BYTE(0x00) /* Length of Owner including NUL */
BYTE(0x4a) BYTE(0x00) BYTE(0x00) BYTE(0x00) /* Length of Value including NUL */
BYTE(0x00) BYTE(0x33) BYTE(0xdd) BYTE(0x7a) /* Note ID */
BYTE(0x54) BYTE(0x42) BYTE(0x44) BYTE(0x00) /* Owner: 'TBD\x00' */
BYTE(0x7b) BYTE(0x22) BYTE(0x70) BYTE(0x61) /* Value: '{"packageType":"deb","package":"fsverity-utils","packageVersion":"1.3-1"}\x00\x00\x00' */
BYTE(0x63) BYTE(0x6b) BYTE(0x61) BYTE(0x67)
BYTE(0x65) BYTE(0x54) BYTE(0x79) BYTE(0x70)
@bluca
bluca / gist:0158ec50638637749641c269439ee621
Created March 26, 2021 17:00
fast src:linux deb package amd64 build
diff --git a/debian/config/amd64/defines b/debian/config/amd64/defines
index b278f36223c7..d599f68dfe6a 100644
--- a/debian/config/amd64/defines
+++ b/debian/config/amd64/defines
@@ -1,12 +1,13 @@
[base]
featuresets:
none
- rt
+# rt

Keybase proof

I hereby claim:

  • I am bluca on github.
  • I am bluca (https://keybase.io/bluca) on keybase.
  • I have a public key whose fingerprint is A9EA 9081 724F FAE0 484C 35A1 A81C EA22 BC8C 7E2E

To claim this, I am signing this object:

@bluca
bluca / libone.pc
Created October 28, 2021 20:28
circular pkgconfig deps
prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib/x86_64-linux-gnu
includedir=${prefix}/include
Name: libone
Version: 1.0
Description: foo
Libs: -L${libdir} -lone
Cflags: -Done
@bluca
bluca / userctl
Last active August 30, 2023 11:06
bash completion for systemctl --user alias, save as '~/.local/share/bash-completion/completions/userctl'
# user(1) completion -*- shell-script -*-
# SPDX-License-Identifier: LGPL-2.1-or-later
__systemctl() {
local mode=$1; shift 1
systemctl $mode --full --legend=no --no-pager --plain "$@" 2>/dev/null
}
__systemd_properties() {
/usr/lib/systemd/systemd --dump-bus-properties