Skip to content

Instantly share code, notes, and snippets.

View Crspy's full-sized avatar
🏠
Working from home

Amr Zaki Crspy

🏠
Working from home
View GitHub Profile
@Crspy
Crspy / constexpr_to_string.cpp
Last active November 18, 2020 14:32
C++11 constexpr numbers (any base) to string (array of chars) conversion also supports prefixes
#include <cstdio>
#include <cstdint>
#include <type_traits>
namespace fast
{
namespace detail
{
constexpr auto numbers = "0123456789ABCDEF";
@Crspy
Crspy / concat_strings.cpp
Last active November 20, 2025 11:21
C++17 constexpr strings concatenation
#include <type_traits>
#include <array>
#include <iostream>
template<typename first, typename... rest>
constexpr auto all_same_v = std::conjunction_v<std::is_same<first, rest>...>;
template <typename... Ts>
constexpr auto concat_strings(Ts&&... args) {
@Crspy
Crspy / TReg.cpp
Last active July 26, 2020 13:13
C++11 templatized constexpr register wrapper class
#include <stddef.h> // this is all we need
namespace reg_wrapper
{
namespace detail
{
template <class T, T v>
struct integral_constant
{
@Crspy
Crspy / FindProcessInfo.cpp
Created June 16, 2020 20:34
Find Process Handle & BaseAdresss
struct ProcessInfo {
HANDLE handle;
HMODULE baseAddress;
};
ProcessInfo FindProcessHandle(const TCHAR* targetProcName)
{
DWORD aProcesses[1024], bytesNeeded;
@Crspy
Crspy / LongestSubSeq.cpp
Last active May 22, 2019 23:05
Find longest common sub sequence in two strings.
#include <string>
std::string LongestSubSeq(std::string s1, std::string s2)
{
// space complexity O(2 *LengthOfLongestString)
// time Complexity O(s1Length*s2Length)
size_t Len = s1.length() > s2.length() ? s1.length() : s2.length();
std::string result,temp;
result.reserve(Len);
temp.reserve(Len);