




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、線性預測與Levinson-Dubin算法實現,移動端實現右側字母A-Z的滑動觸摸選擇 映射遠程端口到本地 Shell/批處理用shell將svn的提交信息生成運維使用的更新文檔 Shell/批處理用SQL語句斷開某個數據庫的所有活動連接 SQL,用udp的方式傳輸文字 ,用于填寫支付密碼的textfield int query() /掃描 int index, len, result; node *p = root; /Trie入口 result = 0; len = strlen(str); for(int i = 0; i < len; +i) index = stri -
2、9;a' while(p->nextindex = NULL && p != root) /跳轉失敗指針 p = p->fail; p = p->nextindex; if(p = NULL) p = root; node *temp = p; /p不動,temp計算后綴串 while(temp != root && temp->count != -1) result += temp->count; temp->count = -1; temp = temp->fail; return result;/ 使用Qt
3、仿寫系統記事本/圖片輪播器,定時器使用GCD /網頁版的簡易跳舞機 int main() int num; while(1) head= tail = 0; scanf("%d", &num); if (num = 0) break; root = new node(); getchar(); for(int i = 0; i < num; +i) gets(keyword); insert(keyword); build_ac(); scanf("%s", str); printf("%dn", query(); re
4、turn 0;/ 下拉菜單鼠標鍵盤事件 /元素據指定html適配移動設備 /原生js當前時間以及倒計時package mainimport ( "io/ioutil" "net/http" "net/" "fmt" "encoding/json") /-/ 黃金數據調用示例代碼 聚合數據/ 在線接口文檔:www/docs/29/- const APPKEY = "*" /您申請的APPKEY func main() /1.上海黃金交易所 Request1() /2.上海期貨交
5、易所 Request2() /3.銀行賬戶黃金 Request3() /1.上海黃金交易所func Request1() /請求地址 juhe :="web:8080/finance/gold/shgold" /初始化參數 param:=.Values /配置請求參數,方法內部已處理encode問題,中文參數可以直接傳參 param.Set("key",APPKEY) /APP Key param.Set("v","") /JSON格式版本(0或1)默認為0 /發(fā)送請求 data,err:=Get(juhe,par
6、am) if err!=nil fmt.Errorf("請求失敗,錯誤信息:rn%v",err) else var netReturn mapstringinterface json.Unmarshal(data,&netReturn) if netReturn"error_code".(float64)=0 fmt.Printf("接口返回result字段是:rn%v",netReturn"result") /2.上海期貨交易所func Request2() /請求地址 juhe :="web:
7、8080/finance/gold/shfuture" /初始化參數 param:=.Values /配置請求參數,方法內部已處理encode問題,中文參數可以直接傳參 param.Set("key",APPKEY) /APP Key param.Set("v","") /JSON格式版本(0或1)默認為0 /發(fā)送請求 data,err:=Get(juhe,param) if err!=nil fmt.Errorf("請求失敗,錯誤信息:rn%v",err) else var netReturn maps
8、tringinterface json.Unmarshal(data,&netReturn) if netReturn"error_code".(float64)=0 fmt.Printf("接口返回result字段是:rn%v",netReturn"result") /3.銀行賬戶黃金func Request3() /請求地址 juhe :="web:8080/finance/gold/bankgold" /初始化參數 param:=.Values /配置請求參數,方法內部已處理encode問題,中文參數
9、可以直接傳參 param.Set("key",APPKEY) /APP Key /發(fā)送請求 data,err:=Get(juhe,param) if err!=nil fmt.Errorf("請求失敗,錯誤信息:rn%v",err) else var netReturn mapstringinterface json.Unmarshal(data,&netReturn) if netReturn"error_code".(float64)=0 fmt.Printf("接口返回result字段是:rn%v",
10、netReturn"result") / get 網絡請求func Get(api string,params .Values)(rsbyte ,err error) var *. ,err=.Parse(api) if err!=nil fmt.Printf("解析錯誤:rn%v",err) return nil,err /如果參數中有中文參數,這個方法會進行Encode .RawQuery=params.Encode() resp,err:=http.Get(.String() if err!=nil fmt.Println("err:&q
11、uot;,err) return nil,err defer resp.Body.Close() return ioutil.ReadAll(resp.Body) / post 網絡請求 ,params 是.Values類型func Post(api string, params .Values)(rsbyte,err error) resp,err:=http.PostForm(api, params) if err!=nil return nil ,err defer resp.Body.Close() return ioutil.ReadAll(resp.Body)代碼描述:基于GO的黃
12、金數據接口調用代碼實例關聯數據:黃金數據代碼 C#代碼 using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Net;using System.IO;using Xfrog.Net;using System.Diagnostics;using System.Web; /-/ 黃金數據調用示例代碼 聚合數據/ 在線接口文檔:www/docs/29/ 代碼中JsonObject類下載地址:/download/gcm3206021155665/7458439/- n
13、amespace ConsoleAPI class Program static void Main(string args) string appkey = "*" /配置您申請的appkey /1.上海黃金交易所 string 1 = "web:8080/finance/gold/shgold" var parameters1 = new Dictionary<string, string>(); parameters1.Add("key", appkey);/你申請的key parameters1.Add("
14、;v" , ""); /JSON格式版本(0或1)默認為0 string result1 = sendPost(1, parameters1, "get"); JsonObject newObj1 = new JsonObject(result1); String errorCode1 = newObj1"error_code".Value; if (errorCode1 = "0") Debug.WriteLine("成功"); Debug.WriteLine(newObj1); e
15、lse /Debug.WriteLine("失敗"); Debug.WriteLine(newObj1"error_code".Value+":"+newObj1"reason".Value); /2.上海期貨交易所 string 2 = "web:8080/finance/gold/shfuture" var parameters2 = new Dictionary<string, string>(); parameters2.Add("key", appkey
16、);/你申請的key parameters2.Add("v" , ""); /JSON格式版本(0或1)默認為0 string result2 = sendPost(2, parameters2, "get"); JsonObject newObj2 = new JsonObject(result2); String errorCode2 = newObj2"error_code".Value; if (errorCode2 = "0") Debug.WriteLine("成功&quo
17、t;); Debug.WriteLine(newObj2); else /Debug.WriteLine("失敗"); Debug.WriteLine(newObj2"error_code".Value+":"+newObj2"reason".Value); /3.銀行賬戶黃金 string 3 = "web:8080/finance/gold/bankgold" var parameters3 = new Dictionary<string, string>(); paramete
18、rs3.Add("key", appkey);/你申請的key string result3 = sendPost(3, parameters3, "get"); JsonObject newObj3 = new JsonObject(result3); String errorCode3 = newObj3"error_code".Value; if (errorCode3 = "0") Debug.WriteLine("成功"); Debug.WriteLine(newObj3); else
19、 /Debug.WriteLine("失敗"); Debug.WriteLine(newObj3"error_code".Value+":"+newObj3"reason".Value); / <summary> / Http (GET/POST) / </summary> / <param name="">請求</param> / <param name="parameters">請求參數</param>
20、; / <param name="method">請求方法</param> / <returns>響應內容</returns> static string sendPost(string , IDictionary<string, string> parameters, string method) if (method.ToLower() = "post") HttpWebRequest req = null; HttpWebResponse rsp = null; System.IO.Str
21、eam reqStream = null; try req = (HttpWebRequest)WebRequest.Create(); req.Method = method; req.KeepAlive = false; req.ProtocolVersion = HttpVersion.Version10; req.Timeout = 5000; req.ContentType = "application/x-www-form-encoded;charset=utf-8" byte postData = Encoding.UTF8.GetBytes(BuildQue
22、ry(parameters, "utf8"); reqStream = req.GetRequestStream(); reqStream.Write(postData, 0, postData.Length); rsp = (HttpWebResponse)req.GetResponse(); Encoding encoding = Encoding.GetEncoding(rsp.CharacterSet); return GetResponseAsString(rsp, encoding); catch (Exception ex) return ex.Message
23、; finally if (reqStream != null) reqStream.Close(); if (rsp != null) rsp.Close(); else /創(chuàng)建請求 HttpWebRequest request = (HttpWebRequest)WebRequest.Create( + "?" + BuildQuery(parameters, "utf8"); /GET請求 request.Method = "GET" request.ReadWriteTimeout = 5000; request.Conten
24、tType = "text/html;charset=UTF-8" HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream myResponseStream = response.GetResponseStream(); StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"); /返回內容 string retString = my
25、StreamReader.ReadToEnd(); return retString; / <summary> / 組裝普通文本請求參數。 / </summary> / <param name="parameters">Key-Value形式請求參數字典</param> / <returns>編碼后的請求數據</returns> static string BuildQuery(IDictionary<string, string> parameters, string encode) St
26、ringBuilder postData = new StringBuilder(); bool hasParam = false; IEnumerator<KeyValuePair<string, string>> dem = parameters.GetEnumerator(); while (dem.MoveNext() string name = dem.Current.Key; string value = dem.Current.Value; / 忽略參數名或參數值為空的參數 if (!string.IsNullOrEmpty(name)/&&
27、; !string.IsNullOrEmpty(value) if (hasParam) postData.Append("&"); postData.Append(name); postData.Append("="); if (encode = "gb2312") postData.Append(HttpUtility.Encode(value, Encoding.GetEncoding("gb2312"); else if (encode = "utf8") postData.Ap
28、pend(HttpUtility.Encode(value, Encoding.UTF8); else postData.Append(value); hasParam = true; return postData.ToString(); / <summary> / 把響應流轉換為文本。 / </summary> / <param name="rsp">響應流對象</param> / <param name="encoding">編碼方式</param> / <returns
29、>響應文本</returns> static string GetResponseAsString(HttpWebResponse rsp, Encoding encoding) System.IO.Stream stream = null; StreamReader reader = null; try / 以字符流的方式讀取HTTP響應 stream = rsp.GetResponseStream(); reader = new StreamReader(stream, encoding); return reader.ReadToEnd(); finally / 釋放資
30、源 if (reader != null) reader.Close(); if (stream != null) stream.Close(); if (rsp != null) rsp.Close(); 代碼 PHP代碼 /* * c遠程傳輸工具 */public function post_c($,$body,$header,$type='POST') $ch = c_init(); c_setopt($ch,COPT_,$); c_setopt($ch,COPT_HEADER,0);/0只要正文 c_setopt($ch,COPT_TIMEOUT,5);/設置超時時間
31、c_setopt($ch,COPT_CONNECTTIMEOUT,5); /將c_exec()獲取的信息以文件流的形式返回,而不是直接輸出。 c_setopt($ch,COPT_RETURNTRANSFER,1); /增加header頭信息 / array_push($header,'Accept:application/json'); / array_push($header,'Content-Type:application/json'); / array_push($header,'http:multipart/form-data'); i
32、f(count($body)>0) c_setopt($ch,COPT_POSTFIELDS,$body); if(count($header)>0) c_setopt($ch,COPT_HTTPHEADER,$header); /設置上傳文件相關 c_setopt($ch,COPT_FOLLOWLOCATION,true); c_setopt($ch,COPT_MAXREDIRS,3);/遞歸 c_setopt($ch,COPT_SSL_VERIFYPEER,false);/ 對認證證書來源的檢查 c_setopt($ch,COPT_SSL_VERIFYHOST,0);/ 從證書
33、中檢查SSL加密算法 switch ($type) case 'GET': c_setopt($ch,COPT_HTTPGET,1); break; case 'POST': c_setopt($ch,COPT_POST,1); break; case 'PUT': c_setopt($ch,COPT_CUSTOMREQUEST,'PUT'); break; case 'DELETE': c_setopt($ch,COPT_CUSTOMREQUEST,'DELETE'); break; /上傳文件相
34、關設置 c_setopt($ch,COPT_ENCODING,'gzip'); c_setopt($ch,COPT_USERAGENT,'SSTS Browser/1.0'); c_setopt($ch,COPT_USERAGENT,'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)');/ 模擬用戶使用的瀏覽器 if(c_errno($ch) return c_error($ch); $content = c_exec($ch); c_close($ch);/關閉c資
35、源,并且釋放系統資源 $result = json_decode($content,true); if(!empty($result) return $result; else return $content; 代碼 C/C+代碼 /*編譯指令$ /opt/sybase/OCS-16_0/bin/cpre64 -m teststu.cp$ cc -m64 -g -DSYB_LP64 -I. -I/opt/sybase/OCS-16_0/include teststu.c /opt/sybase/OCS-16_0/include/sybesql.c -L/opt/sybase/OCS-16_0/
36、lib -lsybct64 -lsybtcl64 -lsybcs64 -lsybcomn64 -lsybintl64 -lsybunic64 -rdynamic -ldl -lnsl -lm -o teststu */#include <stdio.h> /*建立通訊區(qū)域*/EXEC SQL INCLUDE SQLCA; /* * These tokens must be declared in a declare section* because they are used in declare sections below.*/EXEC SQL BEGIN DECLARE SE
37、CTION;#define TYPESIZE 13#define TIDSIZE 6EXEC SQL END DECLARE SECTION; #define EOLN '0'/* * Forward declarations of the error and message handlers and* other subroutines called from main().*/void error_handler();void warning_handler(); intmain(int argc, char *argv)/*聲明宿主變量*/ EXEC SQL BEGIN
38、DECLARE SECTION; /* storage for login name and password. */ char username30; char sname30; char password30; char server30; EXEC SQL END DECLARE SECTION;/*錯誤處理*/ EXEC SQL WHENEVER SQLERROR CALL error_handler(); EXEC SQL WHENEVER SQLWARNING CALL warning_handler(); EXEC SQL WHENEVER NOT FOUND CONTINUE;
39、/*連接到 SQL SERVER 服務器*/ /* * Copy the user name and password defined in sybsqlex.h to * the variables declared for them in the declare section. */ strcpy(username, "mymotif"); strcpy(password, "wxwpxh"); strcpy(server, "MYMOTIFVOSTRO145480"); EXEC SQL CONNECT :username I
40、DENTIFIED BY :password using :server; EXEC SQL USE testdb; EXEC SQL DECLARE c1 CURSOR FOR SELECT SNAME FROM STUDENT; EXEC SQL OPEN c1; printf("name in table studentn"); do EXEC SQL FETCH c1 INTO :sname; if (sqlca.sqlcode != 0) break; printf( "student name = %sn", sname ); while (
41、 1 ); EXEC SQL CLOSE c1; return(0); /*錯誤處理程序*/* void error_handler()* * Displays error codes and numbers from the SQLCA and exits with* an ERREXIT status. */voiderror_handler(void) fprintf(stderr, "n* SQLCODE=(%ld)", sqlca.sqlcode); if (sqlca.sqlerrm.sqlerrml) fprintf(stderr, "n* ASE
42、Error "); fprintf(stderr, "n* %s", sqlca.sqlerrm.sqlerrmc); fprintf(stderr, "nn"); exit(-1); /* void warning_handler()* * Displays warning messages.*/voidwarning_handler(void) if (sqlca.sqlwarn1 = 'W') fprintf(stderr, "n* Data truncated.n"); if (sqlca.sqlwa
43、rn3 = 'W') fprintf(stderr, "n* Insufficient host variables to store results.n"); return;代碼 Log4j配置 <!- 日志jar -> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </dependency>導入這個包,會引入下面兩個jar<!-spring 的基本ja
44、r包 -> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> </dependency> <!- commons-login是必須的,而且沒有依賴,是獨立的包 -> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-loggi
45、ng-api</artifactId> <version>1.1</version> </dependency><dependency><!- transactionManager實務管理的時候,需要這個jar包 -> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId></dependency><dependency> <!-當spring-config.xml文件中配置<aop:aspect >需要加入此包 -> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId></dependency><dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId></dependency&g
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 混凝土道路維修施工方案
- 湖北水幕噴泉施工方案
- 《 龍川別志(節(jié)選) 》
- 重慶公園綠化工程施工方案
- 屋面門窗修理施工方案
- 實驗室通風櫥裝修施工方案
- 2025年紙品用膠合作協議書
- 玻璃幕墻更換施工方案
- 2025年手持云臺項目建議書
- 醫(yī)療機構水污染物排放的公眾參與與社會監(jiān)督
- DB50T 441-2012 渝菜 毛血旺烹飪技術規(guī)范
- 2024年05月富德生命人壽保險股份有限公司招考筆試歷年參考題庫附帶答案詳解
- 醫(yī)防融合培訓
- 高速鐵路設計規(guī)范
- 《電機能能效等級》課件
- 幼兒園課件之大班科學《四季的變化》
- 電商客服外包服務合同
- 影視拍攝現場突發(fā)安全事件應急預案
- DB37T 5096-2017 建設工程項目管理咨詢規(guī)范
- 雙方同意小孩改姓名協議書(2篇)
- 2023年私募股權投資基金基礎知識真題模擬匯編(共824題)
評論
0/150
提交評論