Skip to content

Instantly share code, notes, and snippets.

@croepha
croepha / entrypoint.bash
Created February 5, 2021 22:54
sometimes you just want a bare ubuntu in a container to ssh to
v/entrypoint.bash
#!/bin/bash
#!/bin/bash
# sudo docker run "--env=SSH_KEY=$( ssh-add -L )" --name ssh1 --volume=$HOME/ssh1:/v '--entrypoint=/v/entrypoint.bash' -d ubuntu:20.04
mount -t devtmpfs none /dev
mount -t devpts none /dev/pts
// License and copyright at the bottom
/* These variations of SHA-2 are implmented:
* checksum bytes nocopy alignment in bytes nocopy chunk size in bytes
SHA256 32 4 64
SHA512 64 8 128
SHA512_256 32 8 128
*/
// There are also three APIs for each, simple, buffered, and nocopy:
char* vertex_shader =
"#version 100\n"
"attribute highp vec3 mesh_xyz;\n"
"attribute highp vec4 mesh_color;\n"
"uniform highp mat4 model_view;\n"
"uniform highp mat4 projection;\n"
"varying highp vec4 vertex_color;\n"
"varying highp vec4 vertex_position;\n"
"void main () {\n"
" vertex_color = mesh_color;\n"
@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
exit # Dont run this as a script
# LLVM seems to work great on Musl, there only seems some build errors
# when trying to build the sanitizers. So sanitizers have been disabled.
# This is rougly based on this:
# https://wiki.musl-libc.org/building-llvm.html
# But updated for LLVM 8
# We are also focusing on making a GNU-less toolchain, as there is
# no libgcc and no libstdc++, instead we favor LLVM's own compiler-rt
#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; }