Skip to content

Instantly share code, notes, and snippets.

View zjuyk's full-sized avatar
🎯
Focusing

千玄子 zjuyk

🎯
Focusing
  • ArchlinuxCN
  • Shanghai, China
  • 19:27 (UTC +08:00)
View GitHub Profile
@zjuyk
zjuyk / badapple.c
Last active June 2, 2022 03:19
终端字符画
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(){
FILE *fp = fopen("badapple.txt", "r"); // open character file
fseek(fp, 0, SEEK_END); // play from end of file
int fsize = ftell(fp); // get file size (byte)
fseek(fp, 0, SEEK_SET); // back to start of file
@zjuyk
zjuyk / txt2cloud.py
Created August 17, 2021 21:33
从 txt 生成词云
import jieba
from wordcloud import WordCloud
file = open("input.txt", encoding='utf-8')
word_stream = file.read()
word_list = jieba.lcut(word_stream)
word_string = " ".join(word_list)
w = WordCloud('NotoSansCJK-Regular.ttc', width=1920, height=1080)
w.generate(word_string)
image = w.to_image()
@zjuyk
zjuyk / srt2txt.py
Created August 17, 2021 21:24
将 srt 字幕的台词提取到 txt 中
import re
# 注意默认编码是 UTF-8
file = open("input.srt")
lines = file.readlines()
file.close()
text = ""
for line in lines:
if re.search('^[0-9]+$', line) is None and \
@zjuyk
zjuyk / keybase.md
Created August 6, 2021 04:15
用来验证 keybase

Keybase proof

I hereby claim:

  • I am zjuyk on github.
  • I am zjuyk (https://keybase.io/zjuyk) on keybase.
  • I have a public key ASDXHX6FhJDoD4p-XnZ70T1a5FxgnZmsIU78wg6W3I8Jxgo

To claim this, I am signing this object:

@zjuyk
zjuyk / extra_color.py
Created July 23, 2021 15:32
提取图片主要颜色脚本
import matplotlib.image as img
import pandas as pd
from scipy.cluster.vq import whiten, kmeans
target_image = img.imread("path/to/target_image")
r = []
g = []
b = []
for row in target_image:
for temp_r, temp_g, temp_b in row: