I hereby claim:
- I am apwan on github.
- I am wuyj (https://keybase.io/wuyj) on keybase.
- I have a public key ASAgLnFoCB8WAkAkPr_KCUz2keFstldIzD2iz_pFcDTb6Ao
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
#!/usr/bin/env bash | |
# simply test localhost https, set {rejectUnauthorized: false} when make requests to bypass certificate checking | |
node -e 'const app=require("https-localhost")(); app.get("/", (req, res)=>{console.log(req.headers); res.send("Hello");}); app.listen(443);' |
# rearrange pages | |
def gen(n4): | |
n = n4//4 | |
a1 = [[4*n-2*i, 2*i+1, 2*i+2, 4*n-2*i-1] for i in range(n)] | |
return [str(k) for x in a1 for k in x] | |
''' | |
Example: ','.join(gen(44)) | |
Output: '44,1,2,43,42,3,4,41,40,5,6,39,38,7,8,37,36,9,10,35,34,11,12,33,32,13,14,31,30,15,16,29,28,17,18,27,26,19,20,25,24,21,22,23' | |
''' |
#!/usr/bin/env bash | |
# batch_grading.sh for COMP3270 | |
# by Yijie | |
# example: | |
# (1) ZIP_DIR=folder_of_decompressed_submissions STUDENT_ROOT=output_folder PROJECT=a1 timelimit=60s ./batch_grading.sh | |
# (2) ./batch_grading.sh summary time_60s.txt > error_ids.txt | |
CMD="$0" | |
ZIP_DIR=${ZIP_DIR:-../a1_zip} # download all submitted files and decompress into this directory | |
STUDENT_ROOT=${STUDENT_ROOT:-student_code} |
vicmd() { | |
[ "$#" -lt 1 ] && echo "Usage: $0 [CMD_name]" >&2 && return 1; | |
# check alias | |
#echo "type $(type -t $1)" | |
[[ "$(type -t $1)" =~ ("alias"|"builtin"|"function") ]] && echo "$1 is $(type -t $1), not a valid cmd! " >&2 && return 1 | |
local CMD_="$(which $1 2>/dev/null)" | |
[ -x "$CMD_" ] && vi "$CMD_" || vi "$MY_SHARE_HOME/bin/$1" | |
} |
# check if git/pypi http servers fail # crontab -e | |
*/20 * * * * root /usr/bin/bash -c ". ~/.bashrc; svgits.sh --check >/dev/null 2>&1" | |
*/30 * * * * root /usr/bin/bash -c ". ~/.bashrc; svpypis.sh --check >/dev/null 2>&1" |
# source: https://superuser.com/questions/277642/how-to-merge-audio-and-video-file-in-ffmpeg | |
# merge with audio re-encoding | |
ffmpeg -i video.mp4 -i audio.wav -c:v copy -c:a aac -strict experimental output.mp4 | |
# merge without audio re-encoding | |
ffmpeg -i video.mp4 -i audio.wav -c copy output.mkv | |
# replace audio stream | |
ffmpeg -i video.mp4 -i audio.wav -c:v copy -c:a aac -strict experimental \ |
#!/usr/bin/env python | |
import urllib.request | |
def get_img(img_src, img_name): | |
contents = urllib.request.urlopen(img_src).read() | |
with open(img_name, 'wb') as f | |
f.write(contents) |
const fs = typeof require != 'undefined'? require('fs'): {}; | |
function catFile(path){ | |
return fs.readFileSync(path).toString() | |
} | |
function CSVToArray(strData, strDelimiter) { | |
// Check to see if the delimiter is defined. If not, | |
// then default to COMMA. | |
strDelimiter = (strDelimiter || ","); |
#!/usr/bin/env node | |
//app.js | |
var http = require('http'); | |
server = http.createServer(function(req, res){ | |
res.writeHead(200, {'Content-Type': 'text/html'}); | |
res.write('<h1>Node.js</h1>'); | |
res.end('<p>Hello World</p>'); | |
}).listen(process.env.PORT||4321); |