Skip to content

Instantly share code, notes, and snippets.

View shaded-enmity's full-sized avatar
🇨🇿
I'm so meta even this acronym ...

Pavel Odvody shaded-enmity

🇨🇿
I'm so meta even this acronym ...
  • Red Hat
  • Brno
View GitHub Profile
@shaded-enmity
shaded-enmity / ret0.sh
Created December 1, 2021 10:29
PLT Hook Patcher
#!/usr/bin/bash
#
# Script to patch PLT hooks so that they return 0 instead of looking up the library function
# Assumptions:
# - Caller expects return value in `rax`
# - Callee has no other side effects
#
# This changes the file in-place, no other runtime work is needed
#
#!/usr/bin/bash
for pkg in $(dnf repoquery -f '/lib/modules/**/*.ko.xz' 2>/dev/null | sort -u); do
echo "Package: $pkg"
dnf repoquery --list $pkg 2>/dev/null\
| grep '.ko.xz$'\
| cut -d/ -f5-\
| xargs -n1 printf ' - %s\n'
done
def compare_dictionaries(a, b):
def mapper(item):
if isinstance(item, list):
return frozenset(map(mapper, item))
if isinstance(item, dict):
return frozenset({mapper(k): mapper(v) for k, v in item.items()}.items())
return item
return mapper(a) == mapper(b)
import xml.etree.ElementTree as ET
ET.register_namespace('', 'http://maven.apache.org/POM/4.0.0')
ns = {'pom': 'http://maven.apache.org/POM/4.0.0'}
root = ET.fromstring(open('pom.xml').read())
def text(elem):
return next(elem.itertext())
{
"node": "rabbit@a29cd7b1cd71",
"payload": {
"reply_to": {
"routing_key": "301efcc7-008f-3df4-b814-2b01741265d6",
"exchange": "reply.celery.pidbox"
},
"ticket": "0a5d46b3-9d5a-408f-8057-508035af5bd3",
"destination": null,
"method": "hello",
from json import loads, dumps
from sys import argv
from base64 import b64decode
with open(argv[1], 'r') as f:
for line in f.readlines():
if line.strip():
data = loads(line)
decoded = b64decode(data['payload'])
data['payload'] = loads(decoded)
@shaded-enmity
shaded-enmity / celery-dynamic-debug
Last active March 15, 2016 09:56
celery-dynamic-debug
{
"ticket": "0a5d46b3-9d5a-408f-8057-508035af5bd3",
"destination": null,
"reply_to": {
"routing_key": "301efcc7-008f-3df4-b814-2b01741265d6",
"exchange": "reply.celery.pidbox"
},
"method": "hello",
"arguments": {
"revoked": {},
@shaded-enmity
shaded-enmity / Matgen.py
Last active October 10, 2015 11:28
Creates unrolled 4x4 matrix multiplication C code with nice formatting
#!/usr/bin/python
Dim = 4
for i in range(Dim):
for j in range(Dim):
p = 'm->data[{0} + ({1} * {2})] = '.format(i, j, Dim)
for k in range(Dim):
numlpad = 23 if k > 0 else 0
p += (numlpad * ' ') + 'a->data[{0} + ({2} * {3})] * b->data[{2} + ({1} * {3})] + \n'.format(i, j, k, Dim)
$ readelf -h nvidia-installer
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Advanced Micro Devices X86-64
Target directory: NVIDIA-Linux-x86_64-355.11
-rw-r--r-- buildmeister/gopher 6041 2015-08-27 01:06 ./nvidia-application-profiles-355.11-key-documentation
-rw-r--r-- buildmeister/gopher 72949 2012-12-13 00:04 ./gl.h
-rw-r--r-- buildmeister/gopher 8432 2015-08-27 02:16 ./nvidia-installer.1.gz
-rwxr-xr-x buildmeister/gopher 34280 2015-08-27 01:06 ./nvidia-persistenced
-rwxr-xr-x buildmeister/gopher 51168 2015-08-27 02:33 ./libGLESv1_CM.so.355.11
-rw-r--r-- buildmeister/gopher 18264 2015-08-27 02:16 ./nvidia-smi.1.gz
-rw-r--r-- buildmeister/gopher 2058 2015-08-27 01:06 ./nvidia-persistenced.1.gz
-rwxr-xr-x buildmeister/gopher 14548520 2015-08-27 01:17 ./libcuda.so.355.11
-rwxr-xr-x buildmeister/gopher 11799176 2015-08-27 01:05 ./libglx.so.355.11