Skip to content

Instantly share code, notes, and snippets.

View jepio's full-sized avatar
🏠
Working from home

Jeremi Piotrowski jepio

🏠
Working from home
View GitHub Profile
@jepio
jepio / create-dkms-overlay.sh
Created March 3, 2022 10:26
Script to create an overlay that can be used when building falco dkms module on Flatcar
#!/bin/bash
rm -rf /tmp/overlay
mkdir -p /tmp/overlay/.hidden
pushd /tmp/overlay
# this wrapper ensures that we use our dynamic linker and preload our libc version
cat >.hidden/wrapper.sh <<'EOF'
#!/bin/bash
@jepio
jepio / ct-etcd-gen.go
Created February 1, 2022 14:30
Generate etcd flag struct suitable for embedding in container-linux-config-transpiler
package main
import (
"bytes"
"fmt"
"log"
"regexp"
"os/exec"
"strings"
"unicode"
@jepio
jepio / cpu.c
Created February 1, 2022 10:35
Compute cpu frequency. This works because lines 12-17 are dependent operations which can't be pipelined and so must take 10 cycles.
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
// Perform CYCLES simple in-order operations
unsigned loop(int CYCLES)
{
unsigned a = rand(), b = rand(), x = rand();
for (int i=0; i < CYCLES/10; i++)
#!/bin/bash
KUBE_VERSION=1.21.0
TF_VERSION=0.13.7
# only amd64 is supported due to terraform-libvirt
ARCH=amd64
POOL=/mnt/pool
apps=( qemu-system-x86_64 virsh curl jq wget lbzip2 unzip )
pkgs=( libvirt-daemon-system qemu-system-x86 curl jq wget lbzip2 unzip )
@jepio
jepio / ubuntu20-hyperv-enhanced-session.md
Last active September 4, 2023 06:54 — forked from milnak/ubuntu20-hyperv-enhanced-session.md
Verified way of enabling enhanced session in Hyper-V for Ubuntu 20

Setup Hyper-V enhanced session for Ubuntu 20

I couldn't find instructions that were 100% complete, so I put this together.

These instructions worked fine for me. Follow each step carefully.

Download Ubuntu 20.04 desktop

Download Ubuntu Desktop 20.04 LTS from here.

@jepio
jepio / flatcar-install-k8s.sh
Last active February 6, 2023 03:43
Install k8s on flatcar
#!/bin/bash
set -xe
systemctl enable docker
modprobe br_netfilter
cat <<EOF | tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF
@jepio
jepio / write.cpp
Created November 1, 2015 10:29
variadic vs. monadic(?) binary write
#include <iostream>
#include <fstream>
template <typename... Ts>
void ignore(Ts&&...) {}
template <class Stream, typename T>
void write(Stream& s, T&& t)
{
s.write(reinterpret_cast<const char *>(&t), sizeof(T));
@jepio
jepio / compiler_flags.sh
Last active October 14, 2015 11:07
Common compiler flags that are supported by both gcc and clang.
-O3 # enable various code gen optimizations incl. vectorization
-march=native # enable all instructions sets supp. on curr. machine
-mtune=native # tune for the caches of the curr. machine
-flto # enable link time optimization - cross translation unit - AWESOME!
-fprofile-generate # enable code instrumentation to generate profile of program exec.
-fprofile-use # use profile of program exec. to tune branches and stuff
-ffunction-sections # place functions in separate sections that can be discarded by linker
-fdata-sections # ^^same but for data
-Wl,--gc-sections # garbage collect unused sections during linking
-Wl,-O1 # perform linker optimizations (not very significant)
@jepio
jepio / my_calendar.py
Last active September 30, 2015 09:56
Print a calendar!
#!/usr/bin/env python3
import itertools as it
import operator as op
from datetime import date, timedelta
import calendar as cal
def dates_in_year(year):
day = timedelta(days=1)
curr = date(year, 1, 1)
@jepio
jepio / synchronization.cu
Created September 29, 2015 08:02
Replacing 3 syncs with one predicated sync.
__global__ void three_syncs(int *data, int size, int thresh)
{
__shared__ int flag;
int tid = threaIdx.x;
do {
__syncthreads();
if (!tid)
flag = 0;
__syncthreads();
if (tid < size) {