Skip to content

Instantly share code, notes, and snippets.

tell application "System Events"
tell process "Safari"
set frontmost to true
-- Reference Safari window
set safariWindow to front window
delay 0.5
set sidebarVisible to false
try
import Foundation
// MARK: - Main Request Body
/// Represents the request body for creating a chat completion.
public struct ChatCompletionRequest: Codable {
/// A list of messages comprising the conversation so far.
public let messages: [Message]
@AFutureD
AFutureD / PreviewMetalView.swift
Last active March 21, 2025 02:40
Preview Camera Capture using Metal with coordination transform.
import Async
import AVFoundation
import MetalKit
import Combine
class PreviewMetalView: MTKView {
enum ContentMode {
case resizeAspectFit
case resizeAspectFill
@AFutureD
AFutureD / config.json
Last active December 24, 2024 16:00
Swift LSP support for iOS on vscode
// .sourcekit-lsp/config.json
{
"swiftPM": {
"triple": "arm64-apple-ios",
"swiftCompilerFlags": [
"-sdk",
"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"
],
"cCompilerFlags": [
"-isysroot",
package ;
import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
@AFutureD
AFutureD / config.yml
Created January 30, 2024 04:07
LazyGit Config
gui:
sidePanelWidth: 0.25
git:
paging:
colorArg: always
externalDiffCommand: 'difft --color=always --display="$([ $(tput cols) -lt 180 ] && echo inline || echo side-by-side-show-both)" --context=4' # side-by-side-show-both
# externalDiffCommand: tput cols
keybinding:
universal:
@RequiredArgsConstructor
public class Client {
public <T> Result<T> execute(Object requset, Class<?>... types) {
String content = <json response>
return JSONObject.parseObject(content, buildType(ArrayUtil.append(new Class[]{Result.class}, types)));
}
package *.gateway.fliter;
import lombok.RequiredArgsConstructor;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
import org.springframework.core.Ordered;
import org.springframework.http.MediaType;
import org.springframework.http.codec.HttpMessageReader;
import org.springframework.http.codec.ServerCodecConfigurer;
@AFutureD
AFutureD / ring_aes_example.rs
Last active April 12, 2023 03:26
A example about how to use AES algorithm for ring.
# ring = "0.16.20"
use ring::*;
use ring::aead::{Aad, AES_128_GCM, BoundKey, Nonce, OpeningKey, SealingKey, UnboundKey};
static ALGORITHM: &aead::Algorithm = &AES_128_GCM;
struct OneNonceSequence(Option<aead::Nonce>);
impl OneNonceSequence {
fl () {
API=""
ret_json=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"content\":\"$*\"}" $API)
echo $ret_json | sed "s/.*\"message\":\([^,}]*\).*/\1/"
}