Skip to content

Instantly share code, notes, and snippets.

View mcflan's full-sized avatar

James Macfarlane mcflan

  • Airborne Engineering Limited
View GitHub Profile
@mcflan
mcflan / vim_coc.md
Last active January 23, 2024 23:48
Vim CoC config

Vim CoC Setup for Rust

This gist is to remind me how to install Conquer of Completion in vim and set it up for use with rust. It's a bit of a pain because it depends on node.js but it seems to work really well.

Prerequisits

@mcflan
mcflan / linux_stuff.md
Last active December 3, 2023 15:41
Linux stuff

Apple Magic Trackpad 2

To solve problem of mouse not scolling and not moving unless you press hard enough to cause it to click and select things.

xinput list
Virtual core pointer                    	id=2	[master pointer  (3)]
⎜ ↳ Virtual core XTEST pointer id=4	[slave pointer (2)]
@mcflan
mcflan / linux_stuff
Created November 9, 2023 00:35
Linux stuff
# Apple Magic Trackpad 2
xinput list
```
Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Logitech G903 LIGHTSPEED Wireless Gaming Mouse w/ HERO id=11 [slave pointer (2)]
⎜ ↳ Logitech G903 LIGHTSPEED Wireless Gaming Mouse w/ HERO id=12 [slave pointer (2)]
⎜ ↳ Apple Inc. Magic Trackpad 2 id=9 [slave pointer (2)]
@mcflan
mcflan / objcopy.md
Last active November 16, 2020 16:06
Objcopy tricks

Binutils Tricks and Tips

Using objcopy and objdump as a disassembler for binary machine code files

Use objcopy to take a binary file containining code and convert it into an object file so you can run objdump against it, e.g. to generate a nice disassembly listing:

z80-unknown-coff-objcopy --input-target=binary -B z80 --output-target=z80-unkown-coff  --image-base 0x0000 --rename-section .data=.text,contents,alloc,load,code ../Z.KEYB3 keyb3.out

Explanation:

@mcflan
mcflan / catenary.py
Created September 28, 2019 20:47
Simulate an elastic catenary wire of uniform density.
#!/usr/bin/env ipython3
# A quick python hack to attempt to model an elastic catenary wire of
# uniform density.
#
# James Macfarlane 20190928
import sys
import numpy as np
import matplotlib.pyplot as plt
@mcflan
mcflan / dbus.c
Last active August 7, 2019 15:53
Example of sending a dbus remote call using GDBus API in C.
#include <stdio.h>
#include <gio/gio.h>
#include <glib.h>
#define FATAL(fmt, ...) do { \
fprintf(stderr, "%s:%d: ", __FILE__, __LINE__); \
fprintf(stderr, fmt, ##__VA_ARGS__); \
fprintf(stderr, "\n"); \
exit(1); \
} while (0);
/*
* Code snippet showing how to change the background colour of a a GtkEntry
* widget using CSS.
*/
// Run this once at start-up
void set_up(void)
{
GError *err = NULL;
GtkCssProvider *provider = gtk_css_provider_new();
@mcflan
mcflan / Makefile
Last active February 20, 2018 18:57
Simple Unix Datagram sockets example in C and glib and also a very minimal hacky rust version of client.
CFLAGS=-g -Wall -std=gnu99
LDFLAGS+=-L/usr/local/lib
CPPFLAGS_GTK=`pkg-config --cflags glib-2.0` -I$(DAQ_FIRMWARE_DIR)
CPPFLAGS+=$(CPPFLAGS_GTK) -I$(TCDIR)
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
COMPILE.c = $(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
COMPILE.cc = $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
LOADLIBES_GTK=`pkg-config --libs glib-2.0`
LOADLIBES=$(LOADLIBES_GTK)