Skip to content

Instantly share code, notes, and snippets.

View rayepeng's full-sized avatar
🎯
Focusing

raye peng rayepeng

🎯
Focusing
View GitHub Profile
@rayepeng
rayepeng / To_hex_str.py
Created June 8, 2021 02:12
python 十进制转十六进制字符串
def To_hex_str(num):
chaDic = {10: 'a', 11: 'b', 12: 'c', 13: 'd', 14: 'e', 15: 'f'}
hexStr = ""
if num < 0:
num = num + 2**32
while num >= 16:
digit = num % 16
hexStr = chaDic.get(digit, str(digit)) + hexStr
num //= 16
hexStr = chaDic.get(num, str(num)) + hexStr
@rayepeng
rayepeng / 患癌症计算
Last active June 15, 2021 06:47
贝叶斯
已知:人群中千分之一的人会得癌症
那么假设就是10000个人,10个人会得癌症
患癌症检测成阳性概率为 99%,10个人得癌症,9.9个人检测成阳性,0.1个人检测成阴性
健康检测成阴性概率为 99%,9990个人健康,9890.1 个人检测成阳性,99.9个人检测成阳性
那么就可以计算出,如果检测成阳性,换癌症概率为:
@rayepeng
rayepeng / 添加用户.sh
Created May 21, 2021 07:43
Linux 用户操作
useradd steam
passwd steam
# 修改 /etc/sudoers 文件
chmod u+w /etc/sudoers
'''
即执行:vi /etc/sudoers
@rayepeng
rayepeng / 命令记录.sh
Last active May 22, 2021 10:21
饥荒服务器搭建 #bash
# 更新源
yum update -y
yum upgrade -y
yum install glibc.i686 libstdc++.i686 libcurl.i686 vim screen -y
useradd steam
su steam
cd ~
@rayepeng
rayepeng / 线程池.py
Last active May 20, 2021 01:51
线程池.py #Python #多线程
import requests
from concurrent.futures import ThreadPoolExecutor, as_completed
pool = ThreadPoolExecutor(3)
task_list = set()
targets = [
'http://xxx',
'http://xxx',
'http://xxx'
@rayepeng
rayepeng / join.py
Last active June 15, 2021 06:50
多线程 #Python
# 调用join表示自身优先执行
import threading
#定义线程要调用的方法,*add可接收多个以非关键字方式传入的参数
def action(*add):
for arc in add:
#调用 getName() 方法获取当前执行该程序的线程名
print(threading.current_thread().getName() +" "+ arc)
#定义为线程方法传入的参数
@rayepeng
rayepeng / get_img_name.py
Created May 19, 2021 02:25
残差网络图像分类
def get_img_name(img_dir, format="jpg"):
"""
获取文件夹下format格式的文件名
:param img_dir: str
:param format: str
:return: list
"""
file_names = os.listdir(img_dir) # 列出当前目录下所有文件
# 使用 list(filter(lambda())) 筛选出 jpg 后缀的文件
img_names = list(filter(lambda x: x.endswith(format), file_names))
@rayepeng
rayepeng / reshape.py
Created May 19, 2021 01:22
numpy reshape用法 #Python
In [1]: import numpy as np
In [2]: arr = np.array([1,2,3,4,5,6])
In [3]: arr = arr.reshape(2,1,3)
In [4]: arr
Out[4]:
array([[[1, 2, 3]],
@rayepeng
rayepeng / mistery_picture.py
Last active May 19, 2021 01:41
mistery_picture.py #CTF
import cv2
import re
img_ = cv2.imread('./mistery_picture.bmp')
mi_ = ''.join([str(x) for x in (img_ % 2).reshape(-1)])
for off_ in range(8):
mi_1 = mi_[off_:]
xxx = (''.join([chr(int(mi_1[8*i:8*(i+1)][::-1], 2)) for i in range(len(mi_1) // 8)]))
print(re.findall('(Iron[\s\S]{,66})', xxx))
@rayepeng
rayepeng / usb键盘流量.py
Last active May 18, 2021 15:42
USB键盘流量提取 #CTF
#!/usr/bin/python
# coding: utf-8
from __future__ import print_function
import sys,os
#declare -A lcasekey
lcasekey = {}
#declare -A ucasekey
ucasekey = {}