Skip to content

Instantly share code, notes, and snippets.

View ljyloi's full-sized avatar
🤤

辣椒油 ljyloi

🤤
View GitHub Profile
@ljyloi
ljyloi / process.py
Last active October 9, 2023 10:05
dna script
import sys
import csv
def checkIfMatch(row1, rows_2):
chr1 = 'chr' + row1[0]
bp1 = int(row1[1])
for row2 in rows_2:
chr2 = row2[0]
bp2_a = int(row2[1])
import cv2
import numpy as np
class Rect:
def __init__(self, width:int, height:int, number=0) -> None:
self.width, self.height = width, height
self.number = number
pass
def area(self) :
@ljyloi
ljyloi / gen.sh
Created February 14, 2023 09:17
利用 bash 通过模版文件生成最终文件
#!/bin/bash
export sample="Hello Yaml!"
export nats_machines="10.2.3.4"
export nats_username="nats"
export nats_password="password"
rm -f final.yml temp.yml
( echo "cat <<EOF >final.yml";
cat template.yml;
echo "EOF";
#!/bin/bash
# author: @lumean
# 用于检测某个 vlan 被哪些进程占用了,将进程的 nents 软连接到 iproute2 配置的 netns 目录下,通过 iproute2 工具查看 netns 中的具体情况
VLAN=$1
mkdir -p /var/run/netns
for i in $(ps -e | awk '{print $1}'); do
ln -sf /proc/$i/ns/net /var/run/netns/$i
output=$(ip -d -n $i addr show)
if echo $output | grep -q "1Q id $VLAN"; then
echo "vlan $VLAN still in use by PID $i:"
@ljyloi
ljyloi / make.sh
Last active November 4, 2022 11:12
static-sshd build script
#!/bin/sh
set -ex
# run it to build a sshd for amd64
# docker run --rm -v $(pwd):/tmp -w /tmp -e ARCH=amd64 alpine /tmp/make.sh
# library version
OPENSSH_VERSION=V_8_5_P1
@ljyloi
ljyloi / test.cu
Last active July 28, 2022 08:41
用来测试 gpu 的简单 cuda 代码
// a program doing matrix multiplication with gpu, which could be use to test if gpu monitor really works
// use nvcc to complile
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <random>
#include <stdexcept>