Skip to content

Instantly share code, notes, and snippets.

View erickguan's full-sized avatar

Erick Guan erickguan

View GitHub Profile
@erickguan
erickguan / PRC_natural_reserves.csv
Created May 21, 2017 17:07
CSV exports from P.R.C. national natural reserves via Tabula. PDF from: http://sts.mep.gov.cn/zrbhq/zrbhq/201611/P020161125559865886359.pdf
序号 保护区名称 行政区域 面积 主要保护对象 类型 级别 始建时间 主管部
京01 百花山 北京市门头沟区 21743.1 温带次生林 森林生态 国家级 19850401 林业
京02 拒马河 北京市房山区 1125 大鲵等水生野生动物 野生动物 省级 19961121 农业
京03 蒲洼 北京市房山区 5396.5 森林生态系统 森林生态 省级 20050404 林业
京04 石花洞 北京市房山区 3650 岩溶洞穴 地质遗迹 省级 20001226 国土
京05 汉石桥湿地 北京市顺义区 1615 湿地生态系统及野生动植物 内陆湿地 省级 20050404 林业
京06 怀沙河、怀九河 北京市怀柔区 111 大鲵、中华九刺鱼、鸳鸯等野生动物 野生动物 省级 19961121 农业
京07 喇叭沟门 北京市怀柔区 18482.5 森林生态系统 森林生态 省级 19991213 林业
京08 四座楼 北京市平谷区 19997 森林生态系统 森林生态 省级 20021229 林业
京09 密云雾灵山 密云县 4152.4 森林生态系统及金钱豹等珍稀动植物 森林生态 省级 20001226 林业
library("class")
iris <- read.csv("/Users/fantasticfears/Downloads/iris.csv", header=FALSE)
irisShuffled <- iris[sample(nrow(iris)),]
irisShuffledRaw <- irisShuffled[,1:4]
train <- irisShuffledRaw[1:100,]
test <- irisShuffledRaw[101:nrow(iris),]
cl <- factor(as.array(irisShuffled[1:100,5]))
predicted <- knn(train, test, cl, prob=TRUE)
@erickguan
erickguan / web.china.template.yml
Created March 15, 2016 12:33
展示一下 CA 证书的配置情况
hooks:
before_web:
- exec:
cmd:
- curl -o /shared/cacerts.pem https://curl.haxx.se/ca/cacert.pem
- export SSL_CERT_FILE=/shared/cacerts.pem
- cat -n /shared/cacerts.pem
- ls -alh /shared
- gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
@erickguan
erickguan / tcp-lab3-plot-generator.py
Created October 30, 2015 22:17
A python script generate bit rate plot based on csv exported from Wireshark
import csv
import numpy as np
import matplotlib.pyplot as plt
start_time = 45.0
tick = 1
end_time = start_time + 60.0 * 2
protocol = 'TCP'
with open('hls2.csv', newline='') as csvfile:
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
瑞典
中瑞典大学
@erickguan
erickguan / Gemfile
Created May 10, 2015 11:39
common gemfile
source 'https://rubygems.org'
gem 'rails', '4.2.1'
gem 'pg'
gem 'sass-rails', '~> 5.0'
gem 'sprockets', '~> 3.0.3'
gem 'sprockets-es6'
gem 'pundit'
gem 'refile'
# encoding: utf-8
#
# Author: Erick Guan <fantasticfears@gmail.com>
#
# This script import the data from latest Discuz! X
# Should work among Discuz! X3.x
# This script is tested only on Simplified Chinese Discuz! X instances
# If you want to import data other than Simplified Chinese, email me.
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
@erickguan
erickguan / a.sql
Last active August 29, 2015 14:06
SQL
/* Easy Drop */
DROP TABLE selected_courses;
DROP TABLE students;
DROP TABLE courses;
DROP TABLE teachers;
/* 1: Create table structure */
CREATE TABLE teachers (id INTEGER NOT NULL, name CHAR(8) NOT NULL, title CHAR(10), PRIMARY KEY(id));
CREATE TABLE courses (id INTEGER NOT NULL, name CHAR(10) NOT NULL, teacher_id INTEGER, PRIMARY KEY(id));
CREATE TABLE students (id INTEGER NOT NULL, name CHAR(8) NOT NULL, age SMALLINT, sex CHAR(1), PRIMARY KEY(id));
@erickguan
erickguan / UVA_10180.cpp
Last active August 29, 2015 14:01
UVa 10180
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
static const double eps = 1e-8;
int cmp(double x)