Skip to content

Instantly share code, notes, and snippets.

@phaser
phaser / compile.sh
Created April 12, 2025 21:18
Creating a cross-compiler
#!/bin/sh
set -x
export PATH="$(brew --prefix bison)/bin:$(brew --prefix flex)/bin:/usr/local/bin:$PATH"
export PREFIX="$HOME/opt/cross"
export TARGET=i686-elf
export PATH="$PREFIX/bin:$PATH"
BUILD_FOLDER="build"
@phaser
phaser / parallel_copy.sh
Created November 5, 2024 11:17
Parallel copy using dd
#!/bin/bash
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--file)
source_file="$2"
shift 2
;;
--dest)
@phaser
phaser / vec_generic.h
Last active May 30, 2020 17:04
A vector template that supports specializing for vec2, vec3, vec4 having parametric storage access trough {x,y,z,w}, {r,g,b,a}, {u,v} etc
constexpr bool int_gt(const uint8_t p, const uint8_t val)
{
return p > val;
}
template <typename _Ty, uint8_t _Sz = 2>
class storage2
{
public:
using value_type = _Ty;
// https://leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/727/
#include <vector>
#include <benchmark/benchmark.h>
#include <gtest/gtest.h>
using namespace std;
class Solution
{
@phaser
phaser / remove-all-from-docker.sh
Created September 20, 2019 09:38 — forked from beeman/remove-all-from-docker.sh
Remove all from Docker
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes

To make sure that Hyper-V is really disabled run the following command in PowerShell with Administrator rights:

bcdedit /set hypervisorlaunchtype off 

Usually when VirtualBox stops working with a message complaining about VT-x missing then this might solve it.

Building DPDK kernel module with DKMS

cd /usr/src
sudo wget https://fast.dpdk.org/rel/dpdk-18.11.1.tar.xz
sudo tar -xvf dpdk-18.11.1.tar.xz

Before doing anything do an in-place build of DPDK. The build system uses some of the things it creates during this build process.

make T=x86_64-native-linuxapp-gcc config

Install packages (Ubuntu 18.10)

  sudo apt-get install qemu-kvm qemu virt-manager virt-viewer

Create initial image

@phaser
phaser / configure_muliple_gcc.sh
Created August 20, 2018 09:38 — forked from SunnyRaj/configure_muliple_gcc.sh
Configure multiple GCC versions on ubuntu
#!/usr/bin/env bash
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt update
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo apt-get install -y gcc-4.8 g++-4.8 gcc-4.9 g++-4.9 gcc-5 g++-5 gcc-6 g++-6 gcc-7 g++-7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10
@phaser
phaser / effective_modern_cmake.md
Created August 7, 2018 14:39 — forked from mbinna/effective_modern_cmake.md
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft