Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
0c0ebab
Update Account_Generator.cpp
erichung9060 May 11, 2023
c278f89
Update README.md
erichung9060 May 13, 2023
e450634
Update README.md
erichung9060 May 13, 2023
fca69b6
Update README.md
erichung9060 May 13, 2023
8ed5def
Create pack_to_yaml.sh
erichung9060 Jul 19, 2023
c4b81fa
Update pack_to_yaml.sh
erichung9060 Jul 20, 2023
5fc3fe8
Rename pack.sh to pack_testcase.sh
erichung9060 Jul 20, 2023
5d4b7f3
Update README.md
erichung9060 Jul 20, 2023
3af0ba9
Update pack_to_yaml.sh
erichung9060 Jul 30, 2023
a38f90a
Update pack_to_yaml.sh
erichung9060 Jul 31, 2023
6400e15
Update pack_to_yaml.sh
erichung9060 Jul 31, 2023
53e9d5a
Update README.md
erichung9060 Aug 1, 2023
ffa77b6
Update pack_testcase.sh
erichung9060 Aug 1, 2023
8d039d7
Update pack_to_yaml.sh
erichung9060 Aug 1, 2023
b50711f
Update README.md
erichung9060 Aug 1, 2023
e08072a
Update README.md
erichung9060 Aug 1, 2023
a2b0b06
Update README.md
erichung9060 Aug 1, 2023
9b9bb8b
Update README.md
erichung9060 Aug 1, 2023
b700813
Update README.md
erichung9060 Aug 1, 2023
7cbd723
Update README.md
erichung9060 Oct 29, 2023
508e20f
Rename pack_testcase.sh to pack_to_testcase.sh
erichung9060 Nov 17, 2023
b79a965
Update README.md
erichung9060 Nov 17, 2023
fdab9c1
Update README.md
erichung9060 Nov 17, 2023
cb47bd1
Update pack_to_testcase.sh
erichung9060 Nov 17, 2023
010e593
Update pack_to_yaml.sh
erichung9060 Jan 3, 2024
a91206c
Update pack_to_yaml.sh
erichung9060 Jan 23, 2024
455eea5
Update pack_to_yaml.sh
erichung9060 Jan 23, 2024
bf6d060
Update README.md
erichung9060 Jan 24, 2024
bd7f5e0
Update pack_to_yaml.sh
erichung9060 Jan 24, 2024
97deeb2
Update pack_to_yaml.sh
erichung9060 Jan 24, 2024
7dca868
Update pack_to_testcase.sh
erichung9060 Jan 24, 2024
6b63a17
Create monitor.sh
erichung9060 Jan 24, 2024
ceecab0
Rename monitor.sh to cms_process_monitor.sh
erichung9060 Jan 24, 2024
26e9cbc
fix to 0-based
erichung9060 Feb 24, 2024
219435c
Update pack_to_yaml.sh
erichung9060 Mar 1, 2024
43fdfdd
adapt script for Bash
Apr 15, 2024
1067e47
Update Groups_Submissions_By_Problem_Name.sh
erichung9060 Apr 16, 2024
8bdce1b
Create moss.py
erichung9060 Apr 16, 2024
028027d
update moss.py
Apr 16, 2024
f46d19a
Rename Moss.py to delete.py
erichung9060 Apr 16, 2024
631a226
update moss.py
Apr 16, 2024
3648422
Update README.md
erichung9060 Apr 16, 2024
b9edc69
Update Account_Generator.cpp
erichung9060 Apr 16, 2024
82b2127
Create dependency.sh
erichung9060 Apr 26, 2024
bacbcad
annoymous account
erichung9060 May 10, 2024
513b101
Update Account_Generator.cpp
erichung9060 May 10, 2024
a6a1ae4
Rename cms_process_monitor.sh to auto_launch.sh
erichung9060 May 15, 2024
97a9f72
Update auto_launch.sh
erichung9060 May 15, 2024
622bc0c
Create import_user.sh
erichung9060 May 15, 2024
b513d79
Rename auto_launch.sh to auto_relaunch.sh
erichung9060 May 15, 2024
702ad20
Update Account_Generator.cpp
erichung9060 May 16, 2024
e771199
Create alias.sh
erichung9060 Oct 7, 2024
3fab8a3
Update auto_relaunch.sh
erichung9060 Nov 13, 2024
b163a24
Update auto_relaunch.sh
erichung9060 Nov 14, 2024
d3834e8
Update and rename dependency.sh to dependency.py
erichung9060 Nov 15, 2024
4b6dcc5
Update dependency.py
erichung9060 Nov 15, 2024
2c80f70
Update dependency.py
erichung9060 Nov 15, 2024
d98854a
Update dependency.py
erichung9060 Nov 15, 2024
8188978
Postgres 18+ 已經改成用 /var/lib/postgresql/<版本>/main
panboyu1813 Nov 17, 2025
0ec449d
chore(db): update PostgreSQL data volume mount path for v18+
erichung9060 Nov 18, 2025
8bcb9ec
docs: Update CMS repository URL in README
erichung9060 Nov 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 85 additions & 32 deletions MyScripts/Account_Generator.cpp
Original file line number Diff line number Diff line change
@@ -1,56 +1,109 @@
#include <bits/stdc++.h>
using namespace std;
#define all(a) begin(a), end(a)
#define pb push_back
#define pii pair<int, int>
#define F first
#define S second
#define mp make_pair

