Skip to content

Instantly share code, notes, and snippets.

@trya
trya / json2sexpr.c
Created May 12, 2018 10:42
JSON to S-expr
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <inttypes.h>
#include <unistd.h>
#include <json-c/json.h>
void json2sexp(struct json_object *jobj);
@trya
trya / splice_cat.c
Created May 22, 2018 19:32
Implementation of cat using splice()
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
int p[2];
const size_t sz = 65536;
void cat(int fd)
@trya
trya / zmq_pub.cpp
Created January 5, 2019 21:55
ZMQ publisher with ZMQ_CONFLATE
#include <iostream>
#include <unistd.h>
#include "zmq.hpp"
static const char *addr = "tcp://*:1337";
void pub_loop(void)
{
zmq::context_t ctx;
@trya
trya / zmq_sub.cpp
Created January 5, 2019 21:55
ZMQ subscriber
#include <iostream>
#include "zmq.hpp"
static const char *addr = "tcp://localhost:1337";
void sub_loop(void)
{
zmq::context_t ctx;
zmq::socket_t so(ctx, ZMQ_SUB);
#include <iostream>
#include <map>
struct s {
float red = 1.0/*F*/;
};
static const std::map<int, s> m {
{ 10, {} },
{ 12, {} },
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdint.h>
typedef struct fixed_point {
long long i; // integer part
unsigned long long d; // decimal part
} fixed_point;
@trya
trya / raylib_stdin_sink.c
Last active October 22, 2021 22:44
Simple example of raylib rendering whatever is coming on stdin
#include <stdio.h>
#include <stdlib.h>
#include <threads.h>
#include "raylib.h"
#include "rlgl.h"
int main(int argc, char **argv)
{
if (argc != 4) {