param

Java-HttpUtil

℡╲_俬逩灬. 提交于 2019-11-26 19:13:13
方便发送 Http 请求,不需要引入第三方依赖。 import java.io.*; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLDecoder; import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; public class HttpUtil { public static void main(String[] args) throws IOException { Map<String, String> map = new HashMap<>(); map.put("Accept", "*/*"); map.put("Pragma", "no-cache"); map.put("Connection", "keep-alive"); map.put("Cache-Control", "no-cache"); map.put("Accept-Language", "zh-CN,zh;q=0.9"); // map.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36

一键安装mysql

a 夏天 提交于 2019-11-26 17:35:59
  本文实现了mysql8.x版本( 下载 )在centos7.x操作系统下的一键安装,将文中代码复制到脚本文件,例如install-mysql.sh,将脚本文件与mysql-8.0.17-el7-x86_64.tar.gz放在同一目录下,执行sh install-mysql.sh即可,代码如下: #! /bin/bash config(){   echo "**************初始化数据"   mysql_bin="/usr/local/mysql/bin"   mysql_sock="/opt/apps/tmp/mysql/mysql.sock"   param="-h127.0.0.1 -uroot -proot"   #将root的密码设置为root   $mysql_bin/mysqladmin -S $mysql_sock -u root password 'root' 2>/dev/null   #设置编码为UTF8   $mysql_bin/mysql -S $mysql_sock $param -e"SET character_set_client = utf8" 2>/dev/null   $mysql_bin/mysql -S $mysql_sock $param -e"SET character_set_connection = utf8" 2>

Python爬虫之网页图片抓取

眉间皱痕 提交于 2019-11-26 17:30:39
/*--> */ /*--> */ 一、引入   这段时间一直在学习Python的东西,以前就听说Python爬虫多厉害,正好现在学到这里,跟着小甲鱼的Python视频写了一个爬虫程序,能实现简单的网页图片下载。 二、代码 __author__ = "JentZhang" import urllib.request import os import random import re def url_open(url): ''' 打开网页 :param url: :return: ''' req = urllib.request.Request(url) req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36') # 应用代理 ''' proxyies = ["111.155.116.237:8123","101.236.23.202:8866","122.114.31.177:808"] proxy = random.choice(proxyies) proxy_support = urllib.request.ProxyHandler({"http":

http接口调用

一曲冷凌霜 提交于 2019-11-26 17:00:14
import org.testng.annotations.Test; public class HttpTest { String creatOrderUrl="http://xxx.xxx.net/scriptParams/runScripts?ids=2303"; @Test //可以直接运行了,注意调用http接口,都不能继承别的接口(例如hsf),public void testCrestOrder() { System.out.println("url=="+creatOrderUrl);// httpRequest(creatOrderUrl); //System.out.println("url2=="+httpRequest(creatOrderUrl));} /**get请求*/public static String httpRequest(String req_url) { StringBuffer buffer = new StringBuffer(); try { URL url = new URL(req_url); HttpURLConnection httpUrlConn = (HttpURLConnection) url.openConnection(); httpUrlConn.setDoOutput(false); httpUrlConn

多图片放大缩小工具类

柔情痞子 提交于 2019-11-26 16:48:23
package com.lh.wx.utils; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; public class ImageUtil { /** * 对图片进行放大 * @param originalImage 原始图片 * @param times 放大倍数 * @return */ public static BufferedImage zoomInImage(BufferedImage originalImage, Integer times){ int width = originalImage.getWidth()*times; int height = originalImage.getHeight()*times; BufferedImage newImage = new BufferedImage(width,height,originalImage.getType()); Graphics g = newImage.getGraphics(); g.drawImage(originalImage, 0,0,width

PHP7 OpenSSL DES-EDE-CBC加解密

爷,独闯天下 提交于 2019-11-26 16:46:13
1. 条件约束 之前PHP5上常使用的mcrypt库在PHP7.1+上已经被移除,故我们采用openssl对数据进行加解密。 加密方式采用 DES-EDE-CBC 方式。 密钥填充方式为:采用24位密钥,先将key进行MD5校验取值,得出16位字串,再取key MD5校验值前8位追加到先前的取值后面。由此组装出24位的密钥。 2. 代码分享 <?php class DesEdeCbc { private $cipher, $key, $iv; /** * DesEdeCbc constructor. * @param $cipher * @param $key * @param $iv */ public function __construct($cipher, $key, $iv) { $this->cipher = $cipher; $this->key= $this->getFormatKey($key); $this->iv = $iv; } /** * @func 加密 * @param $msg * @return string */ public function encrypt($msg) { $des = @openssl_encrypt($msg, $this->cipher, $this->key, OPENSSL_RAW_DATA, $this->iv);

Application类-应用程序生命周期

随声附和 提交于 2019-11-26 16:03:54
1、创建Application对象 新建WPF程序后,排除掉WPF自动创建的App.xaml,我们自定义一个类,在该类的Main()方法中,创建Application对象,然后调用创建一个窗口对象,最后在Run()方法中,传递这个窗口对象。便完成了一个简单的应用程序的启动。 class AppStart { [STAThread] public static void Main() { Application application = new Application(); MainWindow mainWindow = new MainWindow(); application.Run(mainWindow); } } 当Run()方法中传递一个窗口时,该窗口就被设置为主窗口。我们可以通过Application.MainWidow属性获取到主窗口。 调用Run()方法后会触发Application.Startup事件并显示主窗口。 当然还有另一种方式启动应用程序: [STAThread] public static void Main() { Application application = new Application(); MainWindow mainWindow = new MainWindow(); application.MainWindow =

第15课 完美转发(std::forward)

浪尽此生 提交于 2019-11-26 14:58:06
一. 理解引用折叠   (一)引用折叠   1. 在C++中, “引用的引用”是非法的 。像auto& &rx = x;(注意两个&之间有空格)像这种直接定义引用的引用是不合法的,但是编译器在通过类型别名或模板参数推导等语境中,会间接定义出“引用的引用”,这时引用会形成“折叠”。   2. 引用折叠 会发生在 模板实例化、auto类型推导、创建和运用typedef和别名声明、以及decltype语境中 。 (二)引用折叠规则   1. 两条规则     (1)所有 右值引用折叠到右值引用上仍然是一个右值引用 。如X&& &&折叠为X&&。     (2)所有的其他引用类型之间的折叠都将变成左值引用。如X& &, X& &&, X&& &折叠为X&。可见 左值引用会传染,沾上一个左值引用就变左值引用了 。 根本原因:在一处声明为左值,就说明该对象为持久对象,编译器就必须保证此对象可靠(左值) 。   2. 利用引用折叠进行万能引用初始化类型推导     (1)当万能引用(T&& param)绑定到左值时,由于万能引用也是一个引用,而左值只能绑定到左值引用。因此,T会被推导为T&类型。从而param的类型为T& &&,引用折叠后的类型为T&。     (2)当万能引用(T&& param)绑定到右值时,同理万能引用是一个引用,而右值只能绑定到右值引用上,故T会被推导为T类型

PInvoke C#: Function takes pointer to function as argument

耗尽温柔 提交于 2019-11-26 14:23:36
问题 I'd like to access this function in my c# code, is this possible? so in the end the c++ code would call my function and also apply the struct called "sFrameofData". C++ Code: //The user supplied function will be called whenever a frame of data arrives. DLL int Cortex_SetDataHandlerFunc(void (*MyFunction)(sFrameOfData* pFrameOfData)); Would this work perhaps? C# Code: [DllImport("Cortex_SDK.dll")] public extern static int Cortex_SetDataHandlerFunc(ref IntPtr function(ref IntPtr pFrameOfData) )

request_html模块(上)

被刻印的时光 ゝ 提交于 2019-11-26 14:19:45
request_html模块(上) 牛逼的requests-html库 安装: pip install request-html 请求数据: from request_html import HTMLSession session = HTMLSession url = 'https://www.baidu.com/' # get: r = session.get(url=url) # post: r = session.post(url=url) # request r = session.request(method='get'/'post', url=url) HTML对象属性: from requests_html import HTMLSession session = HTMLSession() url = 'https://www.zhihu.com/' response = session.get(url=url) response的属性 print(response) print(type(response)) # <Response [200]> # <class 'requests_html.HTMLResponse'> print(dir(response)) #['__attrs__', '__bool__', '__class__', '_