Skip to content

Instantly share code, notes, and snippets.

@ksqsf
ksqsf / .zshenv
Last active January 15, 2024 17:58
My zsh config
# Kitchen-sink for setting PATHs and other environmental variables.
# Also read by Emacs's exec-path-from-shell, so it has to be very short and fast.
export HOMEBREW_NO_INSTALL_FROM_API=1
export HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"
@ksqsf
ksqsf / logseq.py
Last active July 15, 2024 20:49
Python interface to Logseq remote API
import requests
import json
# Doc site: https://plugins-doc.logseq.com/ .
# This list is auto-generated from https://github.com/logseq/plugins/tree/master/docs .
apis = [
'logseq.settings',
'logseq.updateSettings',
'logseq.once',
'logseq.toggleMainUI',
@ksqsf
ksqsf / biliaudio.lisp
Created October 29, 2022 06:56
下载 Bilibili 音频
(ql:quickload :dexador) ;; HTTP
(ql:quickload :yason) ;; JSON
(defun download-bilibili-audio (audio-id)
(let* ((headers '(("User-Agent" . "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/600.3.18 (KHTML, like Gecko) Version/8.0.3 Safari/600.3.18")
("Referer" . "https://bilibili.com")))
(cover-json (yason:parse (dex:get (format nil "https://www.bilibili.com/audio/music-service-c/web/song/info?sid=~a" audio-id))))
(cover-url (gethash "cover" (gethash "data" cover-json)))
(cover-data (dex:get cover-url))
(audio-json (yason:parse (dex:get (format nil "https://www.bilibili.com/audio/music-service-c/web/url?sid=~a" audio-id))))
@ksqsf
ksqsf / biliaudio.rs
Created May 18, 2022 18:49
下载 Bilibili 音频
#!/usr/bin/env cargo play -q
//# anyhow = "*"
//# reqwest = {version="*", features=["gzip","blocking"]}
//# serde_json = "*"
fn main() -> anyhow::Result<()> {
let audio_id = "832257";
let client = reqwest::blocking::Client::new();
let body = client.get(format!("https://www.bilibili.com/audio/music-service-c/web/song/info?sid={}", audio_id)).send()?.text()?;
let resp = &serde_json::from_str::<serde_json::Value>(&body)?["data"]["cover"];
let cover_url = resp.as_str().unwrap();
@ksqsf
ksqsf / biliaudio.hs
Last active June 15, 2022 08:16
下载 Bilibili 音频
#!/usr/bin/env cabal
{- cabal:
build-depends: base, relude, aeson, microlens-aeson, microlens-platform, http-conduit, conduit, conduit-extra, async
-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Main where
import Control.Concurrent.Async
@ksqsf
ksqsf / biliaudio.py
Last active May 13, 2022 11:27
下载 Bilibili 音频(编号以 au 开头的投稿)
import requests
#
# *** 修改这个 ***
#
audio_id = '832257'
# 完事后会下载到一个 m4a 文件和一个 cover.jpg

Keybase proof

I hereby claim:

  • I am ksqsf on github.
  • I am ksqsf (https://keybase.io/ksqsf) on keybase.
  • I have a public key ASDeVaqf2TVkWAwoSMtQcBtMNhw8mKc7r-APIwQe8wSV2Ao

To claim this, I am signing this object:

@ksqsf
ksqsf / wordle.hs
Created January 23, 2022 02:53
Wordle assistant
{-
HOWTO: use 'tellWords' to find possible inputs, guess, and then update 'rules'.
-}
module Main where
import System.IO
import Control.Monad.ST
import Data.Array.MArray
import GHC.Arr
@ksqsf
ksqsf / lambdacats.hs
Created January 21, 2022 07:24
A script to create the Lambdacats sticker pack
#!/usr/bin/env cabal
{- cabal:
build-depends: base, scalpel, process, async, filepath, directory
ghc-options: -threaded -rtsopts -with-rtsopts=-N
-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Monad
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DataKinds #-}
import Control.Monad.IO.Class
import Data.Proxy
import GHC.Exts
import GHC.OverloadedLabels (IsLabel(..))
import GHC.TypeLits