Skip to content

Instantly share code, notes, and snippets.

@kylewlacy
kylewlacy / LICENSE.txt
Last active August 29, 2015 14:13
MinTest - A bare-bones testing "library" for C (based on MinUnit)
Copyright (c) 2015 Kyle Lacy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@kylewlacy
kylewlacy / cartesian_product.rs
Created November 17, 2015 07:28
Cartesian product function in Rust
/// Given a vector containing a partial Cartesian product, and a list of items,
/// return a vector adding the list of items to the partial Cartesian product.
///
/// # Example
///
/// ```
/// let partial_product = vec![vec![1, 4], vec![1, 5], vec![2, 4], vec![2, 5]];
/// let items = &[6, 7];
/// let next_product = partial_cartesian(partial_product, items);
/// assert_eq!(next_product, vec![vec![1, 4, 6],
@kylewlacy
kylewlacy / cartesian_product.scala
Created November 17, 2015 07:38
Cartesian product function in Scala
import scala.reflect.ClassTag
object CartesianProduct {
/**
* Given an array containing a partial Cartesian product, and an array of
* items, return an array adding the list of items to the partial
* Cartesian product.
*
* {{{
* val partialProduct = Array(Array(1, 4), Array(1, 5), Array(2, 4), Array(2, 5))
@kylewlacy
kylewlacy / fn_clone.rs
Last active July 18, 2017 16:17
Rust macro for creating a closure that implements the `Clone` trait. (Dual licensed under MIT/Unlicense; see below)
#![feature(unboxed_closures)]
#![feature(fn_traits)]
use std::time;
use std::thread;
use std::sync::{Arc, RwLock};
macro_rules! fn_clone {
// Normalized form
(
@kylewlacy
kylewlacy / subshell.fish
Created June 5, 2016 08:48
fish subshell substitution
# bash:
# # <(some_command) returns a file (technically a named pipe) for the result of some_command
# $ echo <(echo "hi")
# /dev/fd63
# $ cat <(echo "hi")
# hi
#
# fish:
# # (some_command | psub) returns a file for the result of some_command
# $ echo (echo "hi" | psub)
@kylewlacy
kylewlacy / triangle.rs
Created December 9, 2016 00:04
Rust gfx triangle example using SDL2
// Copyright 2014 The Gfx-rs Developers.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@kylewlacy
kylewlacy / 57-add-emoji-support.conf
Last active November 12, 2024 14:14 — forked from ssaavedra/57-add-emoji-support.conf
Add Emoji to Linux Fontconfig (edited to fix broken fonts for Zoom video conference)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!--
Author: Santiago Saavedra <ssaavedra@gpul.org>, Kyle Lacy
License: CC0
Year: 2016-2017
Install:
Copy to $XDG_CONFIG_DIR/fontconfig/conf.d/57-add-emoji-support.conf
Run fc-cache -f
@kylewlacy
kylewlacy / loopback-fix.md
Created September 11, 2017 21:53
Linux Mint - Fixing loopback device not starting at startup

Recently, I had an issue where I had no loopback device in Linux Mint 18.2 MATE, which occurred after upgrading from 18.1 MATE.

Diagnosis

ping localhost fails, nc -v -l -p 1234 followed by nc localhost 1234 does not connect, etc. Running ifconfig does not show a loopback device present.

Running sudo service network-manager restart and sudo service networking restart doesn't fix the issue, nor does restarting.

The only clue shows up when inspecting /var/log/syslog:

@kylewlacy
kylewlacy / kexec-installer.nix
Created March 5, 2018 03:00 — forked from Mic92/kexec-installer.nix
kexec-based installer for nixos to install nixos from every linux!
## USAGE
# $ nix-build kexec-installer.nix
# can be deployed remote like this
# $ rsync -aL -e ssh result/ root@host:
# $ ssh root@host ./kexec-installer
## Customize it like this
# # custom-installer.nix
# import ./kexec-installer.nix {
# extraConfig = {pkgs, ... } {
# user.extraUsers.root.openssh.authorizedKeys.keys = [ "<your-key>" ];
@kylewlacy
kylewlacy / nixos-install.log
Created March 10, 2018 07:30
Fix for error during NixOS UEFI installation: "Failed to create EFI Boot variable entry: No such file or directory"
# Tested with nixos-minimal-18.03pre130932.cc4677c36ee-x86_64-linux.iso
# Manually mounted /mnt (NixOS root), /mnt/boot (mkfs.ext4 Grub partition), /mnt/boot/efi (mkfs.vfat for EFI boot vars)
[root@nixos:~]# cat /mnt/etc/nixos/hardware-configuration.nix
# Do not modify this file! It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, ... }:
{