This file contains hidden or 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 <iostream> | |
| #if __cplusplus < 201700L | |
| // c++11 | |
| template<typename... Args> | |
| constexpr int f(Args&&... args) { | |
| int sum = 0; | |
| int arr[] = {(sum+=args, 0)...}; | |
| return sum; |
This file contains hidden or 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
| # 指定 dnsmasq 监听的接口 | |
| #interface=ens160 | |
| listen-address=10.1.1.22 | |
| # 禁用 DNS 功能 | |
| port=0 | |
| dhcp-range=10.1.1.0,static,255.255.255.0,1h | |
| # 主机白名单 |
This file contains hidden or 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 <iostream> | |
| #include <QDebug> | |
| #include <QRectF> | |
| template<typename T, typename = void> | |
| struct has_qdebug_stream_operator : std::false_type {}; | |
| template<typename T> | |
| struct has_qdebug_stream_operator<T, std::void_t<decltype(std::declval<QDebug>() << std::declval<T>())>> : std::true_type {}; |
This file contains hidden or 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://aka.ms/vs/17/release/vs_community.exe | |
| .\vs_Community.exe --layout d:\localVSlayout --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Component.VC.140 --add Microsoft.VisualStudio.Component.VC.v141.x86.x64 --add Microsoft.VisualStudio.ComponentGroup.VC.Tools.142.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.19041 --includeRecommended --lang en-US | |
| # install | |
| .\vs_Community.exe --noWeb --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Component.VC.140 --add Microsoft.VisualStudio.Component.VC.v141.x86.x64 --add Microsoft.VisualStudio.ComponentGroup.VC.Tools.142.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.19041 --includeRecommended --addProductLang en-US |
This file contains hidden or 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 draw_rounded_rect(self, painter, rect, x_radius=10, y_radius=10, corners=(1, 1, 1, 1), mode = Qt.AbsoluteSize): | |
| path = QPainterPath() | |
| if mode == Qt.RelativeSize: | |
| x_radius = x_radius / 100 * (rect.width()/2) | |
| y_radius = y_radius / 100 * (rect.height()/2) | |
| x_radius = max(0, min(x_radius, rect.width()/2)) | |
| y_radius = max(0, min(y_radius, rect.height()/2)) |
This file contains hidden or 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
| import sys | |
| import socket | |
| import struct | |
| def multicast_receive(multicast_group, port): | |
| sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
| sock.bind(('', port)) | |
| group = socket.inet_aton(multicast_group) |
This file contains hidden or 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
| import socket | |
| def get_myip(): | |
| s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
| s.settimeout(0) | |
| myip = None | |
| try: | |
| # doesn't even have to be reachable | |
| s.connect(('10.254.254.254', 1)) |
This file contains hidden or 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
| user nginx; | |
| worker_processes 1; | |
| error_log /var/log/nginx/error.log notice; | |
| pid /var/run/nginx.pid; | |
| events { | |
| worker_connections 1024; | |
| } |
This file contains hidden or 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
| ssh-keygen && cat $env:userprofile/.ssh/id_rsa.pub | ssh user@linuxserver 'cat >> .ssh/authorized_keys' |
This file contains hidden or 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
| import sys | |
| from PyQt5.QtCore import * | |
| from PyQt5.QtGui import * | |
| from PyQt5.QtWidgets import * | |
| def rect_scale(source, target, aspect=Qt.IgnoreAspectRatio): | |
| """缩放 | |
| source 待缩放 |
NewerOlder