This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\usepackage{fontspec} %加這個就可以設定字體 | |
\usepackage{xeCJK} %讓中英文字體分開設置 | |
\setCJKmainfont{微軟正黑體} %設定中文為系統上的字型,而英文不去更動,使用原TeX字型 | |
\XeTeXlinebreaklocale "zh" %這兩行一定要加,中文才能自動換行 | |
\XeTeXlinebreakskip = 0pt plus 1pt %這兩行一定要加,中文才能自動換行 | |
\defaultCJKfontfeatures{AutoFakeBold=6,AutoFakeSlant=.4} %以後不用再設定粗斜 | |
\newCJKfontfamily\Kai{標楷體} %定義指令\Kai則切換成標楷體 | |
\newCJKfontfamily\Hei{微軟正黑體} %定義指令\Hei則切換成正黑體 | |
\newCJKfontfamily\NewMing{新細明體} %定義指令\NewMing則切換成新細明體 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define __ASSERT1__(x) __REPORT__(x).__ASSERT2__ | |
#define __ASSERT2__(x) __REPORT__(x).__ASSERT1__ | |
#define __REPORT__(x) report(#x,(x)) | |
#define ASSERT(cond, msg) if(!(cond)) Assert(#cond,msg,__FILE__,__LINE__).__ASSERT1__ | |
#include <iostream> | |
struct Assert { | |
template<class T> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Json Pretty Print | |
json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4) | |
# Json Print Entities instead of \uXXXX | |
json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4, ensure_ascii=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- in global scope | |
if not ... then | |
print "main" | |
else | |
print "library" | |
end | |
[[ | |
$ luajit test.lua |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sys' | |
local n = 100000 | |
local seq = {} | |
for i = 1, n do seq[i] = i end | |
local bs = 405 | |
local plainLoop = function() | |
local yield = {} | |
for i = 1, #seq do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FULL2HALF = { | |
r' ' : r' ', # full space and halfspace | |
r'!' : r'!', r'"' : r'"', r'#' : r'#', r'$' : r'$', r'%' : r'%', | |
r'&' : r'&', r''' : r"'", r'(' : r'(', r')' : r')', r'*' : r'*', | |
r'+' : r'+', r',' : r',', r'-' : r'-', r'.' : r'.', r'/' : r'/', | |
r'0' : r'0', r'1' : r'1', r'2' : r'2', r'3' : r'3', r'4' : r'4', | |
r'5' : r'5', r'6' : r'6', r'7' : r'7', r'8' : r'8', r'9' : r'9', | |
r':' : r':', r';' : r';', r'<' : r'<', r'=' : r'=', r'>' : r'>', | |
r'?' : r'?', r'@' : r'@', r'A' : r'A', r'B' : r'B', r'C' : r'C', | |
r'D' : r'D', r'E' : r'E', r'F' : r'F', r'G' : r'G', r'H' : r'H', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import argparse | |
import json | |
import sys | |
import collections | |
import itertools | |
def main(args): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from torch.autograd import Variable as V | |
import numpy as np | |
a = V( torch.from_numpy( np.asarray([1.112]) ) ).float() | |
b = V( torch.rand(1) ) | |
c = a + b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get dir of current file | |
import os | |
this_path = os.path.dirname(os.path.realpath(__file__)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" convert \xHHHH into Unicode character. | |
:%s#\\x\([0-9a-f]\{4\}\)#\=nr2char(str2nr(submatch(1),16))#g |
OlderNewer