Skip to content

Instantly share code, notes, and snippets.

View AlephAlpha's full-sized avatar

AlephAlpha

View GitHub Profile
@AlephAlpha
AlephAlpha / luna_pinyin.cthulhu.dict.yaml
Created August 10, 2018 07:39
Rime 克苏鲁神话词库,手动整理,欢迎补充。
# Rime custom dictionary
# encoding: utf-8
#
# Rime 克苏鲁神话词库
# 手动整理,欢迎补充
#
# 参考资料:
# * Frend《邪神与那些创造邪神的人》
# https://www.zhihu.com/people/frend-10/posts
# * 艾守义《克苏鲁神话:萌萌哒古神在哪里》
# pip install python-lifelib
from math import log2
from lifelib.pythlib.pattern import Pattern
import lifelib
import sys
def get_gen(pat: Pattern, maxexp: int) -> int | None:
x = pat
@AlephAlpha
AlephAlpha / greek.dict.yaml
Last active December 5, 2022 08:19
Rime 的希腊字母输入方案,也支持一些常用的数学符号。如果需要在其他输入方案中直接输入希腊字母,请参考:https://gist.github.com/lotem/3705586
# Rime dictionary
# encoding: utf-8
---
name: greek
version: "0.1"
sort: original
...
# 小写希腊字母
@AlephAlpha
AlephAlpha / Gomoku.nb
Last active April 29, 2022 10:34
Gomoku game in Mathematica.
DynamicModule[{board, winner, p, pmouse, ppossible, v, Reset},
Reset[] := {winner, board} = {"", ConstantArray[0, {20, 20}]};
Reset[]; Deploy@
Graphics[Button[{Brown, Rectangle[{0, 0}, {20, 20}], Black,
Line[Join @@
Table[{{{i, 0}, {i, 20}}, {{0, i}, {20, i}}}, {i, .5, 19.5}]],
Dynamic[pmouse =
Ceiling@MousePosition["Graphics", {-1, -1}] /. {0 -> 1,
21 -> 20};
If[1 <= Min@pmouse <= Max@pmouse <= 20 &&
@AlephAlpha
AlephAlpha / z3_life_search.py
Last active March 30, 2021 01:21
试玩 Z3……速度好慢,搜个 25P3H1V0.1 都要十几秒。懒得支持生命游戏以外的规则以及对称性了。
#!/usr/bin/env python
from z3 import *
import sys
class LifeSearch:
nbhd = {(i, j): 1 if i == j == 0 else 2
for i in range(-1,2)
for j in range(-1,2)}
@AlephAlpha
AlephAlpha / PKGBUILD
Last active November 9, 2020 03:55 — forked from maksverver/PKGBUILD
golly-4.0 PKGBUILD
# Maintainer: Kyle Sferrazza <kyle.sferrazza@gmail.com>
# Contributor: Maks Verver <maksverver@geocities.com>
# Contributor: p2k <Patrick.Schneider@uni-ulm.de>
# Contributor: nokangaroo <nokangaroo@aon.at>
pkgname=golly
pkgver=4.0
pkgrel=1
pkgdesc="A simulator for Conway's Game of Life and other cellular automata"
@AlephAlpha
AlephAlpha / snake
Last active May 21, 2020 16:10
Snake game in Mathematica.
Module[{a, s, d, f}, RemoveScheduledTask@ScheduledTasks[];
a[] := s =
If[#[[1]] == f,
f = RandomChoice[Complement[Tuples[Range /@ {34, 55}], #]]; #,
Most@#] &@PrependTo[s, s[[1]] + d]; s = {{17, 28}};
f = {18, 28}; d = {1, 0};
RunScheduledTask[
If[1 <= #[[1]] <= 34 && 1 <= #[[2]] <= 55 && FreeQ[Most@s, #] &[
s[[1]] + d], a[],
s = Position[
@AlephAlpha
AlephAlpha / _tealdeer
Last active July 22, 2019 09:12
zsh autocompletion for tealdeer, a tldr implementation in Rust (https://github.com/dbrgn/tealdeer )
#compdef tldr
_arguments : \
{-h,--help}'[Print the help message]' \
{-v,--version}'[Show version information]' \
{-l,--list}'[List all commands in the cache]' \
{-f,--render}'[Render a specific markdown file]:file:_files' \
{-o,--os}'[Override the operating system]:type:(linux osx sunos windows other)' \
{-u,--update}'[Update the local cache]' \
{-c,--clear-cache}'[Clear the local cache]' \
@AlephAlpha
AlephAlpha / webcomics.wl
Last active June 5, 2019 03:08
转发网漫的Mathematica脚本(已放到 GitHub:https://github.com/AlephAlpha/WebComics ,此处不再更新)
#!/usr/bin/env wolframscript
appURL = " https://github.com/AlephAlpha/WebComics";
weiboAPI = "https://api.weibo.com/2/statuses/share.json";
(* 请设成脚本所在的目录 *)
(* 目录名有中文时必须先转 UTF8 *)
SetDirectory[
FromCharacterCode[
ToCharacterCode@"/home/alephalpha/文档/马甲与小号/WebComics/", "UTF8"]];
@AlephAlpha
AlephAlpha / StillLife.m
Last active July 18, 2018 13:27
Game of Life still life searcher in Mathematica
SearchStillLife[w_, h_] :=
Block[{r = RandomInteger[1, {w, h}]},
ArrayPlot[
Echo[Mod[r + ArrayReshape[Boole@#, {w, h}], 2], "RLE: ",
"x = " <> #2 <> ", y = " <> #1 <> ", rule = B3/S23\n" & @@
ToString /@ Dimensions@# <>
StringRiffle[
StringCases[
StringReplace[
StringReplace[