Skip to content

Instantly share code, notes, and snippets.

View GZShi's full-sized avatar
🎯
Focusing

Guozhong Shi GZShi

🎯
Focusing
View GitHub Profile
@GZShi
GZShi / pac.pac
Created August 21, 2017 14:42
list
var FindProxyForURL = function(init, profiles) {
return function(url, host) {
"use strict";
var result = init, scheme = url.substr(0, url.indexOf(":"));
do {
result = profiles[result];
if (typeof result === "function") result = result(url, host, scheme);
} while (typeof result !== "string" || result.charCodeAt(0) === 43);
return result;
};
@GZShi
GZShi / 600999.csv
Last active April 23, 2017 15:27
前端练习:雅虎财经
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 16 columns, instead of 7. in line 8.
日期,股票代码,名称,收盘价,最高价,最低价,开盘价,前收盘,涨跌额,涨跌幅,换手率,成交量,成交金额,总市值,流通市值,成交笔数
2017-04-14,'600999,招商证券,16.4,16.51,16.27,16.43,16.46,-0.06,-0.3645,0.1796,8467761,138598406.0,1.09870312996e+11,77309148163.6,None
2017-04-13,'600999,招商证券,16.46,16.57,16.41,16.5,16.57,-0.11,-0.6639,0.1381,6509609,107319930.0,1.10272277555e+11,77591986510.5,None
2017-04-12,'600999,招商证券,16.57,16.67,16.33,16.47,16.45,0.12,0.7295,0.3299,15549171,257597456.0,1.11009212582e+11,78110523479.9,None
2017-04-11,'600999,招商证券,16.45,16.48,16.24,16.38,16.48,-0.03,-0.182,0.227,10701208,175120304.0,1.10205283462e+11,77544846786.1,None
2017-04-10,'600999,招商证券,16.48,16.54,16.42,16.47,16.47,0.01,0.0607,0.2503,11798833,194561548.0,1.10406265742e+11,77686265959.5,None
2017-04-07,'600999,招商证券,16.47,16.51,16.39,16.5,16.48,-0.01,-0.0607,0.2817,13278837,218419739.0,1.10339271649e+11,77639126235.0,None
2017-04-06,'600999,招商证券,16.48,16.52,16.4,16.5,16.47,0.01,0.0607,0.1868,8803868,144904233.0,1.10406265742e+11,77686265959.5,None
2017-04-05,'600999,招商证券,16.47,16.56,16.26,1
@GZShi
GZShi / index.html
Last active April 19, 2017 11:52
简易的CSV转换,将字段强制加上双引号
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>CSV 双引号转化</title>
<style>
.drop-area {
@GZShi
GZShi / calc.js
Created February 6, 2017 09:39
计算QQ邮箱信用卡账单总额
Array.prototype.map.call(
document.querySelectorAll("td.bill_balance span.info_value span.currency_rmb"),
(e,i)=>+e.innerText.replace("¥ ", "").replace(" (人民币)", "").replace(",", "")
).reduce((prev,curr)=>prev+curr,0)
@GZShi
GZShi / libevent_echo_server.cpp
Created November 7, 2016 11:45
libevent example: echo server
#include <WinSock2.h>
#include <event.h>
#include <event2/listener.h>
#include <event2/util.h>
#include <iostream>
#include <thread>
#pragma comment(lib, "libevent.lib")
#pragma comment(lib, "libevent_core.lib")
#pragma comment(lib, "libevent_extras.lib")
@GZShi
GZShi / benchmark.hpp
Created September 6, 2016 09:17
c++11 practice
#ifndef __BENCHMARK_HPP_BY_GZSHI__
#define __BENCHMARK_HPP_BY_GZSHI__
#include <functional>
#include <chrono>
template<typename TClock, typename TFn, typename ...TArgs>
TClock benchmark(TFn&& fn, TArgs&&... args) {
auto exec = std::bind(std::forward<TFn>(fn), std::forward<TArgs>(args)...);
@GZShi
GZShi / promise-lock.js
Last active June 8, 2016 06:33
并行“流量”控制
'use strict';
// promise lock
// const PromiseLock = (() => {
// function PromiseLock(concurrency) {
// this.queue = [];
// this.lock = 0;
// this.concurrency = Math.max(concurrency, 1);
// }
(function () {
if (location.host !== 'shop.48.cn') {
console.error('kidding me?');
return ;
}
if (typeof jQuery !== 'function') {
console.error('缺少基础库');
return ;
}
@GZShi
GZShi / snh48buyticket.js
Last active May 8, 2016 03:38
SNH购票…
(function () {
if (location.host !== 'shop.48.cn') {
console.error('kidding me?');
return ;
}
if (typeof jQuery !== 'function') {
console.error('缺少基础库');
return ;
}
@GZShi
GZShi / sock5-server.js
Last active April 9, 2016 09:02
根据RFC1928实现的一个sock5代理服务器,基于nodejs。已知bug:存在内存泄露
'use strict';
const net = require('net');
const local = '0.0.0.0';
const port = 1081;
var connSeq = 0;
const server = net.createServer((client) => {
var seq = connSeq++;
var uid = 1;