This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import re | |
import shutil | |
ROOT_DIR = "./" | |
# “数字_”以外的自定义文件夹写这里 | |
CUSTOM_READ_DIR = [ | |
"custom_folder_1", | |
"custom_folder_2", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import glob | |
# get filename list | |
list = [os.path.basename(f) for f in glob.glob('./test/*')] | |
#['1-2.csv', '1-1.csv', '0.csv', '1-2-2.csv', '1.csv', '1-2-1.csv', '2.csv'] | |
# remove 0.csv and extension | |
list.remove('0.csv') | |
list = [x.replace('.csv', '') for x in list] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import json | |
from flask import Flask, render_template | |
# reference: https://stackoverflow.com/questions/29631711/python-to-parent-child-json | |
# create a helper class for each tree node | |
class Node(object): | |
# generate new node | |
def __init__(self, cluster): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <getopt.h> | |
void get_short_option(int argc, char **argv) | |
{ | |
int c; | |
int i; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.shellhacks.com/remove-first-last-characters-strings-bash/ | |
# File to modify | |
$ cat file | |
12345===I Love Bash===54321 | |
12345===I Love Bash===54321 | |
12345===I Love Bash===54321 | |
# Remove First N Characters Of Each Line | |
# (delete first 5 characters of each line / starting from the 6th character) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#################################### | |
# | |
# Backup to NFS mount | |
# https://help.ubuntu.com/lts/serverguide/backup-shellscripts.html.en | |
# | |
#################################### | |
# What to backup. | |
backup_files="/home /var/spool/mail /etc /root /boot /opt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# (https://superuser.com/questions/1095234/bash-script-to-backup-and-restore-directory-structure) | |
# create a tar file <Directory_Structure.tar> of the directory structure | |
# and a list of files <File_List.txt> | |
# in PWD | |
HomeDir=$(pwd) | |
BackupDIR="Backup" # Change here |