Skip to content

Instantly share code, notes, and snippets.

View taeber's full-sized avatar

Taeber Rapczak taeber

View GitHub Profile
@taeber
taeber / mousectl.c
Created February 13, 2024 03:44
mousectl - Swap mouse buttons from the macOS Terminal
// mousectl - Swap mouse buttons from the macOS Terminal
// From https://superuser.com/a/1782251
// with changes by [email protected]
// Compile:
// clang -framework IOKit -framework Foundation -o mousectl mousectl.c
#include <IOKit/hidsystem/IOHIDLib.h>
#include <IOKit/hidsystem/IOHIDParameter.h>
@taeber
taeber / fakesay.c
Created November 13, 2019 23:13
Fake say program
// Fake say program
//
// Author:
// Taeber Rapczak <[email protected]>
//
// Compile:
// $ cc -o say fakesay.c
// Example:
// $ ./say hi
// $ ./say alexa unlock front door
@taeber
taeber / functions.bash
Last active June 20, 2019 15:43
Bash Functions
function envload {
if [ "$#" -ne 1 ]
then
echo "usage: envload <envfile>"
echo ""
echo "Reads an environment file (lines of key=value pairs) into the current Environment"
return
fi
case $(uname) in
@taeber
taeber / standup.bash
Last active January 4, 2018 18:07
Stand up every thirty minutes reminder via i3-nagbar
#!/bin/bash
# Copyright 2017 Taeber Rapczak
# Reminds the user to stand up or sit down on the hour and half-hour
# Uses timer from https://gist.github.com/taeber/20d6b000ae68f5f623f3467233017f34
seconds=$(date +%T | cut -d: -f3)
minutes=$(date +%T | cut -d: -f2)
if [[ $minutes -ne 0 ]] || [[ $seconds -ne 0 ]]
@taeber
taeber / timer.c
Last active December 14, 2017 22:02
Simple Countdown Timer
/* Copyright 2017 Taeber Rapczak
*
* Simple countdown timer
*
* EXAMPLES
* $ timer 10 # sets timer for 10 seconds
* $ timer 1m # sets timer for 1 minute
* $ timer 3h5m2 # sets timer for 3 hours, 5 minutes, 2 seconds
*/
@taeber
taeber / .eslintrc.js
Last active November 7, 2017 18:48
Airbnb eslint issue: comma-dangle
module.exports = {
"extends": "airbnb-base"
};
@taeber
taeber / visible.jsx
Created October 20, 2017 16:33
React Visible Component
// before:
var LoginLink = props => (
{!props.loggedIn &&
<a href="#login">Login</a>
}
);
const Visible = props => props.when && props.children;
// after:
@taeber
taeber / README.md
Last active August 31, 2017 21:37
C Metaprogramming

C Metaprogramming

Macros are used for metaprogramming in C. As an example, a generic List is typically implemented with macros, such as LIST_HEAD_INIT in the Linux kernal or LL_* in (https://troydhanson.github.io/uthash/utlist.html).

I tend to dislike macros, especially ones that emulate control structures and function-macros liberally shrewn about the code. I do like the idea of C++ metaprogramming, but it can get a bit obscure.

@taeber
taeber / file.html
Created September 14, 2014 20:21
Playing around with the File API
<input type="file" id="input">
<br />
<pre id="output"></pre>
<script>
var output = document.getElementById("output");
var input = document.getElementById("input");
function handleFiles() {
var file = this.files[0];
@taeber
taeber / OptionalDependency.cs
Created January 16, 2014 22:28
Demo of an OptionalDependency helper class which should prevent modifying an optional dependency (see Property Injection pattern) in the middle of a class's lifetime.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
sealed class OptionalDependency<T> where T : class
{
private OptionalDependency() { }
private OptionalDependency(T defaultDependency)
{
if (defaultDependency == null)