Skip to content

Instantly share code, notes, and snippets.

View berkus's full-sized avatar
🪢
~consume.enhance.replicate~

Berkus Decker berkus

🪢
~consume.enhance.replicate~
View GitHub Profile
@berkus
berkus / xbox-one-wireless-protocol.md
Created April 4, 2019 13:21 — forked from alfredkrohmer/xbox-one-wireless-protocol.md
XBox One Wireless Controller Protocol

Physical layer

The dongle itself is sending out data using 802.11a (5 GHz WiFi) with OFDM and 6 Mbit/s data rate:

Radiotap Header v0, Length 38
    Header revision: 0
    Header pad: 0
    Header length: 38
    Present flags
@berkus
berkus / build.yml
Last active March 20, 2026 11:25
Disable windows defender to speed up builds
- name: Disable Windows Defender on build dirs
if: runner.os == 'Windows'
run: |
Add-MpPreference -ExclusionPath "$env:GITHUB_WORKSPACE"
Add-MpPreference -ExclusionPath "$env:USERPROFILE\.cargo"
@berkus
berkus / gist:8225683
Created January 2, 2014 20:01
Working with GitHub pull requests from git

From http://www.somethingorothersoft.com/2012/05/22/pulling-github-pull-requests-with-git/

Fetch all Pull Requests (even closed ones)

Just execute the following commands and you'll be able to fetch all pull requests by simply executing git fetch pr. Pull requests will be stored in a remote as individual remote branches. So a pull request 123 will be accessible as 'pr/123':

git remote add pr https://github.com/upstream/repo.git
git config --local --unset remote.pr.fetch
git config --local --add remote.pr.fetch "+refs/pull/*/head:refs/remotes/pr/*"
@berkus
berkus / lyrics.txt
Created October 20, 2025 21:49
Jonne Valtonen's (Purple Motion) Mosaic Days lyrics
Sun, may you shine down on us
let us rejoice in your warmth
in delight,
in delight
Come, sit by me on the ground
we'll chase away the demons
fly, over the hills,
of memories
@berkus
berkus / HOWTO.md
Created October 20, 2025 21:47
How to extract data from the Yojimbo3 database:
  1. rg -a "text match", note the database file to use
  2. sqlite3 Database.db
  3. .tables
  4. .schema <table>
  5. select... until you find the ZBLOB's table primary key Z_PK
  6. Save it to file with SELECT writefile('out.plist', ZBYTES) FROM ZBLOB WHERE Z_PK=298; <-- use your pk
  7. Convert plist to text format with plutil -convert xml1 out.plist
  8. Open it with an editor and find your contents among shitloads of metadata
@berkus
berkus / main.rs
Created October 20, 2025 08:55
Rust undroppable
// From https://jack.wrenn.fyi/blog/undroppable/
use std::mem;
/// A type that cannot be dropped.
pub struct Undroppable<T: ?Sized>(mem::ManuallyDrop<T>);
impl<T> Undroppable<T> {
// Makes `val` undroppable.
//
@berkus
berkus / convemoji.md
Last active October 2, 2025 03:14
Conventional Commits with Emoji
@berkus
berkus / pijularize.sh
Created January 21, 2022 08:18
Pijularize a Git repository with all branches
#!/bin/sh
set -e
set -x
reponame=`basename $(pwd)`
echo "#######################################################################################"
echo "# Script to import all local branches from current repository (${reponame}) into pijul"
echo "# Will create a bunch of temp repos for import, so have sufficient disk space"
echo "#######################################################################################"

1. Separation of immutable and mutable logic

Quite a lot of different people have been on the same trail of thought. Gary Bernhardt's formulation of a "functional core, imperative shell" seems to be the most voiced.

"Boundaries" - Gary Bernhardt

"Imperative shell" that wraps and uses your "functional core".. The result of this is that the shell has fewer paths, but more dependencies. The core contains no dependencies, but encapsulates the different logic paths. So we’re encapsulating dependencies on one side, and business logic on the other side. Or put another way, the way to figure out the separation is by doing as much as you can without mutation, and then encapsulating the mutation separately. Functional core — Many fast unit tests. Imperative shell — Few integration tests

https://www.youtube.com/watch?v=yTkzNHF6rMs

@berkus
berkus / anyfile.groovy
Created May 8, 2024 18:00
Groovy/Gradle print object properties
def filtered = ['class', 'active']
println theObject.properties
.sort{it.key}
.collect{it}
.findAll{!filtered.contains(it.key)}
.join('\n')