Skip to content

Instantly share code, notes, and snippets.

View yfwu's full-sized avatar

Yu-Fu Wu yfwu

View GitHub Profile
@yfwu
yfwu / s2t.md
Last active January 24, 2018 18:36
notes about transform speech to text in macOS

用的是三年沒更新的但是不會有問題的 homebrew-cmu-sphinx

brew tap watsonbox/cmu-sphinx
brew install --HEAD watsonbox/cmu-sphinx/cmu-sphinxbase
brew install --HEAD watsonbox/cmu-sphinx/cmu-sphinxtrain # optional
brew install --HEAD watsonbox/cmu-sphinx/cmu-pocketsphinx
brew install ffmpeg

ffmpeg 是把各類視訊、音訊檔案轉換成 wav 用的。

@yfwu
yfwu / RADLEX.py
Created December 20, 2017 13:23
RADLEX
import csv, pprint
with open('RADLEX_U.csv', 'r') as f:
original = csv.reader(f)
header = next(csv.reader(f))
internal = []
for row in csv.reader(f):
internal.append(dict(zip(header, row)))
@yfwu
yfwu / data.yaml
Created November 14, 2017 15:19
Data sample
name: {name: Name}
id: {name: ID}
age: {name: Age}
ccmain:
name: 'Chief Complain'
dynamic: True
group: chiefcomplain
data: [head, face, neck, chest, 'abdomen & pelvic', 'lower back']
default: {4: {'abpe':1}}
ccspecial:
@yfwu
yfwu / select.html
Created November 14, 2017 15:18
Jinja2 sample
{# input: id, name, options, dependences (dep) #}
{# dep = {1:['id_1',2], 1:['id_2', 3], 2:['id_3', 1]} #}
<script>
var {{ id }}_onchange = function() {
var dep = {{ dep }};
for (const key in dep) {
if (document.getElementsByName('{{ id }}') == key) {
document.getElementsByName(dep[key][0]).value = dep[key][1];
}
@yfwu
yfwu / filtercsv.py
Last active July 5, 2017 09:09
for filter a large csv file
#!/bin/env python
import csv
import sys
def genData(filename):
with open(filename, 'r') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
yield(row)
@yfwu
yfwu / separate.R
Last active February 28, 2017 16:09
write lines to separate files
library('xlsx')
original <- read.xlsx('samplefile.xlsx', sheetIndex = 1, header = FALSE)
for (i in seq_along(original$X1)){
writeLines(paste(original$X1[i]), paste(i, ".txt", sep = ""))
}
@yfwu
yfwu / getftp.py
Last active February 22, 2017 03:06
get ftp files with selection
#!/bin/env python
import ftplib
import wanted # write wanted files in a variable "wanted" as a list
# configuration
url = "ftp.patricbrc.org"
user = "anonymous"
password = "anonymous"
@yfwu
yfwu / eucast2.R
Last active February 2, 2017 05:16
For parse EUCAST data
# eucast2.R
base_url <- "http://mic.eucast.org/Eucast2/SearchController/search.jsp?action=performSearch&BeginIndex=0&Micdif=mic&NumberIndex=1000&Antib=-1&Specium="
bigtable <- data.frame()
for (i in 1:806){
real_url <- paste(base_url, i, sep = "") # combine url with species number
doc = htmlParse(real_url) # read the html
name <- xpathSApply(doc, "/html/body/p[1]/b[1]//text()", saveXML)[[1]] # get microbe's name
table <- readHTMLTable(doc)[4]$`NULL`[-seq(16,640,16),c(0:20,22)] # get the main table
@yfwu
yfwu / keybase.md
Last active November 6, 2016 13:46
Keybase

Keybase proof

I hereby claim:

  • I am yfwu on github.
  • I am yfwu (https://keybase.io/yfwu) on keybase.
  • I have a public key ASBrFzDXDS1y-PaIRbreGIM4Bof4216pcc5DTMLKbFFj3Qo

To claim this, I am signing this object:

@yfwu
yfwu / ncurses.sh
Created July 27, 2016 07:01
for Matlab r2016a
for lib in ncurses ncurses++ form panel menu; do
sudo ln -s /usr/lib/lib${lib}w.so.5 "$pkgdir"/usr/lib/lib${lib}.so.5
done