const char chr[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',

// *Important* Check if the same team name exist for different teams.

#define AUTO_GENERATE_ACCOUNT
#define AUTO_GENERATE_TEAMNAME

#if defined(AUTO_GENERATE_ACCOUNT) && defined(AUTO_GENERATE_TEAMNAME)
#define ACCOUNT_NUMBER 10
#endif

#define AccountPrefix "account"
#define TeamnamePrefix "team"

#define PASSWORD_LENTH 6
const char chr[] = {'2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T',
'H', 'J', 'K', 'L', 'M', 'N',
'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't',
'h', 'i', 'j', 'k', 'm', 'n',
'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z'};

string genPass() {
string Generate_Password() {
string password;
for (int i = 0; i < 6; i++) {
int idx = rand() % 62;
password.pb(chr[idx]);
int sz = sizeof(chr);
for (int i = 0; i < PASSWORD_LENTH; i++) {
int idx = rand() % sz;
password += chr[idx];
}
return password;
}

string Generate_Account(int idx) {
stringstream account;
account << AccountPrefix << setw(3) << setfill('0') << idx;
return account.str();
}

string Generate_Teamname(int idx) {
stringstream teamname;
teamname << TeamnamePrefix << setw(3) << setfill('0') << idx;
return teamname.str();
}

int main() {
srand(time(NULL));
/*
users:
- username: "team1"
password: "dssinsdnds"
first_name: "TeamName"
*/
ifstream TeamnameFile("teamname.txt");
srand(time(0));
map<string, pair<string, string> > team;
ofstream PasswordFile("password.txt");
ofstream SettingFile("context.yaml");
ofstream SettingFile("contest.user.yaml");
#ifdef AUTO_GENERATE_ACCOUNT
ofstream AccountFile("account.txt");
#else
ifstream AccountFile("account.txt");
#endif
#ifdef AUTO_GENERATE_TEAMNAME
ofstream TeamnameFile("teamname.txt");
#else
ifstream TeamnameFile("teamname.txt");
#endif

for (int i = 1; i <= 200; i++) {
string password = genPass();
string teamname;
getline(TeamnameFile,teamname);
string teamname, account, password;
int Account_Idx = 1;

PasswordFile << password << '\n';
SettingFile << " - username: \"team" << setw(3) << setfill('0') << i << "\"\n";
#if defined(AUTO_GENERATE_TEAMNAME) && defined(AUTO_GENERATE_ACCOUNT)
while(Account_Idx <= ACCOUNT_NUMBER){
teamname = Generate_Teamname(Account_Idx);
account = Generate_Account(Account_Idx);
#elif !defined(AUTO_GENERATE_ACCOUNT) && !defined(AUTO_GENERATE_TEAMNAME)
while (getline(AccountFile, account)) {
getline(TeamnameFile, teamname);
#elif defined(AUTO_GENERATE_ACCOUNT) && !defined(AUTO_GENERATE_TEAMNAME)
while (getline(TeamnameFile, teamname)) {
account = Generate_Account(Account_Idx);
#elif !defined(AUTO_GENERATE_ACCOUNT) && defined(AUTO_GENERATE_TEAMNAME)
while (getline(AccountFile, account)) {
teamname = Generate_Teamname(Account_Idx);
#endif

password = Generate_Password();

SettingFile << " - username: \"" << account << "\"\n";
SettingFile << " password: \"" << password << "\"\n";
SettingFile << " first_name: \"" << teamname << "\"\n";

#ifdef AUTO_GENERATE_ACCOUNT
AccountFile << account << "\n";
#endif
#ifdef AUTO_GENERATE_TEAMNAME
TeamnameFile << teamname << "\n";
#endif
PasswordFile << password << "\n";

Account_Idx++;
}
TeamnameFile.close();
PasswordFile.close();
AccountFile.close();
SettingFile.close();
}

// g++ gen.cpp && ./a.out && rm a.out
/*
cms username: account
cms password: password
cms first_name: teamname
*/
28 changes: 0 additions & 28 deletions MyScripts/Add_Problem_Id_To_File_Name.cpp

This file was deleted.

31 changes: 31 additions & 0 deletions MyScripts/Groups_Submissions_By_Problem_Name.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#! /usr/bin/bash

# 1. first copy all submissions from /var/local/lib/cms/submissions to ~
# 2. run this script
# 3. you will get a folder named Problem_Submissions, which groups submissions by problem name

rm -rf Problem_Submissions
IFS=$'\n'

getProblemName(){
ProblemName=$(head -n 3 $1 | tr -d '\r\n' | tr -cd '[:alnum:]-_}.%' | sed 's/\.%l.*//' | awk -F '}' '{print $NF}')
echo $ProblemName
}

for team in $(ls submissions); do
for submission in $(ls submissions/$team); do
problem=$(getProblemName "submissions/$team/$submission")
time=$(echo $submission | awk -F '.' '{print $1}')

if [ ! -d "$problem" ]; then
mkdir -p "Problem_Submissions/$problem"
fi
cp "submissions/$team/$submission" "Problem_Submissions/$problem/$team"
echo -e "\n$time" >> "Problem_Submissions/$problem/$team"
done
echo "$team done!"
done

for problem in $(ls Problem_Submissions); do
python moss.py $problem
done
12 changes: 0 additions & 12 deletions MyScripts/Moss.py

This file was deleted.

34 changes: 0 additions & 34 deletions MyScripts/Sort_Submissions_By_Problem_ID.cpp

This file was deleted.

3 changes: 3 additions & 0 deletions MyScripts/alias.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
alias stopcms="sudo kill \$(ps aux | grep cms | awk '{print \$2}' | head -n -1) > /dev/null 2>&1"
alias startcms="sudo cmsResourceService -a"
alias restartcms="stopcms; startcms"
7 changes: 7 additions & 0 deletions MyScripts/auto_relaunch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
id="1"

if ! curl -s http://localhost:8888 > /dev/null; then
kill $(ps aux | grep cms | awk '{print $2}' | head -n -1)
/usr/local/bin/cmsResourceService -a <<< $id &
fi
70 changes: 70 additions & 0 deletions MyScripts/dependency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# usage : python3 dependency.py pA

import xml.etree.ElementTree as ET
import json, sys

file_path = sys.argv[1] + "/problem.xml"

# Load the XML file
tree = ET.parse(file_path)
root = tree.getroot()

groups = []
group_points = {}
group_dependencies = {}
group_counts = {}
group_testcase_regex = {}

for test in root.find(".//judging").findall(".//test"): # find test in tests
group = test.get('group')

if group not in groups:
groups.append(group)
group_counts[group] = 0

group_counts[group] += 1


for group in root.findall(".//group"):
group_name = group.get('name')

points = group.get('points', '0')
group_points[group_name] = int(float(points))

dependencies = []
for dep in group.findall('.//dependency'):
dep_name = dep.get('group')

dependencies.append(dep_name)
if len(group_dependencies[dep_name]):
dependencies.extend(group_dependencies[dep_name])

dependencies = list(set(dependencies))
dependencies.sort()

group_dependencies[group_name] = dependencies

for group in groups:
print(f"Group {group} : number: {group_counts[group]}, points: {group_points[group]}, dependency: {group_dependencies[group]}")

#---------------------------------------------------

cur = 0
for group in groups:
count = group_counts[group]
print(f"{cur:03d} {cur + count - 1:03d}")
cur += count
regex = input()
group_testcase_regex[group] = regex


score_parameters = []
for group in groups:
testcase_regex = group_testcase_regex[group]
for dependency in group_dependencies[group]:
testcase_regex += "|" + group_testcase_regex[dependency]

score_parameters.append((group_points[group],testcase_regex))

json_string = json.dumps(score_parameters)
print('\n\n' + json_string)
5 changes: 5 additions & 0 deletions MyScripts/import_user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
paste id name account password | while read -r name id account password; do
echo "$name, $id, $account, $password"
cmsAddUser $name $id $account -p $password;
cmsAddParticipation -c 1 $account
done
13 changes: 13 additions & 0 deletions MyScripts/moss.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#python moss.py [problem_name]

import mosspy, sys

userid = 61861013

m = mosspy.Moss(userid, "python")

m.addFilesByWildcard("Problem_Submissions/" + sys.argv[1] + "/*")

url = m.send()

print (sys.argv[1] + " : " + url)
Loading