This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A simple demonstration of libbacktrace to print a stacktrace. | |
* | |
* bear -- gcc -O0 -g -o main main.c -lbacktrace && ./main | |
* bear -- clang -O0 -g -isystem /usr/lib/gcc/x86_64-linux-gnu/12/include/ -o main main.c -lbacktrace && ./main | |
*/ | |
#include <stdio.h> | |
#include <backtrace.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-Dcom.sun.management.jmxremote.host=0.0.0.0 | |
-Dcom.sun.management.jmxremote.port=1234 | |
-Dcom.sun.management.jmxremote.ssl=false | |
-Dcom.sun.management.jmxremote.authenticate=false | |
-Dcom.sun.management.jmxremote.local.only=false | |
-Dcom.sun.management.jmxremote | |
-Djava.rmi.server.hostname=0.0.0.0 | |
-Djava.security.policy=jstatd.all.policy | |
-Dcom.sun.management.jmxremote.rmi.port=1234 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* clang++ -std=c++2c -Wall -Wextra -Wpedantic -g -o main main.cpp && ./main | |
*/ | |
#include <iostream> | |
template<class F> | |
class Defer { | |
private: | |
F func; | |
public: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A simple example um creating a subprocess to execute some program and capture its stdout and stderr using pipes. | |
* | |
* ## Compilation example | |
* | |
* ``` | |
* clang -Wall -Wextra -Wpedantic -std=c23 -g -O0 -fsanitize=address,undefined -fno-omit-frame-pointer -fuse-ld=lld -o fork-test main.c | |
* ``` | |
* | |
* ## References |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <errno.h> | |
#include <stdint.h> | |
#include <stdbool.h> | |
#include <assert.h> | |
enum result { RESULT_OK, RESULT_ERR }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <assert.h> | |
#include <curl/curl.h> | |
struct buffer { | |
unsigned char* data; | |
size_t size; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This program demonstrates how to read/map a file into memory using mmap. | |
* | |
* In order to get the file size we also avoid the "problematic" fseek + SEEK_END approach. | |
* Instead, we use open/fstat for it (although fopen/fileno/fstat would also work just fine). | |
*/ | |
// libc | |
#include <stdio.h> | |
#include <stdlib.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
#include <elf.h> | |
using std::cout; | |
using std::cerr; | |
using std::string_view; | |
using std::array; | |
namespace elf::header | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <librdkafka/rdkafka.h> | |
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) | |
#define BOOTSTRAP_SERVERS_KEY "bootstrap.servers" | |
#define BOOTSTRAP_SERVER_VALUE "kafka:9092" | |
#define PRODUCER_TOPIC "librdkafka-examples-topic" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* https://www.forumsys.com/2014/02/22/online-ldap-test-server/ | |
* | |
* clang++ -Wall -Wextra -Wpedantic -std=c++17 -g -O0 -ggdb -fsanitize=address,undefined -fno-omit-frame-pointer -o /tmp/ldap-client ldap-client.cpp -lldap | |
*/ | |
#include <iostream> | |
#include <cassert> | |
#include <cstring> | |
#include <cerrno> | |
#include <sstream> |
NewerOlder