Skip to content

Instantly share code, notes, and snippets.

@scivision
scivision / CMakeLists.txt
Last active February 16, 2024 11:09
CMake pkg-config .pc.in generate template
# this fragment generates build/my_package.pc
#
# cmake -B build -DCMAKE_INSTALL_PREFIX=~/mylib
cmake_minimum_required(VERSION 3.0)
project(mylib
LANGUAGES C
HOMEPAGE_URL https://github.invalid/username/mylib
DESCRIPTION "example library"
@senderle
senderle / hand-modify-pdf.md
Created September 23, 2020 15:03
So you want to modify the text of a PDF by hand

So you want to modify the text of a PDF by hand...

If you, like me, resent every dollar spent on commercial PDF tools, you might want to know how to change the text content of a PDF without having to pay for Adobe Acrobat or another PDF tool. I didn't see an obvious open-source tool that lets you dig into PDF internals, but I did discover a few useful facts about how PDFs are structured that I think may prove useful to others (or myself) in the future. They are recorded here. They are surely not universally applicable --
the PDF standard is truly Byzantine -- but they worked for my case.

@berkorbay
berkorbay / github_desktop_ubuntu.md
Last active July 3, 2024 02:10
To install Github Desktop for Ubuntu

IMPORTANT

See the following links for further updates to Github Desktop for Ubuntu. These are official instructions. (also mentioned by fetwar on Nov 3, 2023)

For the sake of "maintaining the tradition" here is the updated version.

@bmatcuk
bmatcuk / 1README.md
Created January 9, 2020 02:48
Quick and dirty libuv test

Quick and Dirty libuv Test

This code isn't meant to be pretty: it's just a simple implementation of some libuv features. Specifically:

  • raw mode tty;
  • streaming input from tty;
  • writing output to tty (specifically: echoing the input hex-encoded);
  • handling a signal (SIGTERM, ie, kill pid);
  • quitting on ctrl+c
  • properly cleaning up after ourselves.
@ssrlive
ssrlive / multi-uv-loops.c
Created July 15, 2019 08:40
multiple loops in libuv
#include <stdio.h>
#include <stdint.h>
#include <pthread.h>
#include <uv.h>
/* Libuv multiple loops + thread communication example. */
//rpath is needed because it is an argument to the linker (not compiler) about
//where to look
//gcc -Iinclude -g multi-uv-loops.c -o multi-uv-loops -L "./" -l uv -Xlinker -rpath -Xlinker "./" -lrt
@igorsol
igorsol / bear-jq.md
Last active June 12, 2021 13:40
json filtering with jq utility

So I suddenly discovered that compile_commands.json files generated by the Bear tool contain duplicate entries despite the fact Bear's documentation says it should filter out duplicates. Probably that was result of the outdated (2 years old) version of the Bear - now I updated it but I had no time to check if this issue is already fixed.

How to filter out duplicate entries from a JSON array with thousands of elements? And preferably leave only the last element of the group because it contains the most up-to-date compilation parameters?

One way is just remove compile_commands.json and rebuild whole project - but that could be very tedious because on my machine it takes more than an hour to rebuild the project which I work on. And I have a dosen of different versions in separate directories... After some thinknig I recalled a tool called jq which is 'JSON query'. I had some doubts if I will be able to do my specific task with this tool so I went to documentation page:

@fnky
fnky / ANSI.md
Last active July 3, 2024 11:00
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@franzflasch
franzflasch / qemu-arm-with-busybox-linux-and-shared-folder.md
Last active May 7, 2024 14:26
Howto qemu-arm with busybox linux and shared folder

Install dependencies

apt-get install gcc-arm-linux-gnueabihf qemu

Prepare work directory

mkdir qemu-arm-sandbox && cd qemu-arm-sandbox
@yellowbyte
yellowbyte / compiling_asm.md
Last active June 4, 2024 20:17
how to assemble assembly with NASM assembler to 32-bit or 64-bit ELF binary with or without libc

32-bit ELF binary

how to assemble and link:

nasm -f elf32 -o <filename>.o <filename>.asm
ld -m elf_i386 -o <filename> <filename>.o

template code (hello world):

section .text
global _start

C bit hacks

Related:

Index

Bit Twiddling Hacks