Skip to content

Instantly share code, notes, and snippets.

View shanehou's full-sized avatar

Shane Hou shanehou

View GitHub Profile
@shanehou
shanehou / cnki-search.go
Created September 14, 2013 08:34
代码没写好,数据多的话就会超边界……另外,err的处理很蛋疼,不知道啥方法比较好,求指导……
package main
import (
"encoding/csv"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/http/cookiejar"
"net/url"
@shanehou
shanehou / Hospital Charges Data
Last active January 3, 2016 06:19
全部代码在这里了……Google的文档不太全,研究了一阵才反应过来,之前忘了给div设置高度……为了美观还加了一个footer,直接把我原来的代码拷过来了一点儿……
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hospital Charges Data</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7/html5shiv.js"></script>
<![endif]-->
@shanehou
shanehou / TfIdf_list.py
Last active August 29, 2015 13:57
199801_clear_new.txt是你的源文件去掉所有空行的版本,给你发过的。_list.py用list实现了,满足你的要求……
#!/usr/bin/env python2
#coding=utf-8
#encoding=utf-8
from __future__ import division
from collections import Counter
from math import log, sqrt
from time import clock
def benchmark(func):
@shanehou
shanehou / tf-idf
Last active August 29, 2015 13:57
#!/usr/bin/env python2
#coding=utf-8
#encoding=utf-8
import logging
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
from collections import OrderedDict
from gensim import corpora, models, similarities
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
int number_of_digits(int num) {
int count = 0;
for (count = 0; num != 0; count++, num /= 10);
return count;
}
@shanehou
shanehou / UTF16
Created April 13, 2014 14:09
UTF16 LE BOM
package main
import "fmt"
import "bufio"
import "os"
func main() {
src, err := os.Open("RegistryBOM")
if err != nil {
panic(err)
@shanehou
shanehou / browser
Created April 14, 2014 12:21
browser里面第7行输出的结果里面有"registry=RegistryFileName",但是server里面第4行输出空……
$('#importFile').on('click', function(event) {
var $this = $(this);
var $registryFile = $('#registryFile');
event.preventDefault();
$.ajax({
beforeSend: function(jqXHR, settings) {
console.log(settings);
$registryFile.parent('.form-group').removeClass('has-error');
$registryFile.next('.help-block').text('Importing... Please wait...');
$this.prop('disabled', true);
@shanehou
shanehou / China Map
Last active August 29, 2015 14:00 — forked from wujing278/China Map
就是这样,不行么?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ECharts</title>
<!-- 来自百度CDN -->
</head>
<body>
<!--Step:2 Prepare a dom for ECharts which (must) has size (width & hight)-->
<!--Step:2 为ECharts准备一个具备大小(宽高)的Dom-->
@shanehou
shanehou / 4chan.php
Created April 24, 2014 12:06
4chan source code duplicate
<?
if(file_exists('/www/global/lockdown')) {
if($_COOKIE['4chan_auser'] && $_COOKIE['4chan_apass'] && ($_POST['mode']=='usrdel'||$_GET['mode']=='latest')) {
// ok
}
else {
die('Posting temporarily disabled. Come back later!<br/>&mdash;Team 4chan (uptime? what\'s that?)');
}
}
include_once "./yotsuba_config.php";
@shanehou
shanehou / ant-colony.py
Last active August 29, 2015 14:02
蚁群算法,资源分配
#!/usr/bin/env python3
import random
from bisect import bisect
from itertools import accumulate
from collections import Counter
import sys
total = 180
n = 15