Skip to content

Instantly share code, notes, and snippets.

@hnOsmium0001
hnOsmium0001 / README.md
Created December 8, 2023 06:40
Doom Emacs org-mode CJK separate font

这份配置其实并不怎样。它工作原理是这样的:调用 (buffer-face-mode) 以替换当前buffer的默认face,而org-mode所用的各种face都会从默认face继承font-family。我也不太记得为什么要新建一个fontset而不是直接写 (font-spec :family "Blah") 以得到制定好中文字体的face了,大概和不用fontset没法正确设置ASCII范围字符有关吧。

说实话如果不管你用不用Doom Emacs,都应该直接用 (custom-theme-set-faces) 来直接操作 org-default 这个face,总会比这个方案靠谱一些……

class StringView(
val string: String,
val offset: Int,
val length: Int,
) : Iterable<Char> {
constructor(string: String) : this(string, 0, string.length)
init {
val end = offset + length
assert(offset >= 0 && offset < string.length)
@hnOsmium0001
hnOsmium0001 / CraftJPlus.java
Created August 22, 2021 22:09
A general Java library, for syntax sugars and beautifuler implementations.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
@hnOsmium0001
hnOsmium0001 / WindowsGuiSubsystemWithMain.cmake
Last active July 27, 2021 18:27
CMake snippet to add to CMakeLists.txt to make some target use `int main()` while building to the GUI ("windows") subsystem.
# No console window when targetting windows
if(WIN32)
function(handle_gnu_style_compiler)
# Supposedly the flag -mwindows would automatically make the executable use GUI subsystem
# But, when subsystem is set to GUI, linker will only search WinMain and wWinMain but not the standard main (it seems like)
# so creating GUI executable fails and the linker silently reverts to the default, CUI subsystem
target_link_options(${TARGET_NAME} PRIVATE -Wl,-subsystem:windows)
target_link_options(${TARGET_NAME} PRIVATE -Wl,-entry:mainCRTStartup)
endfunction()
function(handle_msvc_style_compiler)
@hnOsmium0001
hnOsmium0001 / fabric.build.gradle
Created May 31, 2020 19:14
Minecraft mod publishing to Bintray
bintray {
user = findProperty('bintray.user')
key = findProperty('bintray.apiKey')
publications = ['BintrayPublication']
pkg {
repo = 'Maven'
name = '<your-artifact-id>'
licenses = ['<your-license>']
vcsUrl = '<your-git-repository-url>'
version {
@hnOsmium0001
hnOsmium0001 / blueprint_book.txt
Created May 2, 2020 19:47
Factorio 600 SPM Assemblies (beaconed, belt-only)
0eNrUvc1uY0eyLfwqRo2bRkb+p3EnfSd31EDj9uiiYRgsFW0TrZIEinIffwf17h+pEqldVbm511op2n0mp49VUmTsyIj8iVyx4r/fvb992jzstnf7n97f3//r3Q///fqTx3c//HPyn8d/297c333+8eP2l7v17fFn+98fNu9+eLfdbz6++8u7u/XH43+936wPv/ru01/ebe8+bP7r3Q/26S+Lf7R+fNx8fH+7vftl9XF98+v2brMKExEeEfG0v/+43m/v71aPN9vN3c1m9bC++ddESvj041/ebe722/128/lTnv/j95/unj6+3+wOmp6FHT92v77br27uP77f3q3397vDSA/3j9vjAEcdDvJWh9///fg/+TDG4S/2u/vbn95vfl3/tj38+uF3ft7e7jc7yGrb3UHvh9v1fvPuWdjT0eo2seGPn442+Ephzykc3k7fm/uHh82O1zicJWz+62G3eXxc7Xfru8eH+91+9X5zu79g5XgY5sN2t7n5/I+xIz3S0gMuPNHC3Ytw/6Vw3xGedbsA0osuPSwbpn4j/engA7tfdgef+LBg96+UP0zgyd3uHp727zqjNXmOgU8x9/U69q1l0os4d1xZDkHxePyHx4fN5sPq4/2Hp9vj0nWYhZ701wXm4+bD9unjanN70Ga3vVk93N9uOmOdVLeuOC8Y/izS0Za31+A9rDU3/1pt7x43u8OK0RnF90fpOadFWKy7aI6Eq2cXBeXL+9KcWu3wrYcv3T6cF/RfNuvd6t+/bja37ya+8rA7uMnBIL8dBp24TOzqUhYdcsAfK+zthRfOB+rJa+pyoHrHSw9d6T2X9CZLb4Duno6jBugcyMXlLLonLKJuxzuGT7JjFMC4WZaev5See9LLwJJb5lbc+6f9zJLrq+yIGbBV0xa6PF3o5s7d4oIXXgP75/Xj/kJs4LMW7EuZ8PEk03tk8PCSGunICfwGHAHrRFpqAqQm2XOBs3jIsvQESC9aXIRrxkWFZ6k/Sb09IzRWaFwWGp1+H4h0wEX
@hnOsmium0001
hnOsmium0001 / BackgroundRenderers.java
Created October 14, 2019 22:30
Vanilla panel at any size
package powerlessri.harmonics.gui.screen;
import com.google.common.base.Preconditions;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.util.ResourceLocation;
import powerlessri.harmonics.HarmonicsCore;
import powerlessri.harmonics.gui.ITexture;
import powerlessri.harmonics.gui.Texture;
import static powerlessri.harmonics.gui.Render2D.*;
@hnOsmium0001
hnOsmium0001 / IItemFilter.java
Created August 6, 2019 21:58
Item filtering logic
import net.minecraft.item.ItemStack;
@FunctionalInterface
public interface IItemFilter {
boolean isValid(ItemStack stack);
}
package vswe.stevesfactory.library.gui.widget;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.GLAllocation;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.opengl.GL11;
import vswe.stevesfactory.library.gui.debug.RenderEventDispatcher;
import vswe.stevesfactory.library.gui.widget.mixin.*;
import vswe.stevesfactory.utils.RenderingHelper;
@hnOsmium0001
hnOsmium0001 / RelativeDirection.java
Last active June 14, 2019 21:16
Finding relative direction between two BlockPos, assuming they are neighbors
// Inlined because apparently applications of pure function with constants are not considered constants
private static final int DOWN_BITS = 0b010100; // calculateDirectionBits(0, -1, 0)
private static final int UP_BITS = 0b010110; // calculateDirectionBits(0, 1, 0)
private static final int NORTH_BITS = 0b010001; // calculateDirectionBits(0, 0, -1)
private static final int SOUTH_BITS = 0b011001; // calculateDirectionBits(0, 0, 1)
private static final int WEST_BITS = 0b000101; // calculateDirectionBits(-1, 0, 0)
private static final int EAST_BITS = 0b100101; // calculateDirectionBits(1, 0, 0)
private static int calculateDirectionBits(int dx, int dy, int dz) {
// Add 1 to make all offsets positive to avoid dealing with complement bits