Skip to content

Instantly share code, notes, and snippets.

View jiacai2050's full-sized avatar
🏓
Focusing

Jiacai Liu jiacai2050

🏓
Focusing
View GitHub Profile
@jiacai2050
jiacai2050 / mu4e-config.el
Created August 29, 2022 13:13
Emacs mu4e config
;; Mail start
(use-package mu4e
:ensure nil
:if (executable-find "mu")
:commands (mu4e)
:bind (:map mu4e-view-mode-map
("f" . mu4e~headers-jump-to-maildir)
("9" . scroll-down-command)
("0" . scroll-up-command)
("&" . my/open-url-in-external)
//! `yes` unix command in Zig, optimized for speed
//! Reference to: https://github.com/cgati/yes
const std = @import("std");
const BUFFER_CAP = 64 * 1024;
fn fill_up_buffer(buf: *[BUFFER_CAP]u8, word: []const u8) []const u8 {
if (word.len > buf.len / 2) {
return word;
@jiacai2050
jiacai2050 / zig-blog-posts.md
Created July 18, 2022 02:41 — forked from LewisGaul/zig-blog-posts.md
Collection of blog posts about the Zig programming language
const std = @import("std");
const fs = std.fs;
const log = std.log;
const os = std.os;
fn walk(dir: fs.Dir) anyerror!void {
var it = dir.iterate();
loop: {
while (it.next()) |entry| {
if (entry) |e| {
@jiacai2050
jiacai2050 / osx-ld.md
Created March 28, 2022 14:29 — forked from loderunner/osx-ld.md
potential blog posts

ld – Wading through Mac OS X linker hell

Intro

Friend: I tried looking at static linking in Mac OS X and it seems nearly impossible. Take a look at this http://stackoverflow.com/a/3801032

Me: I have no idea what that -static flag does, but I'm pretty sure that's not how you link to a library. Let me RTFM a bit.

Minutes later...

Estimated Emacs Memory Usage
62.4 GiB Total Buffer Memory Usage
5.4 GiB Memory Used By Global Variables
4.9 GiB Overall Object Memory Usage
1.8 GiB Memory Used By Symbol Plists
148.2 MiB Reserved (But Unused) Object Memory
0.0 KiB Total Image Cache Size
Object Storage
@jiacai2050
jiacai2050 / before
Last active August 31, 2021 00:28
emacs init benchmark
Benchmark results
╼►[benchmark-init/root nil 6987ms]
├─[xdg require 14ms]
├─[swiper require 12ms]
├─[/Applications/Emacs.app/Contents/Resources/lisp/term/xterm.elc load 6ms]
├─[vc-git load 22ms]
│ ╰─[diff-mode require 18ms]
├─[~/.config/emacs/etc/yasnippet/snippets/emacs-lisp-mode/.yas-setup load 0ms]
├─[~/.config/emacs/etc/yasnippet/snippets/emacs-lisp-mode/.yas-compiled-snippets load 0ms]
@jiacai2050
jiacai2050 / name-calling.md
Created February 24, 2021 15:03 — forked from coolaj86/name-calling.md
What we call programmers - because labels make us happy! http://youtu.be/uxeR95aYer0#t=58
@jiacai2050
jiacai2050 / latency.txt
Created January 10, 2021 09:33 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD