Skip to content

Instantly share code, notes, and snippets.

View woodnathan's full-sized avatar

Nathan Wood woodnathan

View GitHub Profile
@TheAllenChou
TheAllenChou / Seek.cs
Last active February 2, 2025 16:22
Value Seeking
// example of how to move a current value towards a target value at a constant speed
// without going over the target value
// formula is the same for vectors of any dimension
Vector3 Seek(Vector3 currentValue, Vector3 targetValue, float maxSpeed, float dt)
{
// delta/difference from current value to target value
Vector3 delta = targetValue - currentValue;
// don't take the square root of magnitude yet
// so we can potentially early out on degenerate case of currenvValue ~= targetValue
@cliffrowley
cliffrowley / STREAMDECK_HID.md
Last active February 8, 2025 14:44
Notes on the Stream Deck HID protocol

Stream Deck Protocol

How to interface with a Stream Deck device.

Synopsis

The device uses the HID protocol to communicate with its software.

Configuration

@fauxpark
fauxpark / applefn.patch
Last active February 23, 2025 21:55
QMK Apple Fn
diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk
index 18f8b0bbfc..4ef3e230e4 100644
--- a/builddefs/common_features.mk
+++ b/builddefs/common_features.mk
@@ -878,6 +878,10 @@ ifeq ($(strip $(JOYSTICK_ENABLE)), yes)
endif
endif
+ifeq ($(strip $(APPLE_FN_ENABLE)), yes)
+ OPT_DEFS += -DAPPLE_FN_ENABLE
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active February 26, 2025 18:09
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@SteveTrewick
SteveTrewick / duckspeak.swift
Last active February 20, 2017 11:06
Set AVAudioSession category and options to mix with other audio and turn volume down/up as well as interrupt any spoken text.
import UIKit
import AVFoundation
class ViewController: UIViewController, AVSpeechSynthesizerDelegate {
let synth = AVSpeechSynthesizer()
let avsesh = AVAudioSession.sharedInstance()
let voice = AVSpeechSynthesisVoice(language: "en-GB")
let avopts:AVAudioSessionCategoryOptions = [
.MixWithOthers,
.DuckOthers,
@idStar
idStar / UWFacebookService.m
Created August 30, 2012 16:47
Facebook Utility class to determine if logged in or not
#import "UWFacebookService.h"
@implementation UWFacebookService
// Static
static const int ddLogLevel = LOG_LEVEL_DEBUG;
// Strong
@synthesize facebookGraphUser = _facebookGraphUser;
@marcedwards
marcedwards / high-dpi-media.css
Last active March 2, 2025 20:24
A CSS media query that captures almost all high DPI aware devices.
/* ---------------------------------------------------------- */
/* */
/* A media query that captures: */
/* */
/* - Retina iOS devices */
/* - Retina Macs running Safari */
/* - High DPI Windows PCs running IE 8 and above */
/* - Low DPI Windows PCs running IE, zoomed in */
/* - Low DPI Windows PCs and Macs running Firefox, zoomed in */
/* - Android hdpi devices and above */
@crowl
crowl / NSDictionary+NSNullUtility.h
Created July 13, 2012 03:06
NSDictionary category to deal with nil instead of NSNull objects created by NSJSONSerialization
//
// NSDictionary+NSNullUtility.h
//
//
// Created by Pablo Heredia on 12-07-12.
// Copyright (c) 2012. All rights reserved.
//
#import <Foundation/Foundation.h>
@0xced
0xced / Makefile
Created March 23, 2012 15:02
Experiment ->isa vs object_getClass()
OPTIONS = metaclass.m -o metaclass -std=c99 -framework Foundation -arch x86_64 -Os
isa:
clang -DUSE_ISA=1 $(OPTIONS)
./metaclass
object_getClass:
clang -DUSE_ISA=0 $(OPTIONS)
./metaclass