Skip to content

Instantly share code, notes, and snippets.

View arkku's full-sized avatar

Kimmo Kulovesi arkku

View GitHub Profile
@arkku
arkku / qmk_apple_fn.patch
Last active March 3, 2024 14:22
Patch for QMK firmware to add two keycodes for Apple Fn: KC_APFN simulates the key directly, whereas APFN_LAYER(x) works as MO(x) but also registers as holding down Apple Fn _when no other key is pressed_. APFN_KEY(x) is key x together with Apple Fn.
diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk
index c976b8296d..335b432e78 100644
--- a/builddefs/common_features.mk
+++ b/builddefs/common_features.mk
@@ -108,6 +108,12 @@ ifeq ($(strip $(MOUSEKEY_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/mousekey.c
endif
+ifeq ($(strip $(APPLE_FN_ENABLE)), yes)
+ OPT_DEFS += -DAPPLE_FN_ENABLE -DENABLE_APPLE_FN_KEY=1
@arkku
arkku / bunnies.rb
Last active October 20, 2020 12:29
#!/usr/bin/env ruby
puts "🕳"
bunny = [ '(\_/)', '( •_•)', '/ >' ]
count = (ARGV[0] || 17).to_i
0.upto(count - 1) do |i|
space=''
1.upto(i * bunny.last.length) { |j| space="#{space}#{j.odd? ? '.' : ' '}" }
print bunny.join("\n#{space}")
end
puts "🕳"
@arkku
arkku / moshshell.sh
Last active July 9, 2019 18:02
mosh + tmux helper to kill disconnected leftover sessions from the same machine
#!/bin/sh
host="$1"
[ -z "$host" ] && host=homeshell
port="$2"
[ -z "$port" ] && port=60001
slave="$3"
[ -z "$slave" ] && slave=`hostname -s` # use a fixed string if needed
main=$4
[ -z "$main" ] && main=0
@arkku
arkku / disable-root.sh
Last active November 30, 2017 12:01
Script to disable root account on macOS High Sierra
#!/bin/bash
# This script will disable the root account on macOS.
# At the time of writing there is a severe security flaw in macOS High Sierra,
# which allows the root account to be used without any password to gain admin
# access from any of the GUI password dialogs (it will fail once the first time,
# but on subsequent attempts it will accept the empty password).
#
# The commonly circulated workaround is to set a password for the root account,
@arkku
arkku / config.properties
Created October 5, 2017 14:56
SSH key authentication (only) for UniFi
config.system_cfg.1=sshd.auth.key.1.status=enabled
config.system_cfg.2=sshd.auth.key.1.value=AAAA…Z
config.system_cfg.3=sshd.auth.key.1.type=ssh-rsa
config.system_cfg.4=users.1.password=x
@arkku
arkku / buffy_selections.txt
Last active July 28, 2017 11:30
Buffy the Vampire Slayer
Buffy the Vampire Slayer
Buffy the Vampire slayer is a TV series that began in 1997. It has an extensive cast of characters (a pattern typical of the creator Joss Whedon), funny (and intentionally unrealistic) dialogue and tons of pop culture references. Oh, yeah, and there are some vampires and demons, and a girl with superpowers who fights them - but all that is of secondary importance.
It is highly recommended to watch the entire series, but given that it's 7 seasons (plus 5 more in the spin-off series, Angel), and the fact that especially the first seasons are beginning to show their age, it may be easier to get into the series by watching selected episodes. This list is my selection of such recommended episodes.
Even though I've listed episodes throughout the series, I actually recommend starting from season 4 and working your way up to the musical episode (season 6, episode 7). The musical episode is the best thing ever to be made for TV, but please resist the temptation to skip directly to it, s
@arkku
arkku / convert-certs.sh
Last active July 21, 2017 12:16
Converting Apple Push Notification Services certificates
#!/bin/bash
#
# Obtaining Apple Push Notification Services certificates:
#
# 1) In developer.apple.com go to the App Id, and configure the push
# certificates. Follow Apple's instructions for creating the signing
# requests and generating the certificates.
#
# 2) Download the certificates and import them into the local keychain.
#
@arkku
arkku / tmx
Last active October 5, 2017 15:10
Arkku's tmux wrapper script
#!/bin/sh
# A wrapper for running tmux. Takes on (optional) main session name as
# argument, creates it if it doesn't exist. Then (in either case),
# a new slave session is created and attached to the main session.
# The slave session is configured to be destroyed automatically when
# detached, but the main session stays alive. This arrangement allows
# each slave session to have independent control over active windows/panes.
#
# (Make sure ~/.tmux.conf does not interfere by having something like
# `new-session` or `attach-session` in it.)
@arkku
arkku / ror_puzzle.c
Last active August 29, 2015 14:25
ROR puzzle
uint32_t ror(const uint32_t w, const unsigned rot) { // ROtate Right (bits move `rot` places right w/ wraparound)
return (w >> rot) | (w << (32 - rot));
}
uint32_t a; // = ?
uint32_t rotation = 13;
uint32_t b = 0x29d34b82;
// b == a ^ ror(a, rotation)