Skip to content

Instantly share code, notes, and snippets.

@SergNikitin
SergNikitin / Caddyfile
Last active May 14, 2023 15:46
Caddyfile which works as a reverse proxy for PostHog EU
my.domain.com {
header {
# Below is sufficient if you want the proxy to work
# only for requests coming from your "production" domain.
# If you'd like to test your proxy from other domains, such
# as 'localhost', you'll need to tweak this line accordingly
Access-Control-Allow-Origin https://my.domain.com
}
reverse_proxy https://eu.posthog.com:443 {
@SergNikitin
SergNikitin / posthog-reverse-proxy-error.html
Created May 10, 2023 22:39
posthog-reverse-proxy-error
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>400 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Bad request.
We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
<BR clear="all">

There might be a problem with the project dependency tree. It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

"webpack": "4.44.2"

Don't try to install it manually: your package manager does it automatically. However, a different version of webpack was detected higher up in the tree:

@SergNikitin
SergNikitin / explicit_id_v2.cpp
Created October 20, 2016 19:17
explicit id v2
template <typename T, typename UniqueTag>
class ExplicitArithmeticID final
{
public:
using UnderlyingType = T;
static_assert(std::is_arithmetic<UnderlyingType>::value,
"ExplicitArithmeticID is for arithmetic types only");
constexpr explicit ExplicitArithmeticID(UnderlyingType value)
: mUnderlyingValue(value)
@SergNikitin
SergNikitin / explicit_id.cpp
Created October 20, 2016 09:15
Explicit ID
template <typename T, typename UniqueTag>
class ExplicitArithmeticID
{
public:
static_assert(std::is_arithmetic<T>::value, "ExplicitArithmeticID is for arithmetic types only");
using UnderlyingType = T;
constexpr explicit ExplicitArithmeticID(T value) : mUnderlyingValue(value) {};
const T& underlying() const
/**
* @brief Calls a callable for each passed parameter
* @details If callable is a C++14 generic lambda (i.e. [](auto&& arg){};),
* input parameters may be of different types
*/
template <typename Callable, typename... Args>
constexpr void InvokeForEach(const Callable& callable, Args&&... args)
{
// The following approach relies on the fact that contents
// of the array initializer list are evaluated from left to write
@SergNikitin
SergNikitin / ptr_cast.cpp
Created September 6, 2016 08:53
std::unique_ptr cast helpers
/**
* @brief Converts std::unique_ptr of base type to std::unique_ptr of derived type
* by using static_cast internally
* @details Ownership of the object is transfered to the returned std::unique_ptr.
* It is somewhat analogous to std::static_ptr_cast
*/
template<typename Derived, typename Base, typename Deleter>
std::unique_ptr<Derived, Deleter> static_ptr_cast(std::unique_ptr<Base, Deleter> base)
{
auto deleter = base.get_deleter();
@SergNikitin
SergNikitin / gist:458e625f0808a9f8daee
Created July 30, 2014 18:32
sdl_image linking error
libtool: link: gcc -I/home/snikitin/_src/img_glypher/libs/SDL2/src/sdl2_project/include -I/usr/local/include/SDL2 -D_REENTRANT -o showimage showimage.o -Wl,-rpath -Wl,/usr/local/lib -pthread -L/home/snikitin/_src/img_glypher/libs/SDL2/src/sdl2_project-build ./.libs/libSDL2_image.a -L/usr/local/lib -lSDL2 -pthread
/home/snikitin/_src/img_glypher/libs/SDL2/src/sdl2_project-build/libSDL2.a(SDL_dynapi.c.o): In function `get_sdlapi_entry':
/home/snikitin/_src/img_glypher/libs/SDL2/src/sdl2_project/src/dynapi/SDL_dynapi.c:227: undefined reference to `dlopen'
/home/snikitin/_src/img_glypher/libs/SDL2/src/sdl2_project/src/dynapi/SDL_dynapi.c:228: undefined reference to `dlsym'
/home/snikitin/_src/img_glypher/libs/SDL2/src/sdl2_project/src/dynapi/SDL_dynapi.c:227: undefined reference to `dlopen'
/home/snikitin/_src/img_glypher/libs/SDL2/src/sdl2_project/src/dynapi/SDL_dynapi.c:228: undefined reference to `dlsym'
/home/snikitin/_src/img_glypher/libs/SDL2/src/sdl2_project/src/dynapi/SDL_dynapi.c:227: undefined referenc
@SergNikitin
SergNikitin / gist:d8d9441120d00459201d
Created July 30, 2014 18:21
building sdl_image as CMake external project
cmake_minimum_required(VERSION 2.8)
include(ExternalProject)
project(freetype_test)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
set(LIBS_DIR ${PROJECT_SOURCE_DIR}/libs)
set(FREETYPE_VER "2.5.3")
set(SDL2_VER "2.0.3")
static const u08 BTN_NOT_PRESSED = 1;
int main() {
static u08 previousBtnState[4] = {BTN_NOT_PRESSED,
BTN_NOT_PRESSED,
BTN_NOT_PRESSED,
BTN_NOT_PRESSED};
}
/*