Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CI

on:
pull_request: {}
push:
branches: [ master ]

jobs:
shellcheck:
name: ShellCheck
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- uses: actions/checkout@v4
- uses: ludeeus/action-shellcheck@2.0.0
with:
severity: warning
24 changes: 13 additions & 11 deletions c_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ fi

filename="$1"

str="#include <stdio.h>
\n#include <stdlib.h>
\n\nint main()
\n{
\n\tint aux;\n
\n\tscanf(\"%d\", &aux);\n
\n\tprintf(\"%d\", aux);\n
\n\treturn 0;
\n}"
cat << EOF > "$filename.c"
#include <stdio.h>
#include <stdlib.h>

echo -e $str > "$filename.c"
echo "Done!"
int main()
{
\tint aux;
\tscanf("%d", &aux);
\tprintf("%d", aux);
\treturn 0;
}
EOF

echo "Done!"
62 changes: 34 additions & 28 deletions cpp_competitive_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ main() {
while getopts "c:s:h" flag; do
case $flag in
c)
num_problems=$OPTARG
contest_flag=1 ;;
num_problems=$OPTARG
contest_flag=1 ;;
s)
problem_names=$OPTARG
specify_flag=1 ;;
problem_names=$OPTARG
specify_flag=1 ;;
h)
print_usage
exit ;;
print_usage
exit ;;
*)
print_usage
exit 1 ;;
esac
done

Expand All @@ -32,50 +35,53 @@ main() {
exit 1
fi

if (($contest_flag > 0)); then
if ((contest_flag > 0)); then
echo "creating contest problems..."
problems=("A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T")

for ((i=0;i<$num_problems;i++));
for ((i=0;i<num_problems;i++));
do
echo "creating file ${problems[$i]}.cpp..."
create_file ${problems[$i]}
create_file "${problems[$i]}"
done
elif (($specify_flag > 0)) ;then
elif ((specify_flag > 0)) ;then

names=$(echo $problem_names | tr "," " ")
names=$(echo "$problem_names" | tr "," " ")
for name in $names
do
echo "creating file $name.cpp..."
create_file $name
create_file "$name"
done
else
filename="$1"
echo "creating file $filename.cpp..."
create_file $filename
create_file "$filename"
fi

create_io_files
echo "Done!"
}

create_file() {
local code="#include <bits/stdc++.h>
\nusing namespace std;
\n#define DEBUG(x) cout << #x << \" >>>> \" << x << endl
\n#define MID(l, r) (l + (r - l) / 2)
\n#define CEILDIVISION(x, y) ((x + y - 1) / y)
\n#define INF (int)1e9
\n#define LONGINF (long long)1e18
\n#define MEM(arr, val) memset(arr, (val), sizeof(arr))
\n#define FASTIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
\nconst int MOD = 1000000007; // 10^9 - 7
\n
\nint main() {
\n\tFASTIO;\n\t\n\t\n\treturn 0;
\n}"
cat << EOF > "$1.cpp"
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << #x << " >>>> " << x << endl
#define MID(l, r) (l + (r - l) / 2)
#define CEILDIVISION(x, y) ((x + y - 1) / y)
#define INF (int)1e9
#define LONGINF (long long)1e18
#define MEM(arr, val) memset(arr, (val), sizeof(arr))
#define FASTIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int MOD = 1000000007; // 10^9 - 7

int main() {
\tFASTIO;

echo -e $code > "$1.cpp"

\treturn 0;
}
EOF
}

create_io_files() {
Expand Down
10 changes: 5 additions & 5 deletions create_bootable_usbstick.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ if (($# != 2)); then
fi


read -p $'\nEnter the Operating System: For Windows type: windows | For Linux type: linux \n' os
read -rp $'\nEnter the Operating System: For Windows type: windows | For Linux type: linux \n' os

if [ "$os" = "linux" ]; then

deviceToUmount="${1}1"

sudo umount $deviceToUmount
sudo umount "$deviceToUmount"

echo "Unmounting device..."

sudo dd bs=4M if=$2 of=$1 status=progress oflag=sync
sudo dd bs=4M if="$2" of="$1" status=progress oflag=sync

echo "Done!"

Expand All @@ -37,11 +37,11 @@ elif [ "$os" = "windows" ]; then

deviceToUmount="${1}1"

sudo umount $deviceToUmount
sudo umount "$deviceToUmount"

echo "Unmounting device..."

sudo woeusb -v --target-filesystem NTFS --device $2 $1
sudo woeusb -v --target-filesystem NTFS --device "$2" "$1"

echo $'This script requires woeusb to be installed, install it using the following PPA:\nsudo add-apt-repository ppa:nilarimogard/webupd8\nsudo apt update\nsudo apt install woeusb'

Expand Down
8 changes: 4 additions & 4 deletions pdf2csv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ fi

echo "Converting pdf to txt..."

pdftotext -layout $1 $2.txt
pdftotext -layout "$1" "$2.txt"

# After convert it to txt we have to parse through the lines and separate the fields by commas

echo "Converting txt to csv..."

# Let's add an space after the first field, replace the commas with dots and then separate them

awk '{ sub(/^[ \t]+/, ""); print}' $2.txt | sed 's/ / /' | awk '{gsub(/,/,".")} 1' |
awk -F'[[:space:]][[:space:]]+' 'BEGIN{OFS=",";} {print $1, $2, $3, $4, $5, $6, $7}' > $2.csv
awk '{ sub(/^[ \t]+/, ""); print}' "$2.txt" | sed 's/ / /' | awk '{gsub(/,/,".")} 1' |
awk -F'[[:space:]][[:space:]]+' 'BEGIN{OFS=",";} {print $1, $2, $3, $4, $5, $6, $7}' > "$2.csv"

rm $2.txt
rm "$2.txt"

echo "Done!"
14 changes: 7 additions & 7 deletions run_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ main() {
fi

# get flags
contest_flag=0
specify_flag=0
num_problems=0
while getopts "h" flag; do
case $flag in
h)
print_usage
exit ;;
print_usage
exit ;;
*)
print_usage
exit 1 ;;
esac
done

filename="$1"
run_file $filename
run_file "$filename"
}

run_file() {
g++ $1 && ./a.out -fmax-errors=1 <in.txt >out.txt
g++ "$1" && ./a.out -fmax-errors=1 <in.txt >out.txt
}

print_usage() {
Expand Down