Skip to content

Instantly share code, notes, and snippets.

View kurotych's full-sized avatar

Anatolii Kurotych kurotych

View GitHub Profile
@kurotych
kurotych / check_linux_kernel_version.cmake
Last active November 18, 2022 06:33
How to check linux kernel version in cmake
execute_process(COMMAND uname -r OUTPUT_VARIABLE UNAME_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE)
message(-- " Kernel version: " ${UNAME_RESULT})
string(REGEX MATCH "[0-9]+.[0-9]+" LINUX_KERNEL_VERSION ${UNAME_RESULT})
if (LINUX_KERNEL_VERSION VERSION_LESS 3.8)
message(FATAL_ERROR "Linux kernel version should be greater than 3.8")
endif()
#!/usr/bin/env python3
import socket
import time
HOST = '10.0.0.1'
PORT = 143
while(1):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
@kurotych
kurotych / .clang-format
Last active August 22, 2019 19:35
My code style
Language: Cpp
Standard: Cpp11
IndentWidth: 4
PointerAlignment: Left
ColumnLimit: 90
AllowShortIfStatementsOnASingleLine: true
AccessModifierOffset: -4
AlignEscapedNewlinesLeft: true
AlignTrailingComments: true
AllowShortFunctionsOnASingleLine: true
#include <utility>
// C++14
template <int i1, int i2, typename... Args>
auto to_pair(std::tuple<Args...> t)
{
return std::make_pair(std::get<i1>(t), std::get<i2>(t));
}
// C++11
.text
.global _start
_start:
mov $2, %eax
mov $3, %edx
call power
mov %eax, %ebx
mov $1, %eax
func byteStringToBytes(s *string) []byte {
*s = (*s)[1:len(*s) - 1]
split := strings.Split(*s, ",")
res := make([]byte, len(split))
for i, el := range split {
r , _ := strconv.Atoi(el)
{
"bootstrapped": true,
"in_process_packages":
[
],
"installed_packages":
[
"GoSublime",
"Package Control",
"TerminalView"
@kurotych
kurotych / set dns address by AdapterName
Last active April 14, 2019 22:56
set dns addr in Windows
// example adapterName : {54BB6B17-91C0-4F84-83B2-DE82C525425C}
bool setDNS(QString sAdapterName, QString sDNS)
{
HKEY hKey;
QString strKeyName = "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\" + sAdapterName;
if( RegOpenKeyEx(HKEY_LOCAL_MACHINE,
strKeyName.toStdWString().c_str(),
0,
KEY_WRITE,