买二手车备注

甲方保证发动机、变速箱未拆卸更换,保证此车无任何经济纠纷,可正常过户,保证此车无火烧、无泡水、无事故,车身四梁六柱无切割,公里数为实表。如有以上情况甲方退还车款并以此车款的3倍赔给乙方

gulp与node版本兼容问题

win10系统下使用django时,用到了node,gulp等插件,但是在执行gulp命令时一直报错,网上找了n种方法,靠自己一步步填坑,终于解决了这个bug。记录一下完整的过程。

一、node与gulp版本兼容问题略谈。
我们使用nvm管理node版本,使用npm下载node中的各种插件,包括gulp,node版本需要与gulp版本相适应,比如node12以上的版本不能兼容gulp3,反过来一样gulp4不能适应node12一下的版本(我猜的,嘻嘻)。而node版本号中奇数为测试版,偶数为稳定版,所以我们需要选择合适的版本。我本来打算使用node12版本,但是在下载gulp4.0.2版本时cmd命令行总是显示为2版本,所以最后改为使用node10.20.1,gulp3.9.1。

https://github.com/coreybutler/nvm-windows/releases

二、完整操作过程
首先,假设已经安装了nvm,我们在命令行窗口下安装node10:
nvm install 10.20.1
然后使用10:
nvm use 10.20.1
接下来就可以安装gulp3,注意如果之前安装过其它版本,需要先清空npm_cache文件(在C/用户/APPDATA/roaming/下)并卸载gulp旧版本,卸载命令如下:
npm cache clean -f
npm uninstall –global gulp
安装命令如下:
npm install –global gulp@3.9.1

下面在命令行进入django项目中对应的文件夹,如果之前在该文件夹使用过npm install 命令,还需清空npm_cache 文件夹并清空缓存,命令如下:
npm cache clean -f
然后可以进行安装:
npm install
查看gulp版本:
gulp -v
如果全局与局部都是3.9.1版本,可以执行gulp命令:
gulp
然后会打开浏览器,这就表明命令成功了!!

ubuntu安装uwsgi

sudo apt-get install python3-dev build-essential libpcre3-dev

 

验证pcre

pcre-config --version

pip install uwsgi

验证uwsgi

mkdir /var/www/pyhtml/root

(需要自己保证一下用户ubuntu有权限)

vi wsgi.py
def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return [b"Hello World"]
uwsgi --http :9090 --wsgi-file wsgi.py

mkdir /var/www/pyhtml/uwsgi
(需要自己保证一下用户ubuntu有权限)
cd /var/www/pyhtml/uwsgi
vi uwsgi.ini
[uwsgi]
http = :9090
#http = 127.0.0.1:9090
chdir = /var/www/pyhtml/root
# /var/www/pyhtml/uwsgi/wsgi.py application
module = wsgi:application
master = True
processes = 1
threads = 2
daemonize = wsgi.log
vacuum = true
pidfile = uwsgi.pid

 

sudo vi /etc/systemd/system/uwsgi.service

 

[Unit]
Description=uWSGI server
After=syslog.target

[Service]
User=ubuntu
WorkingDirectory=/var/www/pyhtml/uwsgi
ExecStart=/home/ubuntu/.local/bin/uwsgi --ini uwsgi.ini
Group=www-data

[Install]
WantedBy=multi-user.target

 

安装wasm 1.39.15

安装emsdk 1_39_15

  1. 运行脚本激活fastcomp

{path}/emsdk_1_39_15/emsdk activate latest-fastcomp
source {path}/emsdk_1_39_15/emsdk_env.sh

2. 在~/.bashrc中加入

export EMSDK={path}/emsdk_1_39_15
export EM_CONFIG={path}/emsdk_1_39_15/.emscripten
export EM_CACHE={path}/emsdk_1_39_15/fastcomp/emscripten/cache

export PATH=$PATH:${EMSDK}/fastcomp/fastcomp/bin:${EMSDK}:${EMSDK}/fastcomp/emscripten:${EMSDK}/fastcomp/bin

wasm wrap string

C代码

// C - code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifndef EM_PORT_API
    #if defined(__EMSCRIPTEN__)
        #include <emscripten.h>
#if defined(__cplusplus)
#define EM_PORT_API(rettype) extern "C" rettype EMSCRIPTEN_KEEPALIVE
#else
#define EM_PORT_API(rettype) rettype EMSCRIPTEN_KEEPALIVE
#endif
    #else
#if defined(__cplusplus)
#define EM_PORT_API(rettype) extern "C" rettype 
#else
#define EM_PORT_API(rettype) rettype 
#endif
    #endif
#endif

EM_PORT_API(char*) fm_substr(char* buf, int pos) {
    char * ret;
    int sz = strlen(buf);

    ret = calloc(sz+1-pos, 1);
    memcpy(ret, buf+pos, sz-pos);

    return ret;
}

 

编译:

emcc -s RESERVED_FUNCTION_POINTERS=20 -s EXPORTED_RUNTIME_METHODS=['ccall','cwrap','stringToUTF8','UTF8ToString'] -s EXPORTED_FUNCTIONS=['_malloc','_free'] test.c -o test.js

 

 

使用:js代码

// JS - code

var result = Module.ccall('fm_substr', // name of C function
  'string', // return type
  ['string', 'number'], // argument types
  ['abc', 1]); // arguments

var c_js_ds_substr = Module.cwrap('fm_substr', // name of C function
  'string', // return type
  ['string', 'number']); // argument types
// Call c_javascript_add normally

console.log(c_js_ds_substr('abc', 1));
console.log(c_js_ds_substr('abc', 2));

 

openssl coding得到过期时间

#include <stdio.h>
#include <string.h>

#include <openssl/rand.h>
#include <openssl/asn1t.h>
#include <openssl/pem.h>
#include <openssl/bio.h>

#include "lws-pub.h"
#include "lws-sha1-base64.h"


static char* ECDSACertPEM = "-----BEGIN CERTIFICATE-----\n"
"MIIGxzCCBa+gAwIBAgIIc54uwAnLX20wDQYJKoZIhvcNAQELBQAwgbQxCzAJBgNV\n"
"...\n"
"...\n"
"MXYXS/YRsQ1FZrOK0RL3Ts624N4QZnfIxLspqiRo6wlCvUutLRe1QieqVfjm7SYp\n"
"r7rWE+e3ef9C+es=\n"
"-----END CERTIFICATE-----\n";

int main()
{
    uint8_t * p = NULL;
    lws_filepos_t flen = 0;

    BIO* bio_buf = BIO_new(BIO_s_mem());
    BIO_write(bio_buf, ECDSACertPEM, strlen(ECDSACertPEM));
    X509 * cert = PEM_read_bio_X509(bio_buf, NULL, NULL, NULL);
    const ASN1_TIME *tm = X509_get0_notAfter(cert);
    printf("date: %s \r\n", tm->data);

    BIO_free(bio_buf);
    X509_free(cert);

    struct tm tm1;
    ASN1_TIME_to_tm(tm, &tm1);
    
    printf("date: %d-%d-%d \r\n", 1900+tm1.tm_year, 1+tm1.tm_mon, tm1.tm_mday);

    getchar();
    return 0;
}

 

Bug with TLS 1.2 in Win7 IE11

介绍这个bug
https://serverfault.com/questions/741706/bug-with-tls-1-2-in-internet-explorer-11-windows-7#answer-845167

MS14-066:Schannel 中的漏洞可能允许远程执行代码:2014 年 11 月 11 日https://support.microsoft.com/zh-cn/topic/ms14-066-schannel-%E4%B8%AD%E7%9A%84%E6%BC%8F%E6%B4%9E%E5%8F%AF%E8%83%BD%E5%85%81%E8%AE%B8%E8%BF%9C%E7%A8%8B%E6%89%A7%E8%A1%8C%E4%BB%A3%E7%A0%81-2014-%E5%B9%B4-11-%E6%9C%88-11-%E6%97%A5-4740940a-5fe0-8d9b-88b5-2e2ca5999537

c++11 获得精确时间

#include <iostream>
#include <chrono>
#include <ctime>

#include <sys/timeb.h>
using namespace std;

int main()
{
	// using timeb.h -- deprecated
	struct timeb ft;
	ftime(&ft);	
	
	// using chrono
	auto tp = std::chrono::system_clock::now();
	auto now = std::chrono::system_clock::to_time_t(tp);		
	long long eee = std::chrono::system_clock::period::den / (1000* std::chrono::system_clock::period::num);
	long long fff = tp.time_since_epoch().count();
	int ms = (fff / eee) % 1000;


	printf("A1 %ld, %d\r\n", now, ms);
	
	printf("A2 %ld, %d\r\n", ft.time, ft.millitm);
	

	// change to readable string
	struct tm* gmtm = gmtime(&now);
// gmtm->tm_year+1900
// tmtm->tm_mon+1
	char* dt = asctime(gmtm);
	
	return 0;
}

How to decrypt data from the result of an IE 11 encrypt operation using AES-GCM

https://stackoverflow.com/questions/41449185/how-to-decrypt-data-from-the-result-of-an-ie-11-encrypt-operation-using-aes-gcm

重要的是第一个回复!

<!DOCTYPE html>
<html>
<body>
<script>
	let plainText = new Uint8Array([1]);
	let key;
	
	let secretDic = {
        a: [88, 88, 88, 88, 88, 88, 88, 88,
        88, 88, 88, 88, 88, 88, 88, 88,
        88, 88, 88, 88, 88, 88, 88, 88,
        88, 88, 88, 88, 88, 88, 88, 88]
    };
	
	let keyBuf = new Uint8Array(secretDic.a);
	let iv = window.msCrypto.getRandomValues(new Uint8Array(12));
	let encResult;
	let importOp = window.msCrypto.subtle.importKey('raw', 
		keyBuf,
		{ name: 'AES-GCM' }, 
		true, // false
		['encrypt', 'decrypt']);
		
	importOp.oncomplete = function(e) {
		key = e.target.result;
		console.log('key: ');
		console.log(key);
		
		let encryptOp = window.msCrypto.subtle.encrypt({
			name: 'AES-GCM',
			iv: iv,
			tagLength: 128
		}, key, plainText);
		encryptOp.oncomplete = function (e) {
			encResult = e.target.result;
			console.log('encResult');
			console.log(encResult);
			
			let decryptOp = window.msCrypto.subtle.decrypt({
				name: 'AES-GCM',
				iv: iv,
				tag: new Uint8Array(encResult.tag)
			}, key, new Uint8Array(encResult.ciphertext));
			decryptOp.onerror = function(er){
				console.log('err:');
				console.log(er);
			};
			
			console.log('decrypt');
			console.log(decryptOp);
		};
	};
	
</script>
</body>
</html>