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
namespace table {
namespace table_ {
struct id {
struct _name_t {
static constexpr const char* _get_name() { return "id"; }
template <typename T>
struct _member_t {
T id;
T& operator()() { return id; }
const T& operator()() const { return id; }
namespace table {
namespace table_ {
struct id {
struct _name_t {
static constexpr const char* _get_name() {return "id";}
template <typename T>
struct _member_t {
T id;
T& operator()() {return id; }
const T& operator()() const {return id;}
@niXman
niXman / fnv1a_32.cpp
Last active August 17, 2017 07:28
fnv1a
#include <iostream>
#include <cstdlib>
/***********************************************************************************/
constexpr std::uint32_t fnv1a_r(const char *s, std::uint32_t h = 0x811c9dc5) {
return (*s == 0) ? h : fnv1a_r(s+1, ((h ^ (*s)) * 0x01000193));
}
constexpr std::uint32_t fnv1a_i(const char *s) {
@niXman
niXman / num_of_bytes.cpp
Created December 8, 2017 20:43
num of bytes
#include <iostream>
#include <cstdint>
std::uint8_t num_of_bytes(std::uint64_t v) {
std::uint8_t c = 0;
c |= (!!(v & 0xFF00ull));
c |= (!!(v & 0xFF0000ull)) << 1;
c |= (!!(v & 0xFF000000ull)) << 2;
@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
@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 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 / 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 / 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 / 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"