Skip to content

Instantly share code, notes, and snippets.

@time-river
time-river / rust-reference.rs
Last active February 27, 2024 08:27
rust-reference
// bad
pub fn remove_linked_list_elements(head: Option<Box<ListNode>>, val: i32) -> Option<Box<ListNode>> {
let mut dummy = Some(Box::new(ListNode{val: 0, next: None}));
let mut prev = dummy.as_mut();
let mut curr = head;
while let Some(mut node) = curr {
curr = node.next.take();
if node.val != val {

作者:Seira

时间:2022-11-17 14:24

应无所往,而生其心

记得还在读小学的时候,我的语文老师就谈到了人的”出世“和”入世“问题。当时懵懂无知,也不太懂是啥意思。唯一记得的就是那发光的黑丝和天蓝色的裙摆。现在回想起来,这应该就是《金刚经》里面提到的”心里有所住相“吧(注:此色相非彼色相)。随着广泛阅读大量正经书籍,观看大量正规正版电视电影纪录片,不知道在哪看到了一句话,“以出世的精神做入世的事情”。当时也不太懂是啥意思,但是感觉说出来,挺拽的,所以我和别人聊天时,偶尔会说起这句话。于是出大事了,大家都不和我玩了,我做到了真正的出世。

引言

{
"state":{
"sessions":[
{
"id":1683609685292.7046,
"topic":"Conversation about being great",
"memoryPrompt":"In this discussion, we talked about Security-Enhanced Linux (SELinux), which is a security module that provides a mechanism for enforcing mandatory access control policies on Linux systems. SELinux was developed by the National Security Agency (NSA) and is now maintained by the open-source community. It provides an additional layer of security to Linux systems by enforcing access control policies that go beyond the traditional Linux file permissions. SELinux is designed to protect against a wide range of security threats, including attacks that exploit vulnerabilities in software, privilege escalation, and unauthorized access to sensitive data. It is commonly used in high-security environments such as government agencies, financial institutions, and military organizations. However, SELinux can be challenging to configure and manage, and it requires
@time-river
time-river / opencv-4.2-cuda.patch
Last active January 20, 2023 07:55
Ubuntu 22.04 + OpenCV 4.2 + CUDA fixed
shiFrom 0d99590a7433a11308d3d848c8c11c6d219c68b9 Mon Sep 17 00:00:00 2001
From: "fu.lin" <linfu@autox.ai>
Date: Thu, 12 Jan 2023 23:20:15 +0800
Subject: [PATCH 1/2] debian: compat ubuntu22.04
ref:
- https://github.com/NVlabs/instant-ngp/issues/119
- https://github.com/opencv/opencv/commit/52844614c466a37f64347aca0698157e9bb2e41e
- https://github.com/opencv/opencv/issues/23083
@time-river
time-river / acrn-qemu.sh
Last active February 22, 2023 14:03
qemu setup configuration for acrn debug
# host cpu: i5-1135G7
# $ lspci -vt
# -[0000:00]-+-00.0 Intel Corporation 82G33/G31/P35/P31 Express DRAM Controller
# +-01.0 Red Hat, Inc. Virtio block device
# +-02.0 Red Hat, Inc. Virtio network device
# +-03.0 Red Hat, Inc. Virtio RNG
# +-04.0 Red Hat, Inc. Virtio GPU
# +-05.0 Red Hat, Inc. QEMU XHCI Host Controller
# +-06.0 Red Hat, Inc. Virtio block device
# +-07.0 Red Hat, Inc. Virtio block device
@time-river
time-river / qemu.sh
Created December 21, 2022 06:33
boot vm via qemu command line
qemu-system-x86_64 \
-name qemu \
-machine pc,accel=kvm,usb=off,vmport=off,dump-guest-core=off \
-kernel vmlinuz \
-initrd initrd.img \
-append "root=/dev/vda1 ro debug loglevel=8 console=ttyS0" \
-cpu host \
-smp 4 \
-m 8192 \
-serial stdio \
@time-river
time-river / client-network.pa
Created December 21, 2022 05:32
pulseaudio network configuration (tunnel method)
# save the following to `/etc/pulse/default.pa.d/network.pa`. !!!NOTICE THE SERVER ADDRESS!!!
load-module module-tunnel-sink sink_name="tunnel-sink" server=192.168.122.1
load-module module-tunnel-source source_name="tunnel-source" server=192.168.122.1
#load-module module-zeroconf-discover
set-default-sink tunnel-sink
set-default-source tunnel-source
@time-river
time-river / rtp-client_default.pa
Last active December 21, 2022 05:28
pulseaudio network unicast configuration (rtp audio method)
#!/usr/bin/pulseaudio -nF
#
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
#include <bits/stdc++.h>
void get_post_order(const std::string &pre_order, const std::string &in_order) {
if (pre_order.length() == 0 && in_order.length() == 0) {
return;
} else if (pre_order.length() == 1 && in_order.length() == 0) {
std::cout << pre_order[0] << ' ';
} else if (pre_order.length() == 0 && in_order.length() == 1) {
std::cout << in_order[0] << ' ';
} else if (pre_order.length() == 1 && in_order.length() == 1) {
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <errno.h>
static int stop;