Skip to content

Instantly share code, notes, and snippets.

@qbosen
qbosen / export_brew_in_notes.py
Last active Dec 4, 2021
在logseq笔记目录中搜索目标 homebrew 相关脚本,并导出
View export_brew_in_notes.py
#!/usr/bin/env python3
from typing import *
import sys
import os
import re
from pathlib import Path
def search_and_handle(
search_pattern: Union[AnyStr, Pattern],
View backup_unref_images.sh
#!/bin/bash
SCRIPT_DIR="$(cd $(dirname "$0") && pwd -P)"
LOGSEQ_DIR="$(dirname "$SCRIPT_DIR")"
PY_SCRIPT="clear_unref_images.py"
"$SCRIPT_DIR/$PY_SCRIPT" "$LOGSEQ_DIR" -b
echo 'DONE'
read
View add_directory_proc.sql
-- 确保所有操作只与关系表相关
CREATE PROC add_directory(@dir_id bigint, @parent bigint) AS
BEGIN
INSERT INTO directory_relation (ancestor_id, member_id, distance)
SELECT ancestor_id, @dir_id, distance + 1
FROM directory_relation
WHERE member_id = @parent
UNION ALL
SELECT @dir_id, @dir_id,0;
@qbosen
qbosen / demo.kt
Last active Sep 27, 2020
DDD & JPA
View demo.kt
/*Domain*/
interface SimpleUser : Validatable {
val id: Long
val name: String
@JvmDefault
fun desc(): String = "$id:$name"
}
interface User : SimpleUser {
@qbosen
qbosen / FluentPropertySetter.java
Last active Aug 14, 2020
属性条件复制的链式操作
View FluentPropertySetter.java
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@qbosen
qbosen / NameWare.java
Last active Aug 6, 2020
从方法引用获取属性字面值
View NameWare.java
package top.abosen.nameware;
import java.io.Serializable;
import java.lang.invoke.SerializedLambda;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Optional;
public class Main {
@qbosen
qbosen / P.java
Created Jul 23, 2020
fluent comparing
View P.java
package top.abosen.toys.ipv6;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
View MatcherBuilder.java
package top.abosen.toys.ipv6.match;
import inet.ipaddr.IPAddress;
import inet.ipaddr.IPAddressString;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@qbosen
qbosen / CAS.java
Last active Jul 23, 2020
cas demo
View CAS.java
import sun.misc.Contended;
import sun.misc.Unsafe;
import java.lang.reflect.Field;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.IntStream;
class Scratch {