Skip to content

Instantly share code, notes, and snippets.

View cxa's full-sized avatar
🦥

realazy cxa

🦥
View GitHub Profile
@cxa
cxa / orderless.org
Created November 7, 2023 01:04
My orderless config

Orderless

Orderless is a robust improvement to the Emacs completion system, offering high adaptability through the configuration of dispatchers.

Dispatchers

I often utilize the following completion style:

  • For strings that contain ` (regardless of position), treat them as \`regex:
@cxa
cxa / org-edit-src-code-before.el
Last active October 4, 2023 07:47
Enable `eglot` for org babel code editor
(require 'eglot) ;; avoid `eglot--lookup-mode' being void
(defun sloth/org-babel-edit-prep (info)
(setq buffer-file-name (or (alist-get :file (caddr info))
"org-src-babel.tmp"))
(eglot-ensure))
(advice-add 'org-edit-src-code
:before (defun sloth/org-edit-src-code/before (&rest args)
(when-let* ((element (org-element-at-point))
@cxa
cxa / org-babel-C-execute-filter-args.el
Last active October 3, 2023 12:23
Support `:stdin` for `ob-C` for org-mode
(advice-add 'org-babel-C-execute
:filter-args
(defun sloth/org-babel-C-execute/filter-args (args)
(when-let* ((params (cadr args))
(stdin (cdr (assoc :stdin params)))
(res (org-babel-ref-resolve stdin))
(stdin (org-babel-temp-file "c-stdin-")))
(with-temp-file stdin (insert res))
(let* ((cmdline (assoc :cmdline params))
(cmdline-val (or (cdr cmdline) "")))
@cxa
cxa / regexCheatsheet.js
Last active August 14, 2023 10:01 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* 匹配特定的字符串 */
regex = /hello/; // 查找斜杠中的字符串(大小写敏感)……匹配 "hello", "hello123", "123hello123", "123hello",但不匹配 "hell0", "Hello"
regex = /hello/i; // 查找斜杠中的字符串(大小写不敏感)……匹配 "hello", "HelLo", "123HelLO"
regex = /hello/g; // 全局查找斜杠中的字符串……
/* 通配符 */
regex = /h.llo/; // "." 匹配除了换行外的任何一个字符……匹配 "hello", "hallo",但不匹配 "h\nllo"
regex = /h.*llo/; // "*" 匹配任何字符零次或多次,如 "hello", "heeeeeello", "hllo", "hwarwareallo"
@cxa
cxa / fonts.el
Last active December 1, 2022 06:56
(setq cxa/font-pairs
'((default
:heading (:family "TheFutureFZYouHei" :weight bold :slant normal)
:body (:family "WCaslonZZMC" :height 270)
:code (:family "PitchFZ" :height 200))
(brill
:heading (:family "TheFutureFZYouHei" :weight bold :slant normal)
:body (:family "Brill" :height 270)
:code (:family "PitchSansOPPO" :height 200))
(questa
#!/usr/bin/env node
// npm i -g @mozilla/readability puppeteer
const puppeteer = require("puppeteer");
const fs = require("fs");
const readabilityJsStr = fs.readFileSync(
require.resolve("@mozilla/readability/Readability.js"),
{ encoding: "utf-8" }
);
- (void)drawRect:(NSRect)rect
{
// Drawing code here.
CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
CGContextSetTextMatrix(context, CGAffineTransformIdentity);
NSAttributedString *str = [[NSAttributedString alloc ]
initWithString:@"学习 Core Text. Learning Core Text. 中华人民共和国。"
attributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSFont fontWithName:@"Adobe Song Std" size:24.0f], (NSString *)kCTFontAttributeName, [NSNumber numberWithBool:YES], (NSString *)kCTVerticalFormsAttributeName, nil]];
CFAttributedStringRef attrString = (CFAttributedStringRef)str;
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(attrString);
@cxa
cxa / dotnet.doc.md
Created April 19, 2021 02:32
.NET 文档书签

创建一个新书签,将以下内容作为书签的 url:

javascript:(()=> { const ns = prompt('namespace and/or class (e.g. system.net.http)'); ns && (window.location=`https://docs.microsoft.com/en-us/dotnet/api/${ns}?view=net-5.0`)})()
@cxa
cxa / cascadelist.m
Created May 11, 2012 08:19 — forked from jjgod/cascadelist.m
Use cascade list attribute to customize font fallback in Core Text
#import <ApplicationServices/ApplicationServices.h>
#import <Foundation/Foundation.h>
int main(int argc, char *argv[])
{
if (argc != 2)
return 0;
NSAutoreleasePool *pool = [NSAutoreleasePool new];
CFStringRef name = (CFStringRef) [NSString stringWithUTF8String: argv[1]];
Process: Xcode [79975]
Path: /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: Xcode
Version: 9.0 (13247)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Xcode [79975]
User ID: 501
Date/Time: 2017-09-14 20:28:22.458 +0800