Skip to content

Instantly share code, notes, and snippets.

View niXman's full-sized avatar
:octocat:
looking for a job

niXman niXman

:octocat:
looking for a job
  • I don't know where I am =)
View GitHub Profile
@niXman
niXman / main.cpp
Last active March 7, 2024 07:37
sorted/unsorted small vector search
#include <nanobench.h>
#include <iostream>
#include <array>
#include <set>
#include <algorithm>
/*************************************************************************************************/
@niXman
niXman / strtoint.cpp
Last active February 17, 2024 13:16
fastest string to unsigned naive implementation
// based on https://stackoverflow.com/a/73078442/2878380
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <chrono>
#include <charconv>
@niXman
niXman / pp enum
Last active March 28, 2024 18:33
#define SOME_PREFIX__CAT_I(a, b) a ## b
#define SOME_PREFIX__CAT(a, b) SOME_PREFIX__CAT_I(a, b)
#define SOME_PREFIX__ARG_N( \
_1 , _2, _3, _4, _5, _6, _7, _8, _9,_10, \
_11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
_21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \
_31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \
_41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \
@niXman
niXman / nixmans_atoi.cpp
Last active June 13, 2024 11:15
string to integer fast conversion
#include <cstdint>
#include <cassert>
#include <cstring>
#if !defined(__fallthrough) && defined(__has_cpp_attribute)
#if __has_cpp_attribute(fallthrough)
#define __FJ__FALLTHROUGH [[fallthrough]]
#elif __has_cpp_attribute(gnu::fallthrough)
#define __FJ__FALLTHROUGH [[gnu::fallthrough]]
@niXman
niXman / native-mingw-w64.sh
Created September 13, 2022 08:13
windows-hosted-mingw-w64
#!/bin/bash
THREADS=12
CROSS_MINGW_PREFIX="/home/nixman/mingw-w64-cross"
NATIVE_MINGW_PREFIX="/home/nixman/mingw-w64"
ORIGINAL_PATH="$PATH"
export PATH="$CROSS_MINGW_PREFIX/bin:$PATH"
@niXman
niXman / cross-mingw-w64.sh
Created September 13, 2022 08:12
linux-hosted-mingw-w64
#!/bin/bash
THREADS=12
CURRENT_DIR="$(pwd)"
CROSS_MINGW_PREFIX="$CURRENT_DIR/../mingw-w64-cross"
ORIGINAL_PATH="$PATH"
rm -rf "$CROSS_MINGW_PREFIX"
@niXman
niXman / main.cpp
Created September 2, 2022 11:15
binance permissions
#include <iostream>
#include <array>
#include <cstdint>
enum e_permissions: std::size_t {
NONE = 0
,SPOT = 1u << 0
,MARGIN = 1u << 1
@niXman
niXman / main.cpp
Last active February 17, 2024 13:22
parse IP at compile-time
#include <array>
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdint>
#if !defined(__fallthrough) && defined(__has_cpp_attribute)
#if __has_cpp_attribute(fallthrough)
@niXman
niXman / typename.hpp
Last active December 25, 2022 08:49
constexpr type_name()
#include <iostream>
#include <array>
#include <utility>
#include <string_view>
template<std::size_t...Idxs>
constexpr auto substring_as_array(std::string_view str, std::index_sequence<Idxs...>) {
return std::array{str[Idxs]..., '\n'};
}
@niXman
niXman / main.cpp
Last active November 18, 2022 09:41
struct to tuple
#include <tuple>
#include <type_traits>
struct any_type { template<class T> constexpr operator T(); };
#if defined(__GNUC__) && !defined(__clang__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#elif defined(__clang__)
# pragma clang diagnostic push