Skip to content

Instantly share code, notes, and snippets.

@jelford
jelford / self-pipe-trick.c
Last active Oct 31, 2021
a short snippet demonstrating djb's self-pipe trick in c
View self-pipe-trick.c
// compiles with: gcc -Wall -Werror -pedantic ./selfpipetrick.c -o selfpipetrick
// You can quit by suspending with Ctrl-Z and then sending a `kill -9`
#include <sys/signalfd.h>
#include <signal.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
@jelford
jelford / signalfd.c
Created Oct 31, 2021
A small app that demonstrates using signalfd to handle signals in a normal thread context
View signalfd.c
// Error handling omitted for brevity
// compile with: gcc signalfd.c -o signalfd
#include <sys/signalfd.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <poll.h>
@jelford
jelford / Cargo.toml
Created Apr 4, 2021
Signal-Handling-Raw
View Cargo.toml
[package]
name = "example"
version = "0.1.0"
authors = ["James Elford <james.p.elford@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
libc = "0.2"
@jelford
jelford / Contailerfile
Created Aug 21, 2020
Toolbox for setting up RingCentral Meetings
View Contailerfile
FROM registry.fedoraproject.org/f32/fedora-toolbox:latest
RUN set pipefail && \
dnf update --all -y && \
curl -sSLo "ringcentral_x86_64.rpm" "https://ringcentral.zoom.us/client/latest/ringcentral_x86_64.rpm" && \
dnf localinstall -y "ringcentral_x86_64.rpm" && \
dnf clean all
# build with `podman build -t ringcentral-image .
# init toolbox with `toolbox create -i ringcentral-image -c ringcentral
@jelford
jelford / log.css
Last active Aug 29, 2015
Quick and dirty log panel when console.log isn't available
View log.css
#log {
max-height: 10em;
height: 10em;
overflow-y: scroll;
position: fixed;
right: 0;
top: 0;
@jelford
jelford / jmock_abstract_collecitons.java
Last active Dec 22, 2015
This will bite you if you use Guava's ImmutableX types.
View jmock_abstract_collecitons.java
public class AppTest
{
@Rule public JUnitRuleMockery context = new JUnitRuleMockery();
public static interface ColGetter {
public abstract Col get();
}
public static interface NonColGetter {
public abstract NonCol get();