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
## update sources | |
#sudo apt-get update | |
#sudo apt-get upgrade | |
## a good mirror based on your location | |
deb mirror://mirrors.ubuntu.com/mirrors.txt precise main restricted universe multiverse | |
deb mirror://mirrors.ubuntu.com/mirrors.txt precise-updates main restricted universe multiverse | |
deb mirror://mirrors.ubuntu.com/mirrors.txt precise-backports main restricted universe multiverse | |
deb mirror://mirrors.ubuntu.com/mirrors.txt precise-security main restricted universe multiverse |
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
/* | |
* [MiniDumpWriteDump function](https://docs.microsoft.com/zh-cn/windows/desktop/api/minidumpapiset/nf-minidumpapiset-minidumpwritedump) | |
* [_MINIDUMP_TYPE Enumeration](https://docs.microsoft.com/zh-cn/windows/desktop/api/minidumpapiset/ne-minidumpapiset-_minidump_type) | |
* [Programmatically Generating a Dump File](http://blogs.microsoft.co.il/sasha/2008/05/28/programmatically-generating-a-dump-file/) | |
* [Create your own crash dumps](https://blogs.msdn.microsoft.com/calvin_hsia/2015/08/31/create-your-own-crash-dumps/) | |
*/ | |
using Microsoft.Win32.SafeHandles; | |
using System; | |
using System.Collections.Generic; |
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
@echo off | |
title Activate Microsoft Office 2016 ALL versions for FREE!&cls&echo ============================================================================&echo #Project: Activating Microsoft software products for FREE without software&echo ============================================================================&echo.&echo #Supported products:&echo - Microsoft Office Standard 2016&echo - Microsoft Office Professional Plus 2016&echo.&echo.&(if exist "%ProgramFiles%\Microsoft Office\Office16\ospp.vbs" cd /d "%ProgramFiles%\Microsoft Office\Office16")&(if exist "%ProgramFiles(x86)%\Microsoft Office\Office16\ospp.vbs" cd /d "%ProgramFiles(x86)%\Microsoft Office\Office16")&(for /f %%x in ('dir /b ..\root\Licenses16\proplusvl_kms*.xrm-ms') do cscript ospp.vbs /inslic:"..\root\Licenses16\%%x" >nul)&(for /f %%x in ('dir /b ..\root\Licenses16\proplusvl_mak*.xrm-ms') do cscript ospp.vbs /inslic:"..\root\Licenses16\%%x" >nul)&echo.&echo ============================================================================&ech |
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
# Website: http://www.convertdatatypes.com/Language-CSharp.html | |
# Convert string to bool | |
string vIn = "true"; | |
bool vOut = Convert.ToBoolean(vIn); | |
# Convert string to int | |
string vIn = "0"; | |
int vOut = Convert.ToInt32(vIn); |
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" |