Skip to content

Instantly share code, notes, and snippets.

View gyk's full-sized avatar

Yukun Guo gyk

  • Hangzhou, China
  • 08:51 (UTC +08:00)
View GitHub Profile

Question

Regarding user subscription to our SaaS using Stripe: when they subscribe for the first time, upon receiving "checkout.session.completed" event, is it possible that the user has NOT paid the invoice?

And, on the first subscription, is "invoice.paid" usually sent before "checkout.session.completed" (if they pay immediately)? If they pay it later, will "invoice.paid" come later?

Answer (by Claude Sonnet 4.5)

Great questions about Stripe's webhook event ordering! Let me search for the most current information on this.Great questions! Here's what you need to know about Stripe subscription webhooks:

(ns ollama-embd
(:require
[babashka.http-client :as http]
[cheshire.core :as json]
[clojure.string :as str]))
; https://github.com/ggml-org/llama.cpp/issues/6980#issuecomment-2602196900
(defn embed-text
"Embed text using the Ollama API."
[text]
  • Windows 11 23H2
  • PowerShell in Windows Termial
    • With this line in $PROFILE:

      $OutputEncoding = [System.Console]::OutputEncoding = [System.Console]::InputEncoding = [Text.UTF8Encoding]::new($false)
  • Microsoft Edge v132.0

Cannot write Unicode escape string in ClojureScript REPL:

RWKV-x060-World-7B-v2.1-20240507-ctx4096
Assistant: How can we craft an engaging story featuring Winnie the Pooh being the president of China? Let's think step by step and provide an expert response.
Step 1: Establish the setting
First, we need to establish the setting for our story. Since Winnie the Pooh is a character from a children's book series set in the Hundred Acre Wood, we can place him in a similar environment. Perhaps he is living in a small village or town near the border of China. This will allow us to create a relatable and familiar world for our readers while still maintaining an element of fantasy.
Step 2: Introduce Winnie the Pooh as president
Next, we need to introduce Winnie the Pooh as the president of China. This could be done through various means, such as a misunderstanding or a magical transformation. For example, Winnie the Pooh could be mistaken for President Xi Jinping during a diplomatic visit to China, or he could accidentally ingest some magic beans that grant him political pow

Attempted to install the Win7 target (rust-lang/rust#118150) but failed:

> rustup target add x86_64-win7-windows-msvc
error: toolchain 'stable-x86_64-pc-windows-msvc' does not support target 'x86_64-win7-windows-msvc'
note: you can see a list of supported targets with `rustc --print=target-list`
note: if you are adding support for a new target to rustc itself, see https://rustc-dev-guide.rust-lang.org/building/new-target.html

This is due to currently *-win7-windows-msvc is still Tier 3 and cannot be used in Rustup. For now, just install an old compiler:

$reg = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
Set-ItemProperty -Path $reg -Name ProxyServer -Value "127.0.0.1:2082"
Set-ItemProperty -Path $reg -Name ProxyEnable -Value 1

健康影响

(从 https://en.wikipedia.org/wiki/Green_tea#Health_effects 自动翻译)

普通绿茶含有 99.9% 的水,每 100 毫升提供 1 大卡热量,缺乏显著的营养成分(表),并含有植物化学物质,如多酚和咖啡因。

许多人声称绿茶对健康有益,但人体临床研究并未发现有益的证据。[2][7][12] 2011 年,一个科学家小组应欧盟委员会的要求发表了一份关于健康影响声明的报告:总的来说,他们发现对绿茶的声明没有足够的科学证据支持。 [7]尽管绿茶因其咖啡因含量可能会增强精神警觉性,但只有微弱的、不确定的证据表明经常饮用绿茶会影响患癌症或心血管疾病的风险,并且没有证据表明它有益于减肥。 [2]

Cochrane Collaboration 2020 年的一项综述列出了一些潜在的不良反应,包括胃肠道疾病、肝酶水平升高,以及更罕见的失眠、血压升高和皮肤反应。 [13]

@gyk
gyk / load_and_resize_image.rs
Created December 24, 2021 03:19
Code snippet for loading and resize images
// Improvements over NWG's built-in implementation:
//
// - High quality interpolation mode
// - Crop non-square images
fn load_and_resize_image(decoder: &nwg::ImageDecoder, data: &[u8]) -> Result<Bitmap> {
use winapi::shared::windef::{HBITMAP, HDC};
use winapi::um::wincodec::{
IWICBitmapScaler, IWICBitmapSource, WICBitmapInterpolationModeHighQualityCubic,
};
use winapi::um::wingdi::{
@gyk
gyk / svg2ico_magick.ps1
Created December 21, 2021 04:13
Convert SVG files in a directory into ICOs using ImageMagick
$magickExe = 'C:\Program Files\ImageMagick-7.1.0-Q16-HDRI\magick.exe'
$inPath = 'C:\Users\Joe\Downloads\svg-icons\'
$outPath = 'C:\Users\Joe\Downloads\svg-icons\output\'
foreach ($file in Get-ChildItem -File $inPath)
{
Write-Host "Processing ", $file
$outName = [io.path]::ChangeExtension($file.Name, "ico")
& $magickExe -density 256 -background transparent $file -define icon:auto-resize='64,32,16' -colors 8 (Join-Path $outPath $outName)
}
@gyk
gyk / random-file-name.clj
Created September 13, 2021 08:00
Generate random file name in Clojure
; Better to use test.check
(defn random-name
[]
(let [char-ranges [[\A \Z]
[\a \z]
[\0 \9]]
chars (->> char-ranges
(mapcat (fn [[from-char to-char]]
(map char (range (int from-char) (inc (int to-char))))))
(concat [\_ \space \-])