Skip to content

Instantly share code, notes, and snippets.

View illy's full-sized avatar
💭
I may be slow to respond.

illy

💭
I may be slow to respond.
View GitHub Profile
@illy
illy / uob_phd_pdf.txt
Created April 20, 2012 13:56
This is a brief statistics of UoB PhD dissertation PDF software usage.
AbuAisheh_PhD_2011.html:6:<meta name="Creator" content="PScript5.dll Version 5.2.2">
Abuelela_10_PhD.html:6:<meta name="Creator" content="TeX">
Abuissa09PhD.html:5:<meta name="Creator" content="Acrobat PDFMaker 6.0 for Word">
Acceleration_of_the_DEM_on_a_Reconfigurable_Co-Processor_2003.html:4:<meta name="Creator" content="Acrobat PDFMaker 5.0 for Word">
Adams09PhD.html:6:<meta name="Creator" content="PScript5.dll Version 5.2.2">
Adkins_10_PhD.html:6:<meta name="Creator" content="MicrosoftÆ Office Word 2007">
Ahall_11_PhD.html:6:<meta name="Creator" content="MicrosoftÆ Office Word 2007">
Ahasan07PhD.html:5:<meta name="Creator" content="Acrobat PDFMaker 7.0.7 for Word">
Ahmad10PhD.html:6:<meta name="Creator" content="PScript5.dll Version 5.2">
Ahmad11PhD_A1a.html:6:<meta name="Creator" content="MicrosoftÆ Office Word 2007">

前陣子一直打算謝謝markdown寫作,拖到現在被這位老兄搶了先,很不錯的介紹文章:[为什么Markdown+R有较大概率成为科技写作主流?](http://www.douban.com/note/220903450/).所以我就不再重複了,此文打算用問答的形式介紹下markdown對於文科寫作的意義[^ft]。

###1. 什麼是markdown?

markdown是一種輕量化的標記語言。大家所熟知的標記語言還有latex,lyx, XML,HTML,這類文本的特點就是你在編輯時可以使用各種tag來控制文本的格式。話說回來,mac下的pages,M$的docx也都時XML文檔,只是你在編輯的時候,不需要加入tag,軟件本身替你增加tag了。

這類語言最大的好處就是在編輯時,你可以很大程度的減少格式對於文本的干擾。你想啊,打開一個word文檔,你調個文字大小,設置個 加粗,二號標題,再來個 斜體 什麼的, 時間大半過去了。而標記語言的最大優勢在於,你只要使用系統能夠識別的tag就可以非常方便地控制這些格式。比如markdown,你可以先使用系統默認的那些tag來寫作,等到最後輸出的時候,配置下css模版即可。

markdown是各種標記語言中的小兄弟,一來是因為它年輕,二來因為它非常輕量化。md是 John GruberAaron Swartz 最初發明的,廣泛用於技術文檔的寫作。它的最大優勢在於人機皆可讀 (machine-readble, human-readble)。

@illy
illy / sed and awk notes.md
Created July 31, 2012 22:15
sed and awk notes

##AWK notes##

  1. selective printing

     awk '$2 ~ regex, { $1="", pring $0}' 
    

If $2 = regex, then print the whole line but not $1

  1. convert a single line to multiple lines
@illy
illy / ggplot2_heat_map.r
Last active December 10, 2015 22:59
Sample script of using ggplot to plot acf matrix data.
m.geQuote <- as.matrix(geQuote[,2:5])
acf.geQuote <- acf(m.geQuote, lag=5, plot=F, na.action=na.contiguous)
m.acf.geQuote <- melt(acf.geQuote$acf)
m.acf.geQuote$Var1[m.acf.geQuote$Var1 == 1] <- "Day0"
m.acf.geQuote$Var1[m.acf.geQuote$Var1 == 2] <- "Day1"
m.acf.geQuote$Var1[m.acf.geQuote$Var1 == 3] <- "Day2"
m.acf.geQuote$Var1[m.acf.geQuote$Var1 == 4] <- "Day3"
m.acf.geQuote$Var1[m.acf.geQuote$Var1 == 5] <- "Day4"
m.acf.geQuote$Var1[m.acf.geQuote$Var1 == 1] <- "Day0"
m.acf.geQuote$Var1[m.acf.geQuote$Var1 == 2] <- "Day1"
m.acf.geQuote$Var1[m.acf.geQuote$Var1 == 3] <- "Day2"
m.acf.geQuote$Var1[m.acf.geQuote$Var1 == 4] <- "Day3"
m.acf.geQuote$Var1[m.acf.geQuote$Var1 == 5] <- "Day4"
m.acf.geQuote$Var1 <- factor(m.acf.geQuote$Var1,
+ levels=unique(m.acf.geQuote$Var1), ordered=T)
m.acf.geQuote$Var2[m.acf.geQuote$Var2 == 1] <- "Open"
m.acf.geQuote$Var2[m.acf.geQuote$Var2 == 2] <- "Close"
p <- ggplot(m.acf.geQuote)
p <- p + geom_raster(aes(x=Var1, y=Var2, lable=value, fill= value)) +
facet_wrap(~Var3, nrow=4) +
ggtitle("Cross-correlation of 4 different prices of GE ticker") +
theme(legend.position="none") +
labs(fill="Correlation") +
xlab("") + ylab("")
print(p)
str(acf.geQuote)
List of 6
$ acf : num [1:5, 1:4, 1:4] 1 -0.1917 -0.478 0.1049 0.0648 ...
$ type : chr "correlation"
$ n.used: int 5
$ lag : num [1:5, 1:4, 1:4] 0 1 2 3 4 0 -1 -2 -3 -4 ...
$ series: chr "m.geQuote"
$ snames: chr [1:4] "Open" "Close" "Low" "High"
- attr(*, "class")= chr "acf"
m.geQuote <- as.matrix(geQuote[,2:5])
acf.geQuote <- acf(m.geQuote, lag=5, plot=F, na.action=na.contiguous)
m.acf.geQuote <- melt(acf.geQuote$acf)
@illy
illy / crawl.sh
Last active December 11, 2015 03:58
script for crawling and preprocessing tweet data
## This script is for crawling tweets with a specific address file.
#!/usr/bin/env bash
DIR=PARENT_DIR/`date "+%d-%m-%y-%H:%M"` #set the download file based to download date
mkdir -p $DIR #make dir according to above
wget -i EXTERNAL_ADDRESS_LIST -np -r -N -l1 -P $DIR
@illy
illy / Useful_R_Commands.md
Last active December 14, 2015 08:28
Some useful R commands.

##1 Data manipulation

  1. If the data contains NA values, it regards it as factor, not numeric.

     DATA$COLUMN <- as.numeric(as.character(DATA$COLUMN))
    
  2. Rename the column:

     names(DATA)[2] <- "NEW_NAME"