Skip to content

Instantly share code, notes, and snippets.

@RLovelett
RLovelett / CMakeLists.txt
Created April 1, 2020 17:59
Example of preferring Python 2 over Python3 with new FindPython2 and FindPython3 CMake modules
cmake_minimum_required(VERSION 3.12.4)
find_package(Python2 COMPONENTS Interpreter)
find_package(Python3 COMPONENTS Interpreter)
if (NOT Python2_Interpreter_FOUND AND NOT Python3_Interpreter_FOUND)
message(FATAL_ERROR "Could NOT find Python2 or Python3")
endif()
# https://github.com/Kitware/CMake/blob/cfc92b483fbd3695d4a67843977e709ba4d7ea47/Modules/FindPython/Support.cmake#L2433-L2439
@RLovelett
RLovelett / README.md
Last active February 26, 2023 09:40
FT232H user space GPIO device - https://stackoverflow.com/q/60781594/247730

Setting up ftrace

$ sudo su - root
$ cd /sys/kernel/debug/tracing
$ cat available_tracers
hwlat blk mmiotrace function_graph wakeup_dl wakeup_rt wakeup function nop
$ cat available_filter_functions | grep ftdi_sio | cut -d' ' -f1 | tr '\n' ' ' > set_ftrace_filter
$ cat set_ftrace_filter
get_serial_info [ftdi_sio]
@RLovelett
RLovelett / README.md
Last active August 15, 2024 12:51
Force RGB instead of YCbCr output for HDMI on Ubuntu

Force RGB pixel format over YCbCr

There are some monitors, in my case Dell U2413, that report having YCbCr support when plugged in over HDMI. My AMD Radeon RX 570 Series video card sees this YCbCr pixel format and then prefers that over the RGB pixel format. The result is that fonts, graphics and other visuals are pixelated and not smooth in Ubuntu.

This actually is not just a Linux problem. A similar problem exists on macOS with the same monitor hooked up over HDMI. In fact an article by John Ruble on the Atomic Object blog called Fixing the External Monitor Color Problem with My 2018 MacBook Pro attempts to fix the exact same thing.

Solution

All of the articles I could find exploring this topic advocate patching the EDID for the monitor. Unfortunately the macOS solution would not work here. Luckily I found a Reddit post that covered how to get it working.

@RLovelett
RLovelett / README.md
Last active March 18, 2020 22:01
Systemd Unit and Timer to Build Swift Everyday

Swift Toolchain Build

These systemd unit and timer configurations will get an up-to-date copy of Swift and build the toolchain every day at 2:00 AM local time.

Prerequisites

In order for these configurations to work without modification it is assumed that all of the development dependencies are already installed and that the Swift repository is cloned in $HOME/Source/swift-source/swift.

Install

@RLovelett
RLovelett / mtoc.sh
Created October 29, 2019 20:50
Compile mtoc on macOS Catalina Xcode 11
# https://github.com/macports/macports-ports/blob/master/devel/cctools/Portfile
curl -o cctools-921.tar.gz https://opensource.apple.com/tarballs/cctools/cctools-921.tar.gz
curl -o llvm-8.0.1.src.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-8.0.1/llvm-8.0.1.src.tar.xz
curl -o ld64-409.12.tar.gz https://opensource.apple.com/tarballs/ld64/ld64-409.12.tar.gz
tar xvf cctools-921.tar.gz
tar xvf llvm-8.0.1.src.tar.xz
tar xvf ld64-409.12.tar.gz
@RLovelett
RLovelett / libvirt.md
Last active March 8, 2023 01:53
Setup libvirtd on Fedora Server 28

libvirtd Fedora 28

System Packages

$ dnf install -y \
    libvirt \
    libvirt-python \
    libguestfs-tools \
 qemu-kvm \
@RLovelett
RLovelett / smb.conf
Last active April 8, 2021 15:26
Samba Configuration
# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run 'testparm' to verify the config is correct after
# you modified it.
[global]
workgroup = SAMBA
security = user
passdb backend = tdbsam
load printers = no

Keybase proof

I hereby claim:

  • I am rlovelett on github.
  • I am rlovelett (https://keybase.io/rlovelett) on keybase.
  • I have a public key ASCSdXfEevoHXXVb5eMvjn8rUL00ucXGH1-a1Czn-JSfJgo

To claim this, I am signing this object:

@RLovelett
RLovelett / posix_spawnp.swift
Created April 21, 2016 02:22
Spawn a sub-process from Swift
import Glibc
var action = posix_spawn_file_actions_t()
posix_spawn_file_actions_init(&action);
defer { posix_spawn_file_actions_destroy(&action) }
posix_spawn_file_actions_addopen(&action, 1, "/tmp/foo-log", (O_WRONLY | O_CREAT | O_TRUNC), 0644)
posix_spawn_file_actions_adddup2(&action, 1, 2)
let args = [
"ffmpeg",
@RLovelett
RLovelett / binutils-bisect.sh
Last active May 8, 2022 19:53
A Git bisect run script to find the binutils commit that introduced the move bug
#!/usr/bin/env bash
# Good: 2bd25930
# Bad: 71090e7a
set -ex
BINUTILS_DIR=$HOME/packages/trunk
SWIFT_DIR=$HOME/swift