Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

赵丰 (Zhao Feng) zhaofeng-shu33

🎯
Focusing
  • Department of Electronics and Engineering, Graduate School at Shenzhen
  • Tsinghua University, ShenZhen, GuangDong, PR China
View GitHub Profile
View myscp.sh
#!/bin/bash
if [ -f "$1" ]; then
scp ./$1 feng@10.8.6.22:/home/feng/Downloads/
else
scp feng@10.8.6.22:/home/feng/Downloads/$1 ./
fi
@zhaofeng-shu33
zhaofeng-shu33 / texshop.applescript
Last active Nov 7, 2020
applescript for texshop to open skim displayline
View texshop.applescript
--AppleScript direct
-- set val to do shell script "sed 's|[a-zA-Z]*.pdf|build/&|g' <<< " & quoted form of #PDFPATH#
-- tell application "Skim" to open val
set val to do shell script "sed 's|[a-zA-Z]*.pdf|build/&|g' <<< " & quoted form of #PDFPATH#
-- val is pdfpath
set lf to linefeed
tell application "TeXShop"
set offs to offset of the selection of document #DOCUMENTNAME#
View crop.py
import time
import subprocess
from subprocess import PIPE, STDOUT
import sys
from PIL import Image
resolution = 144
pdf_file_name = sys.argv[1]
r = subprocess.run(['gs', '-q', '-dBATCH', '-dNOPAUSE', '-sDEVICE=bbox', pdf_file_name], stdout=PIPE, stderr=STDOUT)
@zhaofeng-shu33
zhaofeng-shu33 / errata_lfd.md
Last active Aug 30, 2020
learning from data errata
View errata_lfd.md

Lecture 9 Reinforcement learning

Page 34, loss function, missing the closing bracket (y_i - Q()^2)

Page 21, the second equation of Newton's law is wrong, the physical dimension mismatches on two sides of the equality.

View errata_intro_to_intel86_part1
Page 93: the position of ".text:00000009 lea eax, [ecx+eax*2]" is wrong
Page 59: 0x0000BEEF should be red with the corresponding label
View email-source.md
View gbk_2_utf8.py
import os
import argparse
def convert(filename):
with open(filename, 'rb') as f:
st = f.read()
try:
st = st.decode('gbk')
except Exception as e:
print('gbk decode error for ' + filename)
View frame_replace.py
import re
import os
def replace_frame_str(str):
r_ex = re.compile(r'\\FRAME.*?}}', flags=re.DOTALL)
return re.sub(r_ex, '%FRAME', str)
def replace_frame_file(filename):
with open(filename) as f:
st = f.read()
@zhaofeng-shu33
zhaofeng-shu33 / ToChinese.py
Last active May 15, 2020
convert scientific workplace generated tex files to normal tex files
View ToChinese.py
#!/usr/bin/python
#coding=utf-8
import re
import os
def toUnicode(num):
try:
return eval("u"+"'\u{0}'".format(num))
except Exception as e:
import pdb
pdb.set_trace()
View compressimages.py
from PIL import Image, ImageFile
from sys import exit, stderr
from os.path import getsize, isfile, isdir, join
from os import remove, rename, walk, stat
from stat import S_IWRITE
from shutil import move
from argparse import ArgumentParser
from abc import ABCMeta, abstractmethod
class ProcessBase: