星期三, 9月 30, 2009

matlab 100101


% program file lab100101.m
clear all;
a=10;
ts = 0.001;
t1 = -0.5:ts:0.5;
x1 = a*cos(2*pi*5*t1);

ts2 = 0.05;
t2 = -0.5:ts2:0.5;
x2 = a*cos(2*pi*5*t2);

ts3 = 0.01;
t3 = -0.5:ts3:0.5;
x3 = a*cos(2*pi*5*t3);

subplot(311);
plot(t1,x1);
xlabel('t,(s)');
ylabel('x(t)');
grid;

subplot(312);
stem(t2,x2);
xlabel('t,(s)');
ylabel('x(t)');
grid;

subplot(313);
stem(t3,x3);
xlabel('t,(s)');
ylabel('x(t)');
grid;

星期三, 9月 23, 2009

【matlab】 090924work

matlab work2

% program file lab092401.m
clear all;

dt = 0.01;
w = 2;
a = 10;
k = 0;
for t = -10:dt:10
k = k+1;
x(1,k) = a * cos(w*t);
end
tt = -10:dt:10;
plot(tt,x);

% t = -10:dt:10;
% a = 10;
% x = a * cos(w*t);
% plot(t,x);

xlabel('t,(s)');
ylabel('x(t)');
grid;



% program file lab092402.m
dt = 0.01;
w = 2;
t = -10:dt:10;
a = 10;
x1 = a * cos(w*t);
td = -0.5;
x2 = a * cos(w*(t+td));
subplot(211);
plot(t,x1);
xlabel('t,(s)');
ylabel('x(t)');
grid;

subplot(212);
plot(t,x2);

xlabel('t,(s)');
ylabel('x(t)');
grid;



% program file lab092403.m
clear all;
dt = 0.01;
w = 2;
t = -10:dt:10;
a = 10;
x1 = a * cos(w*t);
td = -0.5;
x2 = a * cos(w*(t+td));

subplot(311);
plot(t,x1);
xlabel('t,(s)');
ylabel('x(t)');
grid;

subplot(312);
plot(t,x2);
xlabel('t,(s)');
ylabel('x(t)');
grid;

subplot(313);
%figure(2);
plot(t,x1,'r');
hold on;
plot(t,x2,'g');
xlabel('t,(s)');
ylabel('x(t)');
grid;

星期日, 9月 20, 2009

【Blogger】SyntaxHighlighter 2.0

在 http://spenthil.com/2009/04/12/syntaxhighlighter-2-0-on-blogger/
有些說明。





< pre class=" brush: [語法]"></pre>

義氣仔女 v0.1 腳本

修改自 neo@orz.hk, Moochi, 真正john
關閉自動任務 id = 0
代客泊車 id:1, req:1
賣翻版DVD id:2, req:3
幫財務公司收數 id:3, req:5
麻將館睇埸 id:4, req:7
走水貨返大陸 id:5, req:10
偷車 id:6, req:12
放貴利 id:7, req:14
打劫銀行 id:8, req:16
連環洗劫金鋪 id:9, req:20
綁架重要人物 id:10, req:25
走私毒品 id:11, req:30
經營外圍投注 id:12, req:35


this.renwu_selece_id = 5; //修改任務
this.renwu_selece_reg = 10; //修改體力


// ==UserScript==
// @name cx-sf-t1
// @description by CX, neo@orz.hk, Moochi, 真正john
// @namespace http://apps.facebook.com/street-fights/
// @include http://apps.facebook.com/street-fights/job.php
// @include http://apps.facebook.com/street-fights/bank.php
//2009-8/28 cx-sf-t1 Version 0.1 by cx
// ==/UserScript==
/*pf
Requirement:
- Firefox 3.0.1 or better
- Firefox plugin: Greasemonkey
- Facebook w/ the new interface

function sf_obj() 設定任務,和體力
renwu_selece: id & reg
義氣仔女Online
關閉自動任務 id = 0
代客泊車 id:1, req:1
賣翻版DVD id:2, req:3
幫財務公司收數 id:3, req:5
麻將館睇埸 id:4, req:7
走水貨返大陸 id:5, req:10
偷車 id:6, req:15
放貴利 id:7, req:18
打劫銀行 id:8, req:25
連環洗劫金鋪 id:9, req:30

代客泊車 id:1, req:1
賣翻版DVD id:2, req:3
幫財務公司收數 id:3, req:5
麻將館睇埸 id:4, req:7
走水貨返大陸 id:5, req:10
偷車 id:6, req:12
放貴利 id:7, req:14
打劫銀行 id:8, req:16
連環洗劫金鋪 id:9, req:20
綁架重要人物 id:10, req:25
走私毒品 id:11, req:30
經營外圍投注 id:12, req:35
*/

var job = "http://apps.facebook.com/street-fights/job.php";
var bank = "http://apps.facebook.com/street-fights/bank.php";
var page = "";
if(location.href == job){
page = "job";
}else{
page = "bank";
}

/*****************/
//樣板 template
function template_sf_info(){//sfobj.my_data['level']
this.template_info_data;
//this.template_info_data = sfobj.my_data['level'];
//alert(my_data['level']);
//location.href
template_info_data = "";
template_info_data += "";
template_info_data += "";
template_info_data += ""
template_info_data += "";
template_info_data += ""
template_info_data += "";
template_info_data += "";
template_info_data += ""
template_info_data += ""
template_info_data += ""
template_info_data += ""
template_info_data += ""
template_info_data += "
義氣仔女Online, 頁面:"+ page +"
功能:任務,存錢
修改自neo@orz.hk,by CX
等級:" + sfobj.my_data['level']+"
體力:" + sfobj.my_data['en']+"
剩下:" + sfobj.my_data['-exp']+"經驗值
生命:" + sfobj.my_data['hp']+"
現金:" + sfobj.now_money+"
執行任務:" + sfobj.renwu_selece_id+"
體力上線:" + sfobj.renwu_selece_reg+"
自動存款:" + sfobj.money+"
更新時間:" + sfobj.time+" (S)"+"
";

return this.template_info_data;
}
function template_sf_set(){
var template_set_data;
template_set_data = "
";
template_set_data += "";
template_set_data += "";
template_set_data += "";
template_set_data += "";
template_set_data += "";
template_set_data += "";
template_set_data += "";
template_set_data += "";
template_set_data += "";
template_set_data += "
義氣仔女Online______設定
任務:
體力:
自動存款:
更新時間:
啟動自動任務
啟動自動存款
";
return template_set_data;
}

function div_template(id){
var backgroundcolor = '#ffeeee';
this.htmlElement = document.createElement('div');
this.htmlElement.id = id;
this.htmlElement.style.top = '56px';//向上的高度
this.htmlElement.style.right = '2px';
this.htmlElement.style.position = 'absolute';
this.htmlElement.style.width = '160px';
this.htmlElement.style.height = '230px';
this.htmlElement.style.background = backgroundcolor;
this.htmlElement.style.font = '11px arial';
this.htmlElement.style.color = 'grey';
this.htmlElement.style.textAlign = 'center';
this.htmlElement.style.zIndex = 100;
this.run = function() { //obj is window
//alert(this.htmlElement.zIndex);
//window.parent.document.body.appendChild(this.htmlElement);
window.parent.document.body.appendChild(this.htmlElement);
};
};

function sf_obj(){
this.action = null;
this.action_link = null;
this.env = null;
this.renwu_selece_id = 5;//修改任務
this.renwu_selece_reg = 10;//修改體力
this.htmldata = "";
this.my_info = new Array(20);
this.my_data = new Array(20);
this.money = 1000;
this.ren_io = false;
this.money_io = false;
this.time = 30000;
this.get_my_info = function(htdata){

//this.str = new RegExp('現金:[^v]+').exec(document.getElementById('app17326627347_main').innerHTML);
this.str = new RegExp('現金:[^v]+').exec(htdata);

//this.my_info['cash'] = parseInt(sf_str.toString(10).split('$')[1].split('<')[0].replace(/,/g,""),10);
this.now_money = parseInt(this.str.toString(10).split('$')[1].split('<')[0].replace(/,/g,""),10);
//alert(this.now_money);
this.str = null;

this.my_info['level'] = htdata.match(/等級:<\/span>([0-9]{1,3})/);
this.my_info['exp'] = htdata.match(/EXP:<\/span>([0-9]{1,10})\/([0-9]{1,10})/);
this.my_info['hp'] = htdata.match(/生命:<\/span>([0-9]{0,10})\/([0-9]{1,3})/);
this.my_info['sta'] = htdata.match(/精神:<\/span>([0-9]{0,10})\/([0-9]{1,3})/);
this.my_info['en'] = htdata.match(/體力:<\/span>([0-9]{1,3})\/([0-9]{1,3})/);
//this.my_info['cash'] = htdata.match(/現金:<\/span>\$(.*?)<\/span>/);
this.my_info['cash'] = this.now_money;

this.my_info['level'][1] = parseInt(this.my_info['level'][1]);
this.my_info['hp'][1] = parseInt(this.my_info['hp'][1]);
this.my_data['level'] = this.my_info['level'][1];
this.my_data['exp'] = this.my_info['exp'][1];
this.my_data['-exp'] = this.my_info['exp'][2] - this.my_info['exp'][1];
this.my_data['hp'] = this.my_info['hp'][1];
this.my_data['hp_all'] = this.my_info['hp'][2];
this.my_data['sta'] = this.my_info['sta'][1];
this.my_data['en'] = this.my_info['en'][1];
this.my_data['cash'] = this.my_info['cash'][1];
//alert(this.my_data['cash']);
};
this.Renwu = function(id_exit){//0 is exit
if(page != "job"){return 0;}
//alert("p"+this.renwu_selece_reg);
//if(!this.renwu_selece_reg){return this.renwu_selece_reg;}
//alert("p"+this.my_data['en']);
if(this.my_data['en'] >= this.renwu_selece_reg && this.my_data['en'] != null){
this.action = document.getElementById('app17326627347_mod_action-' + this.renwu_selece_id);
if(this.action.getElementsByTagName('a')[0] == null){location.href = job;}
this.action_link = this.action.getElementsByTagName('a')[0];
this.evt = document.createEvent("MouseEvents");
this.evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
this.action_link.dispatchEvent(this.evt);
}
}
this.save_money = function(id_exit){//0 is exit
if(page != "bank"){return 0;}
if (document.getElementsByName("amount").length > 1) {
document.getElementsByName("deposit")[0].click();
//alert("m");
return;
}
}
};

function post(url, data, cb) {
GM_xmlhttpRequest({
method: "POST",
url: url,
headers:{'Content-type':'application/x-www-form-urlencoded'},
data:encodeURI(data),
onload: function(xhr) { cb(xhr.responseText); }
});
}
/*ex
post('http://www.flash-mx.com/mm/viewscope.cfm', 'userid=joe&password=guessme', function(text) {
alert('HTML of the page:' + text)
})
*/
var last_check = new Date();
var sfobj = new sf_obj();
var div1 = new div_template("window1");
div1.run();

//sfobj.save_money();

function cx_run(){
GM_xmlhttpRequest({
method: 'GET',
url: 'http://apps.facebook.com/street-fights/job.php',
headers: {
'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
'Accept': 'application/atom+xml,application/xml,text/xml',
},
onload: function(responseDetails) {
var html_data = responseDetails.responseText;
sfobj.get_my_info(html_data);//1
//alert(sfobj.my_info['level']);
//alert(sfobj.my_data['level']);
//get_my_info(html_data);
//Renwu();
var tmp1 = sfobj.now_money;
var tmp2 = sfobj.money;
//alert(tmp1+" : "+tmp2);
//alert(tmp1 > tmp2);
if(sfobj.now_money > sfobj.money){
if(page != "bank"){
location.href = bank;
//alert("t0");
}
sfobj.save_money();
//alert("t1");
}else if(sfobj.now_money != null){
//alert("t3");
if(page != "job"){location.href = job;}
sfobj.Renwu();
}
/*
var now_date =new Date();
last_check = now_date;
now_date = null;
*/
//window.setTimeout(function() { cx_run(); }, 30000);
}
});
}

function main_fun(){
var current = new Date();
var seconds = (current - last_check) / 1000;
sfobj.time = parseInt(30-seconds);
if(sfobj.time <= 0){
last_check = current;
window.setTimeout(function() { cx_run(); }, 500);
}

div1.htmlElement.innerHTML = template_sf_info();
window.setTimeout(function() { main_fun(); }, 1000);
}

div1.htmlElement.innerHTML = '
Initializing . . .' ;
//*****htmlElement.innerHTML = '
Initializing . . .' ;
window.setTimeout(function() { cx_run(); }, 500);
window.setTimeout(function() { main_fun(); }, 1000);