Skip to content

Instantly share code, notes, and snippets.

Sergey Gomon gomons

Block or report user

Report or block gomons

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gomons
gomons / zlib_strings.cpp
Last active Sep 1, 2019
Compressing STL Strings with zlib
View zlib_strings.cpp
// Copyright 2007 Timo Bingmann <tb@panthema.net>
// Distributed under the Boost Software License, Version 1.0.
// (See http://www.boost.org/LICENSE_1_0.txt)
//
// Original link http://panthema.net/2007/0328-ZLibString.html
#include <string>
#include <stdexcept>
#include <iostream>
#include <iomanip>
@gomons
gomons / guid.h
Created Jun 21, 2017
Generate GUID by using boost C++ library
View guid.h
std::string generate_guid()
{
boost::uuids::uuid const uuid = boost::uuids::random_generator()();
return boost::uuids::to_string(uuid);
}
@gomons
gomons / to_underlying.cpp
Last active Jun 15, 2016
Convert enum class value to undrlying type
View to_underlying.cpp
template <typename E> constexpr typename std::underlying_type<E>::type to_underlying(E e) {
return static_cast<typename std::underlying_type<E>::type>(e);
}
@gomons
gomons / image_stride.cpp
Last active Jun 15, 2016
Image stride calculation with padding of 4 byte
View image_stride.cpp
inline size_t image_stride_4(size_t width, size_t channels_count) {
return ( (width*channels_count * 8 + 31) & ~31) >> 3;
}
@gomons
gomons / endianness.cpp
Last active Apr 3, 2016
Convert endianness of integral types.
View endianness.cpp
// Original: http://stackoverflow.com/a/12867287/1091536
// Usage:
// To convert from given endian to host, use:
// host = endian(source, endian_of_source)
// To convert from host endian to given endian, use:
// output = endian(hostsource, endian_you_want_to_output)
enum class Endian: int {
Big = 1, Little = 0
};
You can’t perform that action at this time.