Skip to content

Instantly share code, notes, and snippets.

View merryhime's full-sized avatar

merry merryhime

  • UK
  • 14:17 (UTC)
View GitHub Profile
@VictorTaelin
VictorTaelin / sat.md
Last active October 17, 2024 04:21
Simple SAT Solver via superpositions

Solving SAT via interaction net superpositions

I've recently been amazed, if not mind-blown, by how a very simple, "one-line" SAT solver on Interaction Nets can outperform brute-force by orders of magnitude by exploiting "superposed booleans" and optimal evaluation of λ-expressions. In this brief note, I'll provide some background for you to understand how this works, and then I'll present a simple code you can run in your own computer to observe and replicate this effect. Note this is a new observation, so I know little about how this algorithm behaves asymptotically, but I find it quite

@kconner
kconner / macOS Internals.md
Last active November 13, 2024 07:51
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@imbushuo
imbushuo / simplevm.c
Last active November 8, 2024 12:10
Demonstrates Hypervisor.Framework usage in Apple Silicon
// simplevm.c: demonstrates Hypervisor.Framework usage in Apple Silicon
// Based on the work by @zhuowei
// @imbushuo - Nov 2020
// To build:
// Prepare the entitlement with BOTH com.apple.security.hypervisor and com.apple.vm.networking WHEN SIP IS OFF
// Prepare the entitlement com.apple.security.hypervisor and NO com.apple.vm.networking WHEN SIP IS ON
// ^ Per @never_released, tested on 11.0.1, idk why
// clang -o simplevm -O2 -framework Hypervisor -mmacosx-version-min=11.0 simplevm.c
// codesign --entitlements simplevm.entitlements --force -s - simplevm
# Polyrhythmic Prime Discovery
# by Leonard Ritter <[email protected]>
primes = []
phases = []
counter = 2
def is_any_phase_zero ():
@wareya
wareya / find.py
Last active March 13, 2018 00:04
search for han characters based on a list of components
#!python
# coding=utf-8
# Get ids.txt from https://github.com/cjkvi/cjkvi-ids/ and place it next to this script
# ~requires python 3.6 or newer on windows~
# note: depends on the accuracy of ids.txt. for some characters, like 祭, it's pretty bad.
# see also: http://www.chise.org/ids-find
contains = {}
@hthh
hthh / a-diff.py
Last active March 10, 2024 23:47
Switch IPC changes
from data1 import data1
from data2 import data2
from data3 import data3
from data4 import data4
from data500 import data500
from data600 import data600
from data610 import data610
from data700 import data700
all_data = (data1, data2, data3, data4, data500, data600, data610, data700)
@NocturnDragon
NocturnDragon / Swizzles.h
Last active October 15, 2023 01:20
Swizzles in Clang, GCC, and Visual c++
#include <stdio.h>
// #define CLANG_EXTENSION
// Clang compile with -O3
#define VS_EXTENSION
// https://godbolt.org/z/sVWrF4
// Clang compile with -O3 -fms-compatibility
// VS2017 compile with /O3
@graphitemaster
graphitemaster / WORKING_AROUND_OFFSETOF_LIMITATIONS.MD
Last active November 14, 2024 20:59
Working around offsetof limitations in C++

Working around offsetof limitations in C++:

There is sometimes a situation in which one needs to get the relative offset of a structure field, common examples of this include serialization frameworks which aid to serialize objects, vertex attributes for rendering (D3D, GL.), etc.

The most common technique for getting this information is through the offsetof macro defined in stddef.h. Unfortunately using the macro in C++ comes with a new set of restrictions that prevent some (subjectively valid) uses of it.

@ocornut
ocornut / (Archived) imgui_memory_editor.h
Last active August 28, 2024 05:01
Mini memory editor for dear imgui (to embed in your game/tools)
// Mini memory editor for Dear ImGui (to embed in your game/tools)
// Animated GIF: https://twitter.com/ocornut/status/894242704317530112
// THE MEMORY EDITOR CODE HAS MOVED TO GIT:
// https://github.com/ocornut/imgui_club/tree/master/imgui_memory_editor
// Click "Revisions" on the Gist to see old version.
# Poker II Firmware disassembly help tool.
original = IO.read("./Poker II original firmware.bin")
extracted = ""
original.each_byte{|b|
m = (((b & 0x0f) << 4) | ((b & 0xf0) >> 4)) ^ 0xff
extracted << m.chr
}
puts extracted