Skip to content

Instantly share code, notes, and snippets.

View jyc's full-sized avatar

jyc

View GitHub Profile

From Cryptonomicon by Neal Stephenson

The friendliest and most sincere welcome he’d gotten was from Scott, a chemistry professor, and Laura, a pediatrician, who, after knowing Randy and Charlene for many years, had one day divulged to Randy, in strict confidence, that, unbeknownst to the academic community at large, they had been spiriting their three children off to church every Sunday morning, and even had them all baptized. Randy had gone into their house once to help Scott wrestle a freshly reconditioned clawfoot bathtub up the stairs, and had actually seen the word GOD written on actual pieces of paper stuck to the walls of their house—like on the refrigerator door, and the walls of the children’s bedrooms, where juvenile art tends to be reposited. Little time-wasting projects they had done during Sunday school—pages torn from coloring books, showing a somewhat more multicultural Jesus than the one Randy had grown up with (curly hair, e.g.), talking to little biblical kids or assisting disoriented Holy

// cc -O3 -o dotproduct dotproduct.c -march=native -ffast-math
//
// Pretty much just Prof. Daniel Lemire's code, hacked by me
// All errors are mine
//
// Prof. Lemire says in https://github.com/lemire/Code-used-on-Daniel-Lemire-s-blog/blob/master/README.md:
// Unless otherwise stated, I make no copyright claim
// on this code: you may consider it to be in the public
// domain.
// Don't bother forking this code: just steal it.
@jyc
jyc / build-macos-xcode-app-and-publish-sparkle-update.sh
Last active November 9, 2023 06:32
Bash script to build a (macOS) Xcode app and publish an update using Sparkle
#!/bin/bash
set -euo pipefail
# TO CREATE ExportOptions.plist:
# Product > Archive then Window > Organizer > Archives, Distribute App, Distribute Directly doesn’t seem to work!
# Use Archives > Distribute App, Custom, Developer ID, Export seems to work… DO NOT click Upload!
#
# BEFORE RUNNING:
# Create an app-specific password; call it "Foobar Build Scripts": https://support.apple.com/en-us/102654
# Then run:
!nvcc --version
#nvcc: NVIDIA (R) Cuda compiler driver
#Copyright (c) 2005-2022 NVIDIA Corporation
#Built on Tue_Mar__8_18:18:20_PST_2022
#Cuda compilation tools, release 11.6, V11.6.124
#Build cuda_11.6.r11.6/compiler.31057947_0
%pip install -U --only-binary :all: xformers transformers==4.31.0 torch accelerate einops bitsandbytes==0.39.1 peft sentencepiece boto3 'tokenizers>=0.13.3'
--------------------
-- Window Chooser -- 🚻
--------------------
-- Originally: https://github.com/dmgerman/dmg-hammerspoon/blob/f8da75d121c37df40c0971336eb3f67c73d67187/dmg.spoon/init.lua#L115-L224
WC = {}
WC.wf = hs.window.filter.new()
WC.wf:setDefaultFilter{}
WC.currentWindows = {}
--------------------
-- Window Chooser -- 🚻
--------------------
-- Originally: https://github.com/dmgerman/dmg-hammerspoon/blob/f8da75d121c37df40c0971336eb3f67c73d67187/dmg.spoon/init.lua#L115-L224
WC = {}
WC.wf = hs.window.filter.new()
WC.wf:setDefaultFilter{}
WC.currentWindows = {}
function isLeapYear(date) {
var year = date.getFullYear();
if((year & 3) != 0) return false;
return ((year % 100) != 0 || (year % 400) == 0);
};
// https://stackoverflow.com/a/26426761
function getDOY(date) {
var dayCount = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
var mn = date.getMonth();
Manfred wonders, his head turgid and unnaturally slow. It's like being drunk, except much less pleasant: He can't seem to wrap his head around an idea from all angles at once, anymore. Is this what consciousness used to be like? It's an ugly, slow sensation. She turns away from him: "Medline says you'll be all right in a while. The main problem is the identity loss. Are you backed up anywhere?"
"Here." Alan, still top-hatted and mutton-chopped, holds out a pair of spectacles to Manfred. "Take these, they may do you some good." His topper wobbles, as if a strange A-life experiment is nesting under its brim.
"Oh. Thank you." Manfred reaches for them with a pathetic sense of gratitude. As soon as he puts them on, they run through a test series, whispering questions and watching how his eyes focus: After a minute, the room around him clears as the specs build a synthetic image to compensate for his myopia. There's limited Net access, too, he notices, a warm sense of relief stealing over him. "Do you mind if I c
#!/bin/zsh
cd "$2"
ellipsize() {
# Shouldn't add ellipsis if we didn't actually need to ellipsize.
ellipsized="$(echo "$1" | cut -f 1-8 -d' ' | cut -c 1-32)"
if [[ "$ellipsized" != "$1" ]]; then
echo "$ellipsized…"
else
PROMPT='%B%F{$PROMPT_COLOR}[%n@%m %1~%(#.#.)]%f%b $PROMPT_EXTRA%f
%B%F{$PROMPT_ARROW_COLOR}→%f%b '