Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 json | |
if __name__ == "__main__": | |
docs = [] | |
with open('./law200.json','r',encoding='utf-8') as f: | |
for line in f.readlines(): | |
doc = json.loads(line) | |
docs.append(doc) | |
print(len(docs)) |
This file contains hidden or 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
/* | |
Copy this into the console of any web page that is interactive and doesn't | |
do hard reloads. You will hear your DOM changes as different pitches of | |
audio. | |
I have found this interesting for debugging, but also fun to hear web pages | |
render like UIs do in movies. | |
*/ | |
const audioCtx = new (window.AudioContext || window.webkitAudioContext)() |
This file contains hidden or 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 time | |
import progressbar | |
print('in range') | |
for i in progressbar.progressbar(range(20)): | |
time.sleep(0.02) | |
print('in list') | |
my_list = [1]*100 | |
with progressbar.ProgressBar(max_value=len(my_list)) as bar: |
This file contains hidden or 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 os | |
os.environ["CUDA_VISIBLE_DEVICES"] = "0" |
This file contains hidden or 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
# ubnutu | |
# /etc/ssh/sshd_config | |
# This is the ssh client system-wide configuration file. See | |
# ssh_config(5) for more information. This file provides defaults for | |
# users, and the values can be changed in per-user configuration files | |
# or on the command line. | |
# Configuration data is parsed as follows: | |
# 1. command line options |
This file contains hidden or 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
const path = require('path'); | |
const express = require('express') | |
const app = express() | |
const port = 3000 | |
// For Static File | |
app.use(express.static('public')) | |
// 404 Redirect to App(Front End Route will handle next) | |
app.get('*', function(req, res){ | |
res.sendFile(path.join(__dirname+'/public/index.html')) | |
}); |
This file contains hidden or 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
from gensim.models.doc2vec import Doc2Vec, TaggedDocument | |
import csv | |
import jieba | |
# jieba初始化 | |
jieba.set_dictionary('dict/dict.txt.big') | |
jieba.load_userdict('dict/my_dict') | |
jieba.initialize() | |
# 讀入waimai_10k_tw.csv,並且使用jieba斷詞 |
This file contains hidden or 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
""" | |
pytorch CrossEntropyLoss 用法 | |
""" | |
import torch | |
import torch.nn as nn | |
import math | |
loss = nn.CrossEntropyLoss() | |
input = torch.randn(1, 5, requires_grad=True) | |
target = torch.empty(1, dtype=torch.long).random_(5) | |
output = loss(input, target) |
This file contains hidden or 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
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to | |
# newer versions of the distribution. | |
deb http://free.nchc.org.tw/ubuntu/ xenial main restricted | |
# deb-src http://free.nchc.org.tw/ubuntu/ xenial main restricted | |
## Major bug fix updates produced after the final release of the | |
## distribution. | |
deb http://free.nchc.org.tw/ubuntu/ xenial-updates main restricted | |
# deb-src http://free.nchc.org.tw/ubuntu/ xenial-updates main restricted |