Skip to content

Instantly share code, notes, and snippets.

@ykai55
ykai55 / multiscreen.md
Last active May 4, 2019 03:53
多显示器排列组合
# 有三个显示器
outs = ['e1', 'h1', 'e2']

# 需要得到的数组
[['e1'],
 ['h1'],
 ['e2'],
 ['e1', 'h1'],
 ['e1', 'e2'],
@ykai55
ykai55 / path_of_fd.md
Created May 10, 2019 15:24
Linux从文件描述符获取文件名

通过fchdir和getcwd获取文件描述符对应的文件名

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>

int main()
{
 char cwdbuf[4096];
@ykai55
ykai55 / cli_progress.py
Created May 20, 2019 13:07
python cli progress
import time
def print_progress(completed, length=20, cell='█', empty='░', begin='', end=''):
completed = int(completed)
completed = length if completed > length else completed
print(begin + cell * completed + empty * (length-completed) + end, end='')
for i in range(51):
print('\r', end='')
print_progress(i, 50, cell='=', empty=' ', begin='[', end=']')
@ykai55
ykai55 / c_progress.c
Last active May 20, 2019 15:37
progress in c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int progress(char *buf, ssize_t bufsize,
int completed, int length,
char cell, char empty,
char begin, char end)
{
int i = 0;
@ykai55
ykai55 / restart_sleep.c
Created May 22, 2019 08:46
Restart sleep function in c
int t_remain;
for (t_remain = 2; t_remain = sleep(t_remain););
t_remain = 2;
while (t_remain = sleep(t_remain));
@ykai55
ykai55 / jb_ide_config.md
Last active June 13, 2019 18:00
JetBrains IDE Config
Theme: Darcula
Custom UI Font: Source Han Sans CN Medium:16
Code Font: Source Code Pro Medium:18
  如果不介意加粗看不清的话,把Medium设置为Bold能更清晰
Code Scheme: One Dark/Darcula
@ykai55
ykai55 / poker.txt
Created June 16, 2019 15:42
ikbc poker PN-mode key map
PN mode:
j -> down
k -> up
h -> left
l -> right
Caps -> Ctrl_L
Ctrl_L -> Win
Fn + Caps -> Caps
@ykai55
ykai55 / cluster.kt
Created May 12, 2020 10:07
cluster learning
package wekaTest
import weka.clusterers.AbstractClusterer
import weka.clusterers.FilteredClusterer
import weka.clusterers.SimpleKMeans
import weka.core.EuclideanDistance
import weka.core.Instances
import weka.core.SelectedTag
import weka.core.converters.ConverterUtils.DataSource
import weka.filters.unsupervised.attribute.Remove
@ykai55
ykai55 / .ideavimrc
Last active December 24, 2021 08:46
ideavimrc
let mapleader=' '
"""" idea设置
" 导航
nnoremap gi :action GotoImplementation<cr>
nnoremap gu :action FindUsages<cr>
nnoremap gU :action FindUsagesInFile<cr>
nnoremap gd :action GotoDeclaration<cr>
nnoremap gs :action GotoSuperMethod<cr>
@ykai55
ykai55 / addon.py
Created December 20, 2021 17:42
mitmproxy asyncio request
from mitmproxy import http
import asyncio
def request(flow: http.HTTPFlow):
flow.intercept()
async def resume():
try:
await async_request(flow)