Skip to content

Instantly share code, notes, and snippets.

View Chae4ek's full-sized avatar
💜
choose the hard way!

Alexey Nominas Chae4ek

💜
choose the hard way!
View GitHub Profile
@Chae4ek
Chae4ek / TrustedCmd.c
Created September 12, 2024 15:56
Run cmd.exe as TrustedInstaller
#include <Windows.h>
// it has to be included after Windows.h
#include <TlHelp32.h>
static inline int EnablePrivilege(LPCWSTR privilegeName) {
HANDLE hToken = INVALID_HANDLE_VALUE;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, &hToken)) {
return -1;
}
@Chae4ek
Chae4ek / patterns.md
Created April 2, 2024 18:45
Vim's search patterns for the parts of words like in VSCode

Vim's search patterns for the words taking into account camelCase and snake_case. Also, you can modify it for kebab-case (but I don't use it anywhere), e.g. replace every _ to \(_\|-\)

VSCode's "WordPart" works a little differently for snake_case (worse imo). These patterns work greedy for underscores.

Don't forget to escape characters if you gonna use it in lua. There are some possible patterns for you:

@Chae4ek
Chae4ek / theming.md
Created November 30, 2022 05:21
How to use themes in CSS

How to use themes in CSS

This is one of the approaches to defining themes in CSS and using them in JS or TS.
Also you can define an interface for a theme and dynamically create CSS classes.

CSS Modules have an :export block to export variables for using them in .js files.
Create a themes.scss file:

// themes.scss (global scope by default)
@Chae4ek
Chae4ek / Dereferencer.cpp
Created September 5, 2021 15:57
This function dereferences all pointers
#include <type_traits>
template<class T>
static inline constexpr const auto* __get_declaration_ptr(const T* obj) noexcept {
if constexpr (std::is_same_v<T, std::remove_pointer_t<T>>)
return static_cast<const T*>(obj);
else
return __get_declaration_ptr(*obj);
}