Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mcejp
mcejp / gist:ea94ec2afc8487f40792cb57d52643ec
Created November 6, 2018 14:19
Configure fish to display help for keybinds on startup
echo "• Tab completes the current token. Shift Tab completes the current token and starts the pager's search mode.
• Alt-← and Alt-→ move the cursor one word left or right, or moves forward/backward in the directory history if the command line is empty. If the cursor is already at the end of the line, and an autosuggestion is available, Alt-→ (or Alt-F) accepts the first word in the suggestion.
• ↑ and ↓ (or Ctrl-P and Ctrl-N for emacs aficionados) search the command history for the previous/next command containing the string that was specified on the commandline before the search was started. If the commandline was empty when the search started, all commands match. See the history section for more information on history searching.
• Alt-↑ and Alt-↓ search the command history for the previous/next token containing the token under the cursor before the search was started. If the commandline was not on a token when the search started, all tokens match. See the history section for more information on history sea
@mcejp
mcejp / ili9163c.S
Created April 14, 2020 12:56
ILI9163C routines for AVR
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
Originally published on http://0xfffe.blogspot.com/2015/11/to-lcd-or-not-to-lcd-fighting-ili9163.html
*/
@mcejp
mcejp / AUDIO.md
Created November 22, 2020 17:12
Enabling audio output for Arm versatilepb machine in QEMU

Add this to the QEMU command line: -usb -device usb-audio

In VM:

$ nano /etc/asound.conf

pcm.!default {
    type plug
 slave {
from queue import Queue
from threading import Lock
from typing import List, Optional
class Subscription:
_bus: "MessageBus"
_queue: Queue
# Class can be also gevent.queue.Queue
@mcejp
mcejp / VGASimulator.py
Created May 9, 2022 22:03 — forked from pvieito/VGASimulator.py
Simulate and view VGA output from a VHDL simulation
#!/usr/bin/env python3
'''VGASimulator.py - Pedro José Pereira Vieito © 2016
View VGA output from a VHDL simulation.
Ported from VGA Simulator:
https://github.com/MadLittleMods/vga-simulator
by Eric Eastwood <contact@ericeastwood.com>
More info about how to generate VGA output from VHDL simulation here:
http://ericeastwood.com/blog/8/vga-simulator-getting-started
#lang racket
(provide fast-median)
(define (median-of-5 vec)
(when (> (vector-length vec) 5) (error "median-of-5 shall be only used for short vectors"))
(define n (vector-length vec))
(vector-ref (vector-sort vec <) (floor (/ n 2))))
@mcejp
mcejp / FileEmbed.cmake
Last active January 26, 2023 10:36
CMake function to convert a binary file into a C++ header embedding the data as std::span<uint8_t>
# Adapted from original:
# https://jonathanhamberg.com/post/cmake-file-embedding/
# https://gitlab.com/jhamberg/cmake-examples/-/blob/master/cmake/FileEmbed.cmake
function(FileEmbed_Add input output c_name)
add_custom_command(
OUTPUT ${output}
COMMAND ${CMAKE_COMMAND}
-DRUN_FILE_EMBED_GENERATE=1
-DINPUT_FILE=${input}
@mcejp
mcejp / line_writer.py
Created May 1, 2023 12:09
Pattern: line writer with indentation
class LineWriter:
def __init__(self, f, indent=0):
self._f = f
self._indent = indent
def indented(self) -> "LineSink":
return LineSink(self._f, self._indent + 1)
def write_line(self, s=None):
if s is not None:
#!/bin/bash
if [[ $# -ne 1 ]] ; then
echo 'usage: make_release.sh RELEASE'
echo ' example: ./make-release.sh 2022.06'
exit 1
fi
set -e