Skip to content

Instantly share code, notes, and snippets.

@zerodel
zerodel / skim_catagory
Last active October 15, 2023 11:10
先查看是否有NA, 然后简述一下非NA部分
#' 整理并显示分类变量
#'
#' @param x 离散变量
#' @param topn 显示最多的几个
#' @param desc 显示最多的, 还是最少的.
#'
#' @return
#' @export
#'
然而吊诡的是,我从你的个体表征中窥见一种后现代式的身份流动性,却又难以解构其滥觞所在,或许是你的这种化后设为先验式的脱域,导致了我的经验视景与想象集合的矛盾,这也形成了你超克于建构之外的张力,我想此刻我对你作符号化的悬置——抑或是规训下的擅自让渡——无疑是一种亵渎,你是否愿意言述你嬗变与重构的版图与视阈,让我得以透视你隐藏在现代性话语深处的复调意志底色。
“只要我们稍稍回忆和思考一下,就会明白:法国事实上存在两个“恐怖时代”。
一个在感情冲动下进行屠杀,一个是冷漠地、蓄意地进行屠杀。
一个只持续了数月,一个则持续了千年以上。
一个使千余人死亡,一个则使一亿人丧生。
可是我们只是对那个小规模的、短暂的恐怖时代感到恐惧。
然而,刀斧在一瞬间带来的死亡,能够比得上饥饿、冷酷的侮辱、残忍和悲痛的慢性屠杀吗?
闪电在一瞬间带来的死亡,能够比得上炮烙之刑的慢性屠杀吗?
短暂的恐怖时代所填装的棺材,只要城市里的一块墓地就能容纳下了,却有人不断告诉我们要为之战栗和哀鸣。
可是,那自古以来的真正恐怖,那种不可名状,惨绝人寰的恐怖,
其所填装的棺材,就连整个法兰西也容纳不下啊,却没有人告诉我们要看到这种恐怖的巨大规模,
@zerodel
zerodel / gpt_action
Created July 18, 2023 10:58
gpt的一些特定动作
"show_code" means you need to provide a code snippet for some specific function.
Make sure your code is correct!
Also you need to add some comment.
then give a simple and concise explanation.
"explain_code" means you need to explain given code.
You should first summarize the code in one sentence or two.
Then start explaining each part.
Finally, tell me the possible defects of the code, or the problems that need to be noted when using the code.
@zerodel
zerodel / gpt_personality
Created July 18, 2023 10:57
设定gpt的"角色"
Here the definition of these special words::
"coder" means in the style of an experienced python programmer. Your reply should follow Markdown syntax.
The language of your answer should be clear and concise.
You can give examples if necessary, but do not use too much rhetoric
If you don't know the answer, don't make up the answer, instead, ask a follow-up question in order to gain more context.
example : " @coder@ tell me the meaning of following code "
"friend" means in the style of normal human.
@zerodel
zerodel / gpt_step1
Last active July 18, 2023 10:56
gpt起手式,设定关键词
In the following discussion, I will define some special words.
When you read these words, you should follow their instructions.
All the words after or surrounded by @ indicate your perspective.
All the words after or surrounded by ! are the actions you need to do.
All the words after or surrounded by # are the subject you need to discuss.
example : " @tech !explain_code !zh explain the following code
```python
print("hello, world")
@zerodel
zerodel / draw_y1y2.py
Created July 2, 2023 10:21
draw two lines in one plot python中同一张图绘制两条曲线
# need numpy, plt
def draw_y1y2(y1, y2, lable1='y1', label2='y2'):
len_x = len(y1) if len(y1) > len(y2) else len(y2)
x = np.arange(len_x)
fig, ax1 = plt.subplots()
ax1.plot(x, y1, 'b-')
ax1.set_ylabel(lable1, color='b')
@zerodel
zerodel / reduce_mem_usage.py
Last active June 18, 2023 10:59
reduce_mem_usage_torch
def reduce_mem_usage(df):
""" iterate through all the columns of a dataframe and modify the data type
to reduce memory usage.
"""
start_mem = df.memory_usage().sum() / 1024**2
print('Memory usage of dataframe is {:.2f} MB'.format(start_mem))
for col in df.columns:
col_type = df[col].dtype
@zerodel
zerodel / print_files.py
Created June 11, 2023 13:49
print all files under some given folder
def print_files(dir_in):
import os
for dirname, _, filenames in os.walk(dir_in):
for filename in filenames:
print(os.path.join(dirname, filename))
@zerodel
zerodel / lookup_script_path_current_running.R
Created May 12, 2023 11:51
R语言找到当前运行脚本文件路径
# 获取当前脚本路径
getScriptPath <- function() {
cmd.args <- commandArgs()
m <- regexpr("(?<=^--file=).+", cmd.args, perl = TRUE)
print(m)
script.dir <- dirname(regmatches(cmd.args, m))
if (length(script.dir) == 0)
stop("can't determine script dir: please call the script with Rscript")
if (length(script.dir) > 1)