Skip to content

Commit 7fd17b7

Browse files
committed
Long time no see
1 parent 1a98920 commit 7fd17b7

File tree

617 files changed

+13462
-583
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

617 files changed

+13462
-583
lines changed

asy/cse5.asy

-1
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,3 @@ picture CopyClean()=CC;
276276

277277
pair MarkAngle(real a=0,Label s='',int f=anglefontsize,
278278
pen p=anglefontpen, pair B, pair A, pair C, real r, int m=1, pair S=nullpair, pen q=anglepen)=MA;
279-

bashrc

+1-120
Original file line numberDiff line numberDiff line change
@@ -1,120 +1 @@
1-
#
2-
# ~/.bashrc
3-
#
4-
5-
# If not running interactively, don't do anything
6-
[[ $- != *i* ]] && return
7-
8-
#PS1='[\u@\h \W]\$ '
9-
10-
# Trick jshell into working
11-
export TERM=xterm-256color
12-
# Vim
13-
export VISUAL='vim'
14-
export EDITOR='vim'
15-
# Custom scripts
16-
export PATH="/home/ericshen/bin:/home/ericshen/.local/bin:$PATH"
17-
export PYTHONPATH="/home/ericshen/.von:$PATH"
18-
19-
# Java PATH
20-
export PATH="/usr/lib/jvm/java-14-openjdk/bin:$PATH"
21-
22-
# Useful constants
23-
export SITE='[email protected]'
24-
export MW='/home/ericshen/Documents/Classes/LiJie'
25-
export SCH='/home/ericshen/Documents/School/Grade-10'
26-
27-
# Cleanup
28-
alias clean='rm *.aux *.fdb_latexmk *.fls *.log *.out *.pre *.class *.von *.mcgrep *~'
29-
30-
# Useful alternatives
31-
#alias asy='asy -nosafe -noprc -render=0' # THANK YOU GHOSTSCRIPT 9.50 (screw you ghostscript 9.52)
32-
alias tmacs='emacs -nw' # non-graphical emacs
33-
alias pdf='zathura &>/dev/null' # zathura shortcut
34-
alias img='feh --scale-down --auto-zoom' # feh auto-scale
35-
alias ytdl="youtube-dl -f bestaudio[ext=m4a] --embed-thumbnail --add-metadata -o '%(title)s.%(ext)s'" # download music
36-
alias gvim='gvim &>/dev/null' # don't print warnings
37-
alias wpm='python -m wpm'
38-
alias von='python -m von' # von
39-
alias g='git' # git (e.g. g s, g a)
40-
alias skin='find . -type f -print0 | xargs -0 chmod 644' # chmod files to 644 after importing from exfat drive
41-
42-
# ls preferences
43-
alias ls='ls --color=tty --group-directories-first --quoting-style=literal -CF --time-style=long-iso'
44-
alias ll='ls -lh'
45-
alias la='ls -a'
46-
alias l='ls -alh'
47-
48-
# Be careful
49-
alias rm='rm -i'
50-
alias mv='mv -i'
51-
alias cp='cp -i'
52-
53-
# Fun!
54-
alias caps='xdotool key Caps_Lock'
55-
alias CAPS='xdotool key Caps_Lock'
56-
alias fuck='sudo $(fc -ln -1)'
57-
alias dog='pygmentize -g'
58-
alias what='ping -c 3 google.com'
59-
alias rvim='sudo -E vim' # sudo vim while preserving environment
60-
alias shrug='echo "¯\_(ツ)_/¯"'
61-
62-
# Quickly switch locale
63-
alias english='export LANG=en_US.utf8'
64-
alias chinese='export LANG=zh_CN.utf8'
65-
66-
# ibus
67-
export GTK_IM_MODULE=ibus
68-
export XMODIFIERS=@im=ibus
69-
export QT_IM_MODULE=ibus
70-
71-
# urxvt ctrl+s flow control is stupid
72-
stty -ixon
73-
74-
# i3blocks
75-
export SCRIPT_DIR='/home/ericshen/.config/i3blocks'
76-
77-
# I'm lazy so http://bashrcgenerator.com/
78-
export PS1="\[$(tput bold)\]\[\033[38;5;43m\]\u\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;38m\]@\[$(tput sgr0)\]\[\033[38;5;80m\]\h\[$(tput sgr0)\]\[\033[38;5;38m\]:\[$(tput bold)\]\[\033[38;5;45m\]\w\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;38m\]\\$\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]"
79-
alias short='PS1="\[\033[38;5;38m\]\\$\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]"'
80-
81-
# Auto-complete
82-
# source /home/ericshen/bin/auto-complete-alias &>/dev/null
83-
84-
# Copy-pasta; Use:
85-
# $ echo 'Hi' | pclip; gclip
86-
if [ -n "$(type -P xclip)" ]; then
87-
test -z "$(type -P pclip)" && \
88-
alias pclip="$(type -P xclip) -selection c -i"
89-
test -z "$(type -P gclip)" && \
90-
alias gclip="$(type -P xclip) -selection c -o"
91-
test -z "$(type -P pprim)" && \
92-
alias pprim="$(type -P xclip) -selection p -i"
93-
test -z "$(type -P gprim)" && \
94-
alias gprim="$(type -P xclip) -selection p -o"
95-
fi
96-
97-
# Extract files (thanks Reddit)
98-
extract() {
99-
if [ -f $1 ] ; then
100-
case $1 in
101-
*.tar.bz2) tar xvjf $1 ;;
102-
*.tar.gz) tar xvzf $1 ;;
103-
*.tar.xz) tar xvJf $1 ;;
104-
*.bz2) bunzip2 $1 ;;
105-
*.rar) unrar x $1 ;;
106-
*.gz) gunzip $1 ;;
107-
*.tar) tar xvf $1 ;;
108-
*.tbz2) tar xvjf $1 ;;
109-
*.tgz) tar xvzf $1 ;;
110-
*.zip) unzip $1 ;;
111-
*.Z) uncompress $1 ;;
112-
*.7z) 7z x $1 ;;
113-
*.xz) unxz $1 ;;
114-
*.exe) cabextract $1 ;;
115-
*) echo "\`$1': unrecognized file compression" ;;
116-
esac
117-
else
118-
echo "\`$1' is not a valid file"
119-
fi
120-
}
1+
[ -f ~/.fzf.bash ] && source ~/.fzf.bash

bin/.texyou.un~

4.32 KB
Binary file not shown.

bin/6.101-submit

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#!/usr/bin/env bash
2+
# 6.101 Lab Submission Script
3+
4+
author="6.101 Course Staff"
5+
version="F24-000"
6+
default_semester="fall24"
7+
8+
semester="${SEMESTER:-$default_semester}"
9+
user="labs"
10+
host="py.mit.edu"
11+
impersonate=""
12+
assignment=""
13+
14+
function help {
15+
echo "Usage: $0 [-h] [-t] [-a LAB] [-s SEMESTER] [-c URL] [-i USERNAME] file";
16+
echo " -h : show this help message";
17+
echo " -t : run a connection/authentication test, but do not ";
18+
echo " submit anything";
19+
echo " -s SEMESTER : a semester, default $default_semester";
20+
echo " -H HOST : the location of the server to connect to. ";
21+
echo " default: $host";
22+
echo " -a ASSIGNMENT : the assignment to submit to. if not specified, we ";
23+
echo " will try to guess based on the working directory";
24+
echo " -y : submit without asking for confirmation";
25+
}
26+
27+
while getopts ":hs:c:a:i:ty" arg; do
28+
case ${arg} in
29+
h)
30+
help;
31+
exit 0;
32+
;;
33+
s)
34+
semester=${OPTARG};
35+
;;
36+
a)
37+
assignment=${OPTARG};
38+
;;
39+
t)
40+
run_test=true;
41+
;;
42+
i)
43+
impersonate=${OPTARG};
44+
;;
45+
y)
46+
skip_confirmation=true;
47+
;;
48+
:)
49+
help;
50+
exit 1;
51+
;;
52+
?)
53+
help;
54+
exit 1;
55+
;;
56+
esac
57+
done
58+
59+
echo "6.101 Lab Submission Script";
60+
echo "(Version $version)";
61+
echo "";
62+
63+
ssh_command="ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 $user@$host";
64+
65+
shift $(($OPTIND - 1));
66+
67+
if [ "$run_test" == "true" ]; then
68+
echo "Running authentication test.";
69+
echo "$version" | $ssh_command test;
70+
exit 0;
71+
fi
72+
73+
case "$1" in
74+
-)
75+
input_file=-;
76+
;;
77+
"")
78+
echo "No file specified. Exiting.";
79+
exit 1;
80+
;;
81+
*)
82+
input_file="$1";
83+
;;
84+
esac
85+
86+
if [ ! -z "$impersonate" ]; then
87+
echo "Attempting to submit for $impersonate. This will only work for staff members.";
88+
fi
89+
90+
if [ ! -z "$assignment" ]; then
91+
echo "Submitting $assignment";
92+
fi
93+
94+
if [ ! -f "$input_file" ]; then
95+
echo "ERROR: File $input_file does not exist. Exiting."
96+
exit 1;
97+
else
98+
filedir="$(cd $(dirname "$input_file") && pwd)"
99+
if [ -z "$assignment" ]; then
100+
assignment="$(basename $filedir)";
101+
echo "Guessing assignment name: $assignment";
102+
fi
103+
echo "Reading submission from file ($input_file)";
104+
input_filename="$(basename "$input_file")";
105+
fi
106+
107+
echo "";
108+
109+
if [ "$skip_confirmation" != "true" ]; then
110+
echo "Please double check the information above.";
111+
while true; do
112+
read -p "Would you like to proceed with making this submission? [y/N] " yn </dev/tty;
113+
case $yn in
114+
N|n|No|no|Nope|nope|"")
115+
echo;
116+
echo "Exiting. No submission will be made.";
117+
exit 1;
118+
;;
119+
Y|y|Yes|yes|Yep|yep)
120+
echo;
121+
break;
122+
;;
123+
*)
124+
echo "Please enter yes or no";
125+
;;
126+
esac
127+
done
128+
fi
129+
130+
echo "Proceeding with submission.";
131+
echo ""
132+
echo "$version" | cat - "$input_file" | $ssh_command submit "$assignment" "$input_filename" "$impersonate"

bin/ggb2asy

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/usr/bin/env python
2+
# Have the ggb->asy code ready in clipboard
3+
# Ensure the only checked item is "use pair names"
4+
import pyperclip
5+
import re
6+
import string
7+
import io
8+
import traceback
9+
10+
banner = "# Evan's GGB to Asy Cleanup script #"
11+
print("#"*len(banner))
12+
print("# Evan's GGB to Asy Cleanup script #")
13+
print("#"*len(banner))
14+
print()
15+
16+
fat_decimal_regex = re.compile(r'(\d+\.\d{5})\d+')
17+
def replace_numbers(s):
18+
return fat_decimal_regex.sub(r"\1", s)
19+
20+
clipboard_contents = pyperclip.paste()
21+
try:
22+
input_buffer = io.StringIO(clipboard_contents)
23+
output_buffer = io.StringIO()
24+
25+
first_line = input_buffer.readline()
26+
assert "Geogebra to Asymptote conversion" in first_line,\
27+
"First line is missing header\n" + first_line
28+
# print(r'/* start ggb to asy preamble */', file=output_buffer)
29+
points_dict = {}
30+
31+
# preamble
32+
for line in input_buffer:
33+
line = replace_numbers(line).strip()
34+
if not line: # end preamble
35+
# print(r'/* end preamble */', file=output_buffer)
36+
break
37+
elif "real labelscalefactor" in line:
38+
continue
39+
elif "pen dps" in line:
40+
continue
41+
elif "pen dotstyle" in line:
42+
continue
43+
elif "real xmin" in line:
44+
continue
45+
elif line.startswith("pair "):
46+
# collect the coordinates of all the points
47+
content = line[5:].strip().rstrip(';')
48+
assignments = content.split(', ')
49+
for assn in assignments:
50+
point_name, pair = assn.split(' = ')
51+
points_dict[point_name] = eval(pair)
52+
print(line, file=output_buffer)
53+
54+
# process figures
55+
for line in input_buffer:
56+
line = replace_numbers(line).strip()
57+
if line == "/* dots and labels */": # end figures
58+
break
59+
elif line == "/* draw figures */": # ignore this line
60+
continue
61+
elif "grid" in line: # delete grid
62+
continue
63+
line = line.replace("linewidth(2.)", "linewidth(0.6)")
64+
print(line.strip(), file=output_buffer)
65+
66+
# process dots and labels
67+
dot_regex = re.compile(r'dot\(([a-zA-Z0-9_]+|\([0-9\.\-,]+\)),.*?dotstyle\);')
68+
label_regex = re.compile(r'label\("(.+?)", (\([0-9\.\-,]+\)), .+?\);')
69+
70+
while True:
71+
dot_line = replace_numbers(input_buffer.readline().strip())
72+
if dot_line == r"/* end of picture */": # end of file
73+
break
74+
dot_match = dot_regex.match(dot_line)
75+
if dot_match is None:
76+
continue
77+
label_line = replace_numbers(input_buffer.readline().strip())
78+
label_match = label_regex.match(label_line)
79+
assert label_match is not None, label_line
80+
81+
point = dot_match.groups()[0]
82+
label = label_match.groups()[0]
83+
label_loc = eval(label_match.groups()[1])
84+
# determine the direction
85+
if point in points_dict:
86+
coords = points_dict[point]
87+
else:
88+
assert all(_ in '.0123456789-,()' for _ in point)
89+
coords = eval(point)
90+
91+
if coords is None:
92+
print(r'dot("%s", %s, dir(45));' %(label, point), file=output_buffer)
93+
else:
94+
dx = 100*(label_loc[0]-coords[0])
95+
dy = 100*(label_loc[1]-coords[1])
96+
print(r'dot("%s", %s, dir((%.3f, %.3f)));' %(label, point, dx, dy), file=output_buffer)
97+
98+
output = output_buffer.getvalue()
99+
print(output[:500] + '\n...\n' + output[-500:])
100+
response = input("Replace clipboard contents? [y/n] ")
101+
if response.strip().lower() == 'y':
102+
pyperclip.copy(output)
103+
104+
except:
105+
print("Input:")
106+
print()
107+
print(clipboard_contents[0:500] + '...')
108+
print('-'*40 + '\n')
109+
traceback.print_exc()
110+
response = input("Failed. Press ENTER to continue... ")

bin/gtexme

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ else
99
# zathura $PWD/$file.pdf &>/dev/null &
1010
latexmk -pvc -pdf $PWD/$file.tex &>/dev/null &
1111
fi
12-
gvim $PWD/$file.tex &>/dev/null --servername GVIM
12+
gvim $PWD/$file.tex

0 commit comments

Comments
 (0)