Skip to content

Instantly share code, notes, and snippets.

@yanping
yanping / _config.yml
Created January 21, 2012 14:45 — forked from davefearon/_config.yml
Jekyll + Liquid + pagination = win!
paginate: 5
@yanping
yanping / feedsky.html
Created April 20, 2012 02:35
show post list with feedsky
<div id="recent">
<!-- Feedsky FEED JS发布代码开始 -->
<script src="http://feed.feedsky.com/yanping/jsout&amp;n=5&amp;e=utf8">
</script>
<div class="reader-publisher-module" id="readerpublishermodule0" style="border: 1px solid rgb(188, 204, 235); margin: 0.5em; padding: 0pt; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; text-align: left; text-indent: 0pt; text-decoration: none; font-weight: normal; font-family: arial,sans-serif; font-size: 10pt; -moz-border-radius-topleft: 8px; -moz-border-radius-topright: 8px; -moz-border-radius-bottomright: 8px; -moz-border-radius-bottomleft: 8px;">
<h3 style="border-style: none none solid; border-color: -moz-use-text-color -moz-use-text-color rgb(188, 204, 235); border-width: medium medium 1px; margin: 0pt 0.5em; padding: 0.2em 0pt; background: transparent none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-
@yanping
yanping / test.R
Created October 1, 2012 06:24 — forked from nanxstats/test.R
R Code for Reading HTML Tables with XML
require(XML)
pg1 = 'http://www.wxtj.gov.cn/tjxx/tjsj/ydzyzb/index.shtml'
pg2 = 'http://www.wxtj.gov.cn/tjxx/tjsj/ydzyzb/index_2.shtml'
pg3 = 'http://www.wxtj.gov.cn/tjxx/tjsj/ydzyzb/index_3.shtml'
pg4 = 'http://www.wxtj.gov.cn/tjxx/tjsj/ydzyzb/index_4.shtml'
url1 = htmlTreeParse(pg1, useInternal = TRUE)
url2 = htmlTreeParse(pg2, useInternal = TRUE)
url3 = htmlTreeParse(pg3, useInternal = TRUE)
@yanping
yanping / generate_archives.rb
Created October 14, 2012 16:13 — forked from stympy/generate_archives.rb
Archive generator plugin for jekyll
# Jekyll archive page generator with pagination.
#
# Based on the category generator from
# http://recursive-design.com/projects/jekyll-plugins/,
# which is copyright (c) 2010 Dave Perrett,
# http://recursive-design.com/ and is licensed under the MIT
# license (http://www.opensource.org/licenses/mit-license.php), and
# on the pagination code from Jekyll itself.
#
# This code is copyright (c) 2011 Benjamin Curtis, and is licensed
@yanping
yanping / excerpt.rb
Created October 14, 2012 16:14 — forked from stympy/excerpt.rb
Jekyll excerpt plugin
# This goes in _plugins/excerpt.rb
module Jekyll
class Post
alias_method :original_to_liquid, :to_liquid
def to_liquid
original_to_liquid.deep_merge({
'excerpt' => content.match('<!--more-->') ? content.split('<!--more-->').first : nil
})
end
end
@yanping
yanping / jsonball.rb
Created October 15, 2012 01:24 — forked from ahgittin/jsonball.rb
a jekyll tag to parse json files and objects for use as maps subsequently
require 'json'
# JSON parser tag, creating map for use in jekyll markdown
# Alex.Heneveld @ Cloudsoft Corp (remove spaces and add the .com)
# Released under APL 2.0
# usage: {% jsonball varname from TYPE PARAM %}
#
# where TYPE is one of {data,var,file,page}, described below
@yanping
yanping / imgurUploader.r
Created October 17, 2012 08:14
upload image file to imgur.com
require(utils)
require(tcltk)
require(RCurl)
img.upload <- function(){
if(any(ls(envir=.GlobalEnv)=="fileName")) {
rm(fileName,envir=.GlobalEnv)
}
if(any(ls(envir=.GlobalEnv)=="uploadInfo")) {
#解决安装Pygments后出现Liquid error: bad file descriptor的问题
diff --git a/lib/albino.rb b/lib/albino.rb
index 387c8e9..b77d55e 100644
--- a/lib/albino.rb
+++ b/lib/albino.rb
@@ -1,4 +1,5 @@
require 'posix-spawn'
+require 'rbconfig'
##
@yanping
yanping / etf-and-lof.r
Created November 8, 2012 13:09
基金数据的整理
# 数据文件的下载地址 http://dl.vmall.com/c0a13rrt7p
# 基金基本信息数据来自 http://quote.eastmoney.com/center/fund.html
# 历史行情数据来自天相
setwd("C:/etf/data")
etf <- read.csv("etf.csv")
lof <- read.csv("lof.csv")
colnames(etf) <- c("jjdm","jjmc","bdzs","glr","clgm","zcgm","clsj","tgr")
colnames(lof) <- c("jjdm","jjmc","bdzs","glr","clgm","zcgm","clsj","tgr","tgfl","glfl")
@yanping
yanping / xls2csv.bas
Created November 8, 2012 16:20
批量转换xls为csv的VBA代码
'批量转换文件夹中的xls为csv
'地址 http://www.cnblogs.com/snippet/archive/2010/07/06/xls2csv.html
Option Explicit
Sub covertFile(ByRef sFilename As String)
Dim oWorkbook As Workbook
Set oWorkbook = Workbooks.Open(Filename:=sFilename)
oWorkbook.SaveAs Filename:=sFilename & ".csv", FileFormat:= _
xlCSV, CreateBackup:=False