Skip to content

Instantly share code, notes, and snippets.

View ApolloZhu's full-sized avatar
🐣
Improving Swift Platform Experience

Zhiyu Zhu/朱智语 ApolloZhu

🐣
Improving Swift Platform Experience
View GitHub Profile
@ApolloZhu
ApolloZhu / can_import_submodule_in_system_framework.swift
Created January 9, 2022 08:24
Testing 'canImport()' non-existing submodule in system frameworks.
// RUN: %target-typecheck-verify-swift
// Testing 'canImport()' non-existing submodule in system frameworks.
#if canImport(CoreImage)
import CoreImage
#if !canImport(CoreImage.CIFilterBuiltins)
#error("Should can import CoreImage.CIFilterBuiltins")
#endif
@ApolloZhu
ApolloZhu / Splitter.swift
Created December 9, 2021 23:12
Word Splitter
import Foundation
public enum Splitter {
/// https://stackoverflow.com/a/62527131
private static let wordBoundaries = #"([^\p{L}\d]+|(?<=\p{L})(?=\d)|(?<=\d)(?=\p{L})|(?<=[\p{Ll}\d])(?=\p{Lu})|(?<=\p{Lu})(?=\p{Lu}\p{Ll})|(?<=[\p{L}\d])(?=\p{Lu}\p{Ll}))"#
static func split(_ string: String) -> AsyncStream<String> {
AsyncStream<String> { continuation in
string
.enumerateSubstrings(in: string.startIndex..., options: .byWords) { (substring, _, _, _) in
We can make this file beautiful and searchable if this error is corrected: It looks like row 5 should actually have 57 columns, instead of 4. in line 4.
ID,Name,Year,Season,English,Japanese,Episodes,Broadcast,Source,Duration,Rating,Score,Members,Favorites,Action,Adventure,Cars,Comedy,Dementia,Demons,Drama,Ecchi,Fantasy,Game,Harem,Hentai,Historical,Horror,Josei,Kids,Magic,Martial Arts,Mecha,Military,Music,Mystery,Parody,Police,Psychological,Romance,Samurai,School,Sci-Fi,Seinen,Shoujo,Shoujo Ai,Shounen,Shounen Ai,Slice of Life,Space,Sports,Super Power,Supernatural,Thriller,Vampire,Yaoi,Yuri
40010,Ishuzoku Reviewers,2020,winter,Interspecies Reviewers,異種族レビュアーズ,12,Saturdays at 23:00 (JST),Manga,23,R+ - Mild Nudity,7.61,168339,17545,,,,1,,,,1,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
38883,Haikyuu To the Top,2020,winter,,ハイキュー!! TO THE TOP,13,Saturdays at 01:25 (JST),Manga,24,PG-13 - Teens 13 or older,8.76,149026,1557,,,,1,,,1,,,,,,,,,,,,,,,,,,,,,1,,,,,1,,,,1,,,,,,
38656,Darwins Game,2020,winter,Darwin's Game,ダーウィンズゲーム,11,Saturdays at 00:00 (JST),Manga,26,R - 17+ (violence & profanity),7.3,130054,646,1,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,1,,,,,,,,,,
39017,Kyokou Suiri,2020,
@ApolloZhu
ApolloZhu / gist:e7871cd8e73522ab512538221aa54917
Created October 26, 2019 22:33
UW ICPC Contestant iOS LinkedIn
linkedin.com/in/jake-jung-0217/
https://homes.cs.washington.edu/~sorawee/scoreboard.html
@ApolloZhu
ApolloZhu / LISP.md
Last active May 20, 2019 06:35
ACSL 版 LISP 语法总结(2018-04-26)

因为没有看过 LISP 官方的文档,ACSL的文档从来都是讲的不明不白,我也只能总结规律,如有不妥,希望大家指正。

LISP 是一种函数式编程语言,里面只有两种数据结构——原子和表。所谓的表,其实就是操作符(函数)、表和原子的集合。

NIL 是一个特例,它既是原子又是表,所以 ’() 也表示空。

表示在被传入到操作符的是值,列表或是字符串,而不是变量。数字前面不要求加上。这同时也可用 (quote variable) 来表示

之后所有的 LISP 函数都会被用 Swift 重现,下面的是可有可无的定义。

fun runTextRecognition(bitmap: Bitmap) {
val image = FirebaseVisionImage.fromBitmap(bitmap)
// FirebaseVisionTextRecognizer will be used
val detector = FirebaseVision.getInstance().visionTextDetector
detector.detectInImage(image)
.addOnSuccessListener {
texts ->
val blocks = texts.blocks
if (blocks.size == 0) { /*nothing found*/ return }
blocks.forEach {
@ApolloZhu
ApolloZhu / CMIMC 2019 Sudoku.txt
Last active February 1, 2019 21:20
A 36x36 matrix, empty spots indicated by 00.
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003616001822000000000000000000000000000000000000000000000000000000000000003405021506000000000000000000000000000000000000000000000000000000000000002501082930000000000000000000000000000000000000000000000000000000000000000020262303321200000000000000000000000000000000360000000000000000000000321224113531330400000000000000000000000000000000340100000000000000000031330428141907211617000000000000000000000000000000252000000000000000001907211617182210360502000000000000000000000000000000132400000000000000002210360502150609340108290000000000000000000000000000122800000000000000000009340108
@ApolloZhu
ApolloZhu / fetchBilibiliFollowers.swift
Created November 22, 2018 03:50
Get the first 250 or 1000 followers of a user on bilibili
let id: Int = /*Replace with your bilibili user id*/
// You can simply copy paste the entire cookie, but the following is the minimum:
// If id is different from DedeUserID (i.e. you don't own such account), this doesn't matter
let cookie = "DedeUserID=XXXX;DedeUserID__ckMd5=XXXXXXXXXXXXXXXX;SESSDATA=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX;"
///////////////////////////////////////
// Code //
///////////////////////////////////////
import Foundation
@ApolloZhu
ApolloZhu / QRCodeRenderer.swift
Created October 20, 2018 18:50
Part of swift_qrcodejs. Deprecated in favor of EyreFree/EFQRCode
/*
Copyright (c) 2017 Zhiyu Zhu/朱智语
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@ApolloZhu
ApolloZhu / agnoster.zsh-theme
Created June 28, 2018 06:13
Basically PS1
prompt_status() {
local symbols
symbols=()
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘ 🤯 "
[[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡ 😎 "
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙ 🤔 "
if [[ -n "$symbols" ]] ; then
prompt_segment black default "$symbols"
else