WebRTC detect connection type
WebRTC detect connection type
Test on Chromium 87 and 90
Detecting the connection type of webrtc, p2p or relay.
// Listen for connectionstatechange on[......]
Test on Chromium 87 and 90
Detecting the connection type of webrtc, p2p or relay.
// Listen for connectionstatechange on[......]
创建一个electron 窗口,设置skipTaskbar为true,即可隐藏应用的任务栏图标。
const {app, BrowserWindow} = require('electron')
function createWindow () {
cons[......]
LeetCode – Reverse Linked List
将单链表逆序
性能:
Runtime: 4 ms, faster than 89.98% of C online submissions for Reverse Linked List.
算法思路:
类比于插入排[……]
LeetCode – Remove Duplicates from Sorted Array
对已经排好序的数组,去除其中重复的元素,并返回去重后的长度。如[1,2,2,3,3],去重后为[1,2,3] ,去重后长度为3
两个指针,前者(p)记录当前去重后的最后一个元素,后者(i)[……]
升级了系统到 macOS Mojave 10.14.4,使用gcc 和 clang 编译时,总是提示如下错误
➜ tmp gcc main.c
ld: malformed file
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.s[……]
shared_ptr内部维护一个引用计数,当创建、copy、销毁时,引用计数都会变化
(1) 拷贝构造函数 p(q),会递增q的引用,p和q指向同一个对象
shared_ptr<string> q = make_shared<string>[......]
CAS, compare-and-swap, 原子的比较和设置变量值。
#include <stdio.h>
#if defined(__linux__) || defined(__unix__)
#define CAS32(ptr, val_old, val_new[......]
protobuf的github 源码地址为 https://github.com/google/protobuf
本次使用的环境为ubuntu,参照官方教程
sudo apt-get install autoconf automake libtool curl #安装工具
git c[......]
std::bind1st 和 std::bind2nd将二元函数转换为一元函数,具体用法参加下面的代码。
代码介绍了两种使用方式,第一种是使用std::less和std::greater,第二种是使用自定义的仿函数。
#include <iostream>
#include <ve[......]
一个简单的日志函数示例,使用宏实现日志的打印和显示。
不足:没有考虑多线程的文件操作问题;宏较长,使用宏会使得代码体积膨胀。
#include <stdio.h>
#include <time.h>
#include <string>
#define __MOD[......]
libjpeg 库主要用于 jpeg 格式图片的编解码,其交叉编译过程如下
从官方网站http://www.ijg.org/files/ 下载libjpeg库的源码,本次编译过程使用的是jpegsrc.v9a.tar.gz
# 2.1 切[......]