7
15
2011
0

SAE 上开发 股票提醒程序

全程基本用在线 sdk。不写历程直接看最终成果就好。

kvdb 又慢又不稳,郁闷,只能用下面这个东西。(怪不得文档里面老是去查$ret)

其实精华就是这个 kvget 函数。。。
代码如下
<?php
/*
so price is actually target price.
$vcodepricepair = "code price";
$vphonepwd = "phone pwd";
"vphone" => $vphones = "phone pwd,phone pwd";
$phone => $vlist = "code price,code price";
*/
function kvget ($kv, $key) {
	$ret = false;
	while(!$ret) $ret = $kv->get("$key");
	return $ret;
}

$kv = new SaeKVClient();
$ret = false;
while (!$ret) $ret = $kv->init();

$vphones = kvget($kv, 'vphones');
$vphonepwds = explode(",", $vphones);

foreach($vphonepwds as $vphonepwd) {
	//decode
	$phonepwd = explode(" ", $vphonepwd);
	$phone = $phonepwd[0];
	$pwd = $phonepwd[1];	
	$vlist = $kv->get($phone);
	$list = explode(",", $vlist);
	
	foreach ($list as $vcodepricepair) {
		//decode
		$codepricepair = explode(" ", $vcodepricepair);
		$code = $codepricepair[0];
		$price = $codepricepair[1];
		
		//get data
		$url = "http://api.liqwei.com/stock/?code=$code";
		$data = file_get_contents($url);
		$elements = explode(",", $data);
		$cprice = $elements[1]; // current price

		//send msg
		if ($price >= $cprice - 0.05 || $price <= $cprice + 0.05) {
			$url = "http://sms.bber.info/api.php?phone=$phone&pwd=$pwd&to=$phone&msg=$code,$cprice";
			fopen("$url", 'r');
		}
	}
}

 

http://sms.bber.info/ 为 飞信网页版 和 api

参见 http://3haku.net/2010/11/25/php%E9%A3%9E%E4%BF%A1-pafetion-%E5%BC%80%E6%BA%90%E5%95%A6.html

hq.sinajs.cn 为 sina 财经 api,日,sina自己不让抓自己!

http://api.liqwei.com/stock/?code=sh:600028 用这个了

KVDB 限制如下

set (line 136)

更新key对应的value

  • return: 成功返回true,失败返回false
bool set (string $keystring $value)
  • string $key: 长度小于256字节
  • string $value: 长度小于4MB

 

Category: 未分类 | Tags: php stock sae kvdb
7
10
2011
0

这几天摸过的东西

首先是给妈妈录成绩用的 vba 代码

Sub 自动成绩填充():


Application.ScreenUpdating = False

For i = 2 To 58
    For j = 2 To 58
        If Sheet1.Cells(i, "A").Value = Sheet1.Cells(j, "G").Value Then
            Sheet1.Cells(i, "B").Value = Sheet1.Cells(j, "I").Value
            Sheet1.Cells(i, "C").Value = Sheet1.Cells(j, "J").Value
            Sheet1.Cells(i, "D").Value = Sheet1.Cells(j, "K").Value
        End If
    Next j
Next i
    
Application.ScreenUpdating = True


End Sub

然后是 go http://golang.org/ 做了个小 wiki

然后又摸了 php

这里要说下 sae ,尝试部署了以下项目:

vanilla 搞不懂

Wordpress 用向导,install.php不能

Question2Answer InnoDB 不能

qwench 中文不能

也把那些框架都小试了一边

 

 

Category: 随记 | Tags: go php sae vba excel

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com