Skip to content

Instantly share code, notes, and snippets.

@croepha
croepha / netem_veth.sh
Created April 3, 2019 04:12
notes on Linux network emulation for local processes
sudo ip netns add client_ns
sudo ip link add veth0 type veth peer name veth1
sudo ip link set veth1 netns client_ns
sudo ip link set dev veth0 up
sudo ip addr add 192.168.250.10/24 dev veth0
sudo tc qdisc add dev veth0 root netem delay 1000ms
sudo ip -n client_ns link set dev veth1 up
sudo ip -n client_ns addr add 192.168.250.11/24 dev veth1
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <vector>
struct Thing {
int v1;
int v2;
};
int main () {
#include <wmmintrin.h>
int main() {
__m128i v = {};
static const int r0 = 0x00;
static const int r[] = {0x00};
static const int r1 = r[0];
_mm_aeskeygenassist_si128(v, r0); // compiles
_mm_aeskeygenassist_si128(v, r1); // fails with error: argument to '__builtin_ia32_aeskeygenassist128' must be a constant integer
}
#include <stdio.h>
#include <math.h>
#define PI 3.14159265
/*
* a1 \ a1 \
* |\ |\ s3 ______ a22
* | \ s3 s21 | \ | /
* | \ | \ s22 | / s1
#include <algorithm>
#include <stdio.h>
typedef float (*op_t)(float, float);
float op_add (float l, float r) { return l + r; }
float op_sub (float l, float r) { return l - r; }
float op_subr(float l, float r) { return r - l; }
float op_mul (float l, float r) { return l * r; }
float op_div (float l, float r) { return l / r; }
#include <assert.h>
#include <OpenGL/gl3.h>
#include <SDL2/SDL.h>
int main () {
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS,
SDL_GL_CONTEXT_DEBUG_FLAG |
SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
@croepha
croepha / merge_dir.cpp
Created August 24, 2018 23:13
filesystem filtering tools
// cro_build:release,noasan,raw, -static-libstdc++
#define _XOPEN_SOURCE 700
#define _POSIX_C_SOURCE 200809L
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <assert.h>
using System;
using System.ServiceProcess;
using System.Net.Sockets;
using System.Net;
using System.Text;
public partial class MyService : ServiceBase
{