Skip to content

Instantly share code, notes, and snippets.

View tachi-hi's full-sized avatar
🍊
tachibana is a kind of citrus fruits and trees.

Hideyuki Tachibana tachi-hi

🍊
tachibana is a kind of citrus fruits and trees.
View GitHub Profile
@tachi-hi
tachi-hi / gist:3402572
Created August 20, 2012 09:16
makefile for TeX (manual version management)
#
# makefile for TeX document whose version number is managed manually
# e.g.
# document_v1.tex document_v2.tex ...
#
LATEX = latex
BIBTEX = bibtex
DVIPDF = dvipdf
RM = rm -f
@tachi-hi
tachi-hi / gist:2779734
Created May 24, 2012 06:02
Non-negative Matrix Factorization
# Given matrix V, and decompose it as
# V ~ W %*% H
NMF.EUC <- function(V, r, n){
W <- matrix(runif(nrow(V)*r), nrow(V), r)
H <- matrix(runif(ncol(V)*r), r, ncol(V))
d <- c(0)
for(i in 1:n){
W <- W * (V %*% t(H)) / (W %*% H %*% t(H))
H <- H * (t(W) %*% V) / (t(W) %*% W %*% H)
@tachi-hi
tachi-hi / LatestExcelFileFinder.sh
Created May 18, 2012 18:11
A way to find the latest excel file
#!/usr/bin/bash
# >> ls *.xls
# xxx_v1.xls xxx_v10.xls xxx_v2.xls xxx_v3.xls
#
# we'd like to find the latest version.
ls *.xls | sed -e 's/.*_v\([0-9]*\).*/\1/g' | sort -n | tail -n 1
# or