模仿csdn的代码,己整理的Linux常用命令

更新时间:2024-01-28 07:52:01 阅读量: 教育文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

爬取百度贴吧的网页,由CM安卓6卡刷包精简生成自己的卡刷包 [Shell/批处理],写的tcp聊天室,模仿csdn的代码,己整理的Linux常用命令(非常适用于快速入门/快速温习 [其他]自适应屏幕大小。兼容各个浏览器包括ie6 最简单的python命令解析器 vector c = findmaxsubarray(a); vector d = findmaxsubarray(b);

printf(\ for (int i = 0; i < c.size(); i++) printf(\

printf(\

printf(\ for (int i = 0; i < d.size(); i++) printf(\}

[文件] Angle.cpp ~ 5KB #include \

#include \#include \

// java多用户商城系统

//Java连接PostgreSQL数据库 //Java连接PostgreSQL数据库 //java爬虫gecco的demo CAngle::CAngle() {

angle = 0;

m_hitPen.setColor(Qt::red); m_hitPen.setWidth(5);

ang_info_pen.setColor(Qt::blue);

m_shapeType = CDrawWin::SHAPE_ANGLE; qDebug() << __func__ <<\ }

// JavaScript正则校验工具库 //javascript中的闭包 //JavaScript做的日历

void CAngle::drawShape(QPainter &pt) {

int i = 0;

QPainterPath path;

qDebug() << __func__ <<\ for(i = 0;i < m_ptArray.size();i++) {

QPoint ltPt_0(m_ptArray[i].x()-2,m_ptArray[i].y()-2); QPoint rbPt_0(m_ptArray[i].x()+2,m_ptArray[i].y()+2); QRect rec_0(ltPt_0,rbPt_0); m_hitPen.setColor(Qt::red); pt.setPen(m_hitPen); pt.drawRect(rec_0); if(i == 1) {

QPoint ltPt_0(m_ptArray[i].x()-2,m_ptArray[i].y()-2); QPoint rbPt_0(m_ptArray[i].x()+2,m_ptArray[i].y()+2); QRect rec_0(ltPt_0,rbPt_0); m_hitPen.setColor(Qt::green); pt.setPen(m_hitPen); pt.drawRect(rec_0); }

}

pt.setPen(angle_pen);

path.moveTo(m_ptArray[0]); path.lineTo(m_ptArray[1]); path.lineTo(m_ptArray[2]);

qDebug() << __func__ <<\ pt.drawPath(path); }

//JavaScript控制选项卡切换 //java实现多客户端聊天室 [代码] [Google Go]代码 package main import ( \\\\

\)

const APPKEY = \您申请的APPKEY

func main(){

//1.上海黄金交易所 Request1()

//2.上海期货交易所 Request2()

//3.银行账户黄金 Request3() }

//1.上海黄金交易所 func Request1(){ //请求地址

juhe :=\

//初始化参数 param:=.Values{}

//配置请求参数,方法内部已处理encode问题,中文参数可以直接传参 param.Set(\

param.Set(\格式版本(0或1)默认为0

//发送请求

data,err:=Get(juhe,param) if err!=nil{

fmt.Errorf(\请求失败,错误信息:\\r\\n%v\ }else{

var netReturn map[string]interface{} json.Unmarshal(data,&netReturn)

if netReturn[\

fmt.Printf(\接口返回result字段是:\\r\\n%v\ } } }

//2.上海期货交易所 func Request2(){ //请求地址

juhe :=\

//初始化参数 param:=.Values{}

//配置请求参数,方法内部已处理encode问题,中文参数可以直接传参 param.Set(\

param.Set(\格式版本(0或1)默认为0

//发送请求

data,err:=Get(juhe,param) if err!=nil{

fmt.Errorf(\请求失败,错误信息:\\r\\n%v\ }else{

var netReturn map[string]interface{} json.Unmarshal(data,&netReturn)

if netReturn[\

fmt.Printf(\接口返回result字段是:\\r\\n%v\ } } }

//3.银行账户黄金 func Request3(){ //请求地址

juhe :=\

//初始化参数 param:=.Values{}

//配置请求参数,方法内部已处理encode问题,中文参数可以直接传参 param.Set(\

//发送请求

data,err:=Get(juhe,param) if err!=nil{

fmt.Errorf(\请求失败,错误信息:\\r\\n%v\ }else{

var netReturn map[string]interface{} json.Unmarshal(data,&netReturn)

if netReturn[\

fmt.Printf(\接口返回result字段是:\\r\\n%v\ } } }

// get 网络请求

func Get(api string,params .Values)(rs[]byte ,err error){ var *.

,err=.Parse(api) if err!=nil{

fmt.Printf(\解析错误:\\r\\n%v\

return nil,err }

//如果参数中有中文参数,这个方法会进行Encode .RawQuery=params.Encode() resp,err:=http.Get(.String()) if err!=nil{

fmt.Println(\ return nil,err }

defer resp.Body.Close()

return ioutil.ReadAll(resp.Body) }

// post 网络请求 ,params 是.Values类型

func Post(api string, params .Values)(rs[]byte,err error){ resp,err:=http.PostForm(api, params) if err!=nil{

return nil ,err }

defer resp.Body.Close()

return ioutil.ReadAll(resp.Body) }

代码描述:基于GO的黄金数据接口调用代码实例 关联数据:黄金数据 [代码] [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 //----------------------------------

namespace ConsoleAPI {

class Program

{

static void Main(string[] args) {

string appkey = \配置您申请的appkey

//1.上海黄金交易所

string 1 = \

var parameters1 = new Dictionary();

parameters1.Add(\你申请的key

parameters1.Add(\格式版本(0或1)默认为0

string result1 = sendPost(1, parameters1, \

JsonObject newObj1 = new JsonObject(result1); String errorCode1 = newObj1[\

if (errorCode1 == \ {

Debug.WriteLine(\成功\ Debug.WriteLine(newObj1); } else {

//Debug.WriteLine(\失败\

Debug.WriteLine(newObj1[\ }

//2.上海期货交易所

string 2 = \

var parameters2 = new Dictionary();

parameters2.Add(\你申请的key

parameters2.Add(\格式版本(0或1)默认为0

string result2 = sendPost(2, parameters2, \

JsonObject newObj2 = new JsonObject(result2); String errorCode2 = newObj2[\

if (errorCode2 == \ {

Debug.WriteLine(\成功\ Debug.WriteLine(newObj2); } else {

//Debug.WriteLine(\失败\

Debug.WriteLine(newObj2[\ }

//3.银行账户黄金

string 3 = \

var parameters3 = new Dictionary();

parameters3.Add(\你申请的key

string result3 = sendPost(3, parameters3, \

JsonObject newObj3 = new JsonObject(result3); String errorCode3 = newObj3[\

if (errorCode3 == \ {

Debug.WriteLine(\成功\ Debug.WriteLine(newObj3); } else {

//Debug.WriteLine(\失败\

Debug.WriteLine(newObj3[\ }

}

///

/// Http (GET/POST) ///

///

/// /// /// 响应内容

static string sendPost(string , IDictionary parameters, string method) {

if (method.ToLower() == \ {

HttpWebRequest req = null; HttpWebResponse rsp = null;

System.IO.Stream reqStream = null; try {

req = (HttpWebRequest)WebRequest.Create(); req.Method = method; req.KeepAlive = false;

req.ProtocolVersion = HttpVersion.Version10; req.Timeout = 5000; req.ContentType =

\ byte[] postData =

Encoding.UTF8.GetBytes(BuildQuery(parameters, \ 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; }

finally {

if (reqStream != null) reqStream.Close(); if (rsp != null) rsp.Close(); } } else {

//创建请求

HttpWebRequest request = (HttpWebRequest)WebRequest.Create( + \+ BuildQuery(parameters, \

//GET请求

request.Method = \

request.ReadWriteTimeout = 5000;

request.ContentType = \ HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Stream myResponseStream = response.GetResponseStream();

StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding(\

//返回内容

string retString = myStreamReader.ReadToEnd(); return retString; } }

///

/// 组装普通文本请求参数。 ///

/// /// 编码后的请求数据

static string BuildQuery(IDictionary parameters, string encode) {

StringBuilder postData = new StringBuilder(); bool hasParam = false;

IEnumerator> dem = parameters.GetEnumerator();

while (dem.MoveNext()) {

string name = dem.Current.Key; string value = dem.Current.Value; // 忽略参数名或参数值为空的参数 if

(!string.IsNullOrEmpty(name))//&& !string.IsNullOrEmpty(value) {

if (hasParam) {

postData.Append(\ }

postData.Append(name); postData.Append(\ if (encode == \

{

postData.Append(HttpUtility.Encode(value, Encoding.GetEncoding(\ }

else if (encode == \ {

postData.Append(HttpUtility.Encode(value, Encoding.UTF8));

} else {

postData.Append(value); }

hasParam = true; } }

return postData.ToString(); }

///

/// 把响应流转换为文本。 ///

/// /// /// 响应文本 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 {

// 释放资源

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);//设置超时时间 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'); if(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);// 从证书中检查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; }

//上传文件相关设置

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资源,并且释放系统资源 $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/lib -lsybct64 -lsybtcl64 -lsybcs64 -lsybcomn64 -lsybintl64 -lsybunic64 -rdynamic -ldl -lnsl -lm -o teststu */

#include

www.jat.cn 小型臭氧发生器 侳侱侲 /*建立通讯区域*/

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 SECTION; #define TYPESIZE 13 #define TIDSIZE 6

EXEC 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(); int

main(int argc, char *argv[]) {

/*声明宿主变量*/

EXEC SQL BEGIN DECLARE SECTION;

/* storage for login name and password. */ char username[30]; char sname[30]; char password[30]; char server[30];

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; /*连接到 SQL SERVER 服务器*/

/*

** Copy the user name and password defined in sybsqlex.h to ** the variables declared for them in the declare section. */

strcpy(username, \ strcpy(password, \

strcpy(server, \

EXEC SQL CONNECT :username IDENTIFIED BY :password using :server;

EXEC SQL USE testdb;

EXEC SQL DECLARE c1 CURSOR FOR SELECT SNAME FROM STUDENT; EXEC SQL OPEN c1;

printf(\ do {

EXEC SQL FETCH c1 INTO :sname; if (sqlca.sqlcode != 0) break;

printf( \ } while ( 1 ); EXEC SQL CLOSE c1;

return(0); }

/*错误处理程序*/ /*

** void error_handler() **

** Displays error codes and numbers from the SQLCA and exits with ** an ERREXIT status. */ void

error_handler(void) {

fprintf(stderr, \

if (sqlca.sqlerrm.sqlerrml) {

fprintf(stderr, \

fprintf(stderr, \ }

fprintf(stderr, \

exit(-1); } /*

** void warning_handler() **

** Displays warning messages. */ void

warning_handler(void) {

if (sqlca.sqlwarn[1] == 'W') {

fprintf(stderr, \ }

if (sqlca.sqlwarn[3] == 'W') {

fprintf(stderr,

\ } return;

}

[代码] Log4j配置

org.slf4j

slf4j-log4j12

导入这个包,会引入下面两个jar

org.springframework

spring-context-support

commons-logging

commons-logging-api 1.1

org.springframework spring-orm

org.aspectj

aspectjweaver

org.springframework spring-webmvc

[文件] 无缝滚动.html ~ 1KB

[代码] 获取的参数 //获取的参数

function getParam(paramKey){ //获取当前

var = location.href; //获取要取得的get参数位置

var get = .indexOf(paramKey +https://www.bwwdw.com/plus/\ if(get == -1){

return false; }

//截取字符串

var getParamStr = .slice(paramKey.length + get + 1); //判断截取后的字符串是否还有其他get参数 var nextparam = getParamStr.indexOf(https://www.bwwdw.com/plus/\ if(nextparam != -1){

getParamStr = getParamStr.slice(0, nextparam); }

return decodeURIComponent(getParamStr); }

[代码] 添加参数 //添加参数

function addParam(,paramKey,paramVal){ var andStr = https://www.bwwdw.com/plus/\

var beforeparam = .indexOf(https://www.bwwdw.com/plus/\ if(beforeparam != -1){ andStr = https://www.bwwdw.com/plus/\ }

return + andStr + paramKey + https://www.bwwdw.com/plus/\}

[代码] 删除参数 //删除参数

function delParam(,paramKey){

var Param = .substr(.indexOf(https://www.bwwdw.com/plus/\ var before = .substr(0,.indexOf(https://www.bwwdw.com/plus/\ var next = https://www.bwwdw.com/plus/\

var arr = new Array(); if(Param!=https://www.bwwdw.com/plus/\

var ParamArr = Param.split(https://www.bwwdw.com/plus/\

for(var i=0;i

var paramArr = ParamArr[i].split(https://www.bwwdw.com/plus/\ if(paramArr[0]!=paramKey){ arr.push(ParamArr[i]); } } }

if(arr.length>0){

next = https://www.bwwdw.com/plus/\ }

= before+next; return ; }

[代码] [C#]代码

#region 防止sql注入式攻击(可用于UI层控制) ///

/// 判断字符串中是否有SQL攻击代码 ///

/// 传入用户提交数据

/// true-安全;false-有注入攻击现有;

public bool ProcessSqlStr(string inputString) {

string SqlStr =

@https://www.bwwdw.com/plus/\r|char|asc|mid|substring|master|truncate|declare|xp_cmdshell|restore|backup|net +user|net +localgroup +administratorshttps://www.bwwdw.com/plus/\ try {

if ((inputString != null) && (inputString != String.Empty)) {

string str_Regex = @https://www.bwwdw.com/plus/\

Regex Regex = new Regex(str_Regex, RegexOptions.IgnoreCase); //string s = Regex.Match(inputString).Value; if (true == Regex.IsMatch(inputString)) return false;

} } catch {

return false; }

return true; } ///

/// 处理用户提交的请求,校验sql注入式攻击,在页面装置时候运行 ///

System.Configuration.ConfigurationSettings.AppSettings[https://www.bwwdw.com/plus/\为用户自定义错误页面提示地址,

/// 在Web.Config文件时里面添加一个 ErrorPage 即可 /// /// ///

public void ProcessRequest() {

try {

string getkeys = https://www.bwwdw.com/plus/\ string sqlErrorPage =

System.Configuration.ConfigurationSettings.AppSettings[https://www.bwwdw.com/plus/\ if (System.Web.HttpContext.Current.Request.QueryString != null) {

for (int i = 0; i <

System.Web.HttpContext.Current.Request.QueryString.Count; i++) {

getkeys =

System.Web.HttpContext.Current.Request.QueryString.Keys[i]; if

(!ProcessSqlStr(System.Web.HttpContext.Current.Request.QueryString[getkeys])) {

System.Web.HttpContext.Current.Response.Redirect(sqlErrorPage + https://www.bwwdw.com/plus/\getkeys + https://www.bwwdw.com/plus/\有SQL攻击嫌疑!https://www.bwwdw.com/plus/\

System.Web.HttpContext.Current.Response.End(); } } }

if (System.Web.HttpContext.Current.Request.Form != null) {

for (int i = 0; i < System.Web.HttpContext.Current.Request.Form.Count; i++)

{

getkeys = System.Web.HttpContext.Current.Request.Form.Keys[i];

if

(!ProcessSqlStr(System.Web.HttpContext.Current.Request.Form[getkeys])) {

System.Web.HttpContext.Current.Response.Redirect(sqlErrorPage + https://www.bwwdw.com/plus/\getkeys + https://www.bwwdw.com/plus/\有SQL攻击嫌疑!https://www.bwwdw.com/plus/\

System.Web.HttpContext.Current.Response.End(); } } } } catch {

// 错误处理: 处理用户提交信息! } }

#endregion

#region 转换sql代码(也防止sql注入式攻击,可以用于业务逻辑层,但要求UI层输入数据时候进行解码) ///

/// 提取字符固定长度 /// /// /// ///

public string CheckStringLength(string inputString, Int32 maxLength) {

if ((inputString != null) && (inputString != String.Empty)) {

inputString = inputString.Trim();

if (inputString.Length > maxLength)

inputString = inputString.Substring(0, maxLength); }

return inputString; } ///

/// 将输入字符串中的sql敏感字,替换成https://www.bwwdw.com/plus/\敏感字]https://www.bwwdw.com/plus/\,要求输出时,替换回来 /// ///

/// qhd001.com

public string MyEncodeInputString(string inputString) {

//要替换的敏感字 string SqlStr =

@\r|char|asc|mid|substring|master|truncate|declare|xp_cmdshell|restore|backup|net +user|net +localgroup +administrators\ try {

if ((inputString != null) && (inputString != String.Empty)) {

string str_Regex = @\

Regex Regex = new Regex(str_Regex, RegexOptions.IgnoreCase); //string s = Regex.Match(inputString).Value;

MatchCollection matches = Regex.Matches(inputString); for (int i = 0; i < matches.Count; i++)

inputString = inputString.Replace(matches[i].Value, \matches[i].Value + \

} } catch {

return \ }

return inputString; } ///

/// 将已经替换成的\敏感字]\,转换回来为\敏感字\/// /// ///

public string MyDecodeOutputString(string outputstring) {

//要替换的敏感字 string SqlStr =

@\r|char|asc|mid|substring|master|truncate|declare|xp_cmdshell|restore|backup|net +user|net +localgroup +administrators\ try {

if ((outputstring != null) && (outputstring != String.Empty)) {

string str_Regex = @\

Regex Regex = new Regex(str_Regex, RegexOptions.IgnoreCase); MatchCollection matches = Regex.Matches(outputstring); for (int i = 0; i < matches.Count; i++)

outputstring = outputstring.Replace(matches[i].Value, matches[i].Value.Substring(1, matches[i].Value.Length - 2));

} } catch {

return \ }

return outputstring; }

#endregion

void CAngle::drawInfo(QPainter &Pt) {

QPoint midPt = ((m_ptArray[1] + m_ptArray[2]))/2; QString str_angle;

QString str_1 = \ QString str_2 = \ QFont myFont;

QFontMetrics fm(myFont);

qDebug() << __func__ <<\ int width = 0; int width1 = 0; int heigh = 0;

double x1 = m_ptArray[0].x()-m_ptArrayx(); double y1 = m_ptArray[0].y()-m_ptArrayy(); double x2 = m_ptArrayx()-m_ptArrayx(); double y2 = m_ptArrayy()-m_ptArrayy(); double x = x1*x2 + y1*y2; double y = x1*y2 - x2*y1;

angle = 180 / (M_PI /acos(x / (sqrt(pow(x,2) + pow(y,2)))));

str_angle.setNum(angle); width = fm.width(str_angle); width1 = fm.width(str_2); heigh = fm.height() * 3;

QRect rectinfo(midPt.x(),midPt.y(),width + width1,heigh); Pt.setPen(ang_info_pen);

Pt.drawRoundedRect(rectinfo,5,5);

Pt.drawText(rectinfo,Qt::AlignCenter,QString(\\ }

void CAngle::mousePressEvent(QMouseEvent *event) {

switch(countClick){ case 0: {

m_ptArray.push_back(event->pos()); m_ptArray.push_back(event->pos()); m_ptArray.push_back(event->pos()); countClick++;

CDrawWin::m_curDrawStatus = CDrawWin::DRAW_STATUS_DRAWING; }

break; case 1: {

m_ptArray[1] = event->pos(); countClick++;

CDrawWin::m_curDrawStatus = CDrawWin::DRAW_STATUS_DRAWING; }

break;

本文来源:https://www.bwwdw.com/article/aslw.html

Top