This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://www.suchan.cz/2015/08/uwp-quick-tip-getting-device-os-and-app-info/ | |
https://docs.microsoft.com/zh-cn/windows/desktop/api/winnt/ns-winnt-_osversioninfoa | |
https://social.msdn.microsoft.com/Forums/WINDOWS/en-US/6d754895-36c0-403d-a91d-f0efbc1f36a8/uwphow-to-retrieve-os-version-in-a-universal-app?forum=wpdevelop | |
*/ | |
using Windows.ApplicationModel; | |
using Windows.Security.ExchangeActiveSyncProvisioning; | |
using Windows.System.Profile; | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MD5 | |
public static string Md5(string str) | |
{ | |
var algorithm = HashAlgorithmNames.Md5; | |
HashAlgorithmProvider provider = HashAlgorithmProvider.OpenAlgorithm(algorithm); | |
var hash = provider.CreateHash(); | |
IBuffer buffer = CryptographicBuffer.ConvertStringToBinary(str, BinaryStringEncoding.Utf16LE); | |
hash.Append(buffer); | |
var hashedBuffer = hash.GetValueAndReset(); | |
return CryptographicBuffer.ConvertBinaryToString(BinaryStringEncoding.Utf16LE, hashedBuffer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set websocket url | |
string ip = "ws://" + "api.test.com:80"; | |
// new websocket | |
MessageWebSocket socket = new MessageWebSocket(); | |
var cts = new CancellationTokenSource(); | |
cts.CancelAfter(2000); // cancel after 2 seconds | |
var connectAsync = socket.ConnectAsync(new Uri(ip)); | |
var connectTask = connectAsync.AsTask(cts.Token); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <Windows.h> | |
std::string UTF8_To_Std_Str(const std::string & str) | |
{ | |
int nwLen = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, NULL, 0); | |
wchar_t* pwBuf = new wchar_t[nwLen + 1]; | |
memset(pwBuf, 0, nwLen * 2 + 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_query_parameter(url, param_name, param_value): | |
"""Given a URL, set or replace a query parameter and return the | |
modified URL. | |
>>> set_query_parameter('http://example.com?foo=bar&biz=baz', 'foo', 'stuff') | |
'http://example.com?foo=stuff&biz=baz' | |
""" | |
scheme, netloc, path, query_string, fragment = urlsplit(url) | |
query_params = parse_qs(query_string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def encodeConversion(req): | |
if req.encoding == 'ISO-8859-1': | |
encodings = requests.utils.get_encodings_from_content(req.text) | |
if encodings: | |
encoding = encodings[0] | |
else: | |
encoding = req.apparent_encoding | |
# encode_content = req.content.decode(encoding, 'replace').encode('utf-8', 'replace') | |
encode_content = req.content.decode(encoding, 'replace') # 如果设置为replace,则会用?取代非法字符; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def guess_encoding(csv_file): | |
"""guess the encoding of the given file""" | |
import io | |
import locale | |
with io.open(csv_file, "rb") as f: | |
data = f.read(5) | |
if data.startswith(b"\xEF\xBB\xBF"): # UTF-8 with a "BOM" | |
return "utf-8-sig" | |
elif data.startswith(b"\xFF\xFE") or data.startswith(b"\xFE\xFF"): | |
return "utf-16" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
专业版(Professional): | |
KBJFW-NXHK6-W4WJM-CRMQB-G3CDH | |
企业版(Enterprise): | |
NJVYC-BMHX2-G77MM-4XJMR-6Q8QF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
题目:从尾到头打印链表 | |
题目描述:输入一个链表,按链表值从尾到头的顺序返回一个ArrayList。 | |
*/ | |
/** | |
* struct ListNode { | |
* int val; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: UTF-8 -*- | |
# Python 生成 CSV 文件 | |
# Python 生成 CSV 文件,可用于生成带标签的数据集 CSV 文件,标签从0开始自动升序:0,1,2,3... | |
# 作者:https://github.com/huihut | |
# 参考:https://github.com/opencv/opencv_attic/blob/master/opencv/modules/contrib/doc/facerec/src/create_csv.py | |
''' |