Skip to content

Instantly share code, notes, and snippets.

@vifly
vifly / cat_answers_pro_max.py
Created Oct 30, 2021
Hackergame 2021 writeup code
View cat_answers_pro_max.py
import requests
cookies = dict(session="",
PHPSESSID="")
def crack(questions, answers):
data = {"q1": "20150504", "q2": "1", "q3": "Development Team of Library", "q4": "1", "q5": "/dev/null"}
for index, question in enumerate(questions):
data[question] = answers[index]
@vifly
vifly / bills.py
Created Nov 9, 2020
Hackergame 2020 writeup code
View bills.py
import cn2an
result = 0
def remove_zero(amount: str) -> str:
if amount[0] == "零":
return amount[1:]
return amount
@vifly
vifly / merge_OSTEP.py
Created Sep 27, 2020
合并 OSTEP 的 PDF 文件
View merge_OSTEP.py
#使用 https://gist.github.com/theagoliveira/65980c144bf53cf8ee5e351bd827d7e7
#下载 Operating Systems: Three Easy Pieces,然后用此脚本把下载的多个 PDF 文件合并。
#可以使用 https://pypi.org/project/pdfCatalog/ 为 PDF 生成目录,pdfCatalog 只
#考虑到中文章节的情况,为了成功生成目录,需要在运行此脚本后生成的 catalog.txt 首行插入“扉页 1”。
import glob
from os.path import *
from pdfrw import PdfReader, PdfWriter, IndirectPdfDict
@vifly
vifly / slogans.json
Created Nov 9, 2019
Slogans for viflythink.com
View slogans.json
[
{
"content": "千里之行,始于足下"
},
{
"content": "与魔鬼战斗的人,应当小心自己不要成为魔鬼。当你凝视深渊时,深渊也在凝视着你"
},
{
"content": "自由并非免费赠饮"
},
@vifly
vifly / remove_some_kde_applications.py
Created Nov 2, 2019
删除 kde-applications 中属于教育或游戏分类的应用,需要 root 权限,使用需谨慎
View remove_some_kde_applications.py
import subprocess
import glob
def is_need_remove(file_path):
with open(file_path, 'r') as f:
content = f.readlines()
for line in content:
if line.split("=")[0] == "Categories":
categories = line.split("=")[1]
# 如果分类字段里有 Education 或 Game,那么认为是需要删除的