Skip to content

Instantly share code, notes, and snippets.

View zethon's full-sized avatar
👓

Addy zethon

👓
View GitHub Profile
@zethon
zethon / gist:858b20b4d94e47f11c80995348481d43
Created December 19, 2017 19:04
CMake, Curl and Visual Studio
# This was required in my project's CMake in order to properly link and build against curl
if (MSVC)
add_definitions(
-D_SCL_SECURE_NO_WARNINGS
-DWIN32_LEAN_AND_MEAN
-DCURL_STATICLIB
)
list(APPEND CURL_LIBRARIES
@zethon
zethon / gist:a25255115d68b65670dcd20b7b3c2f42
Created December 22, 2017 13:28
-Xlinker -no_deduplicate
-Xlinker -no_deduplicate
Adding this to DEBUG builds can reduce linking times greatly. I still haven't figured out how to get it in CMake working properly.
@zethon
zethon / timer.cpp
Last active February 22, 2018 18:03
Quick test of std::copy vs boost::iostream
#include <boost/timer/timer.hpp>
#include <boost/iostreams/stream.hpp>
#include <cmath>
#include <iostream>
#define BUFFER_SIZE 64 * 1024
char buffer[BUFFER_SIZE];
const char* data = R"(0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234
@zethon
zethon / gist:dc7a5c71b0ac3cff35017febd1f15511
Last active June 27, 2021 04:04
Changing the color of macOS app title bar in Qt with CMake

In CMake, add/link the Carbon library to the executable

    FIND_LIBRARY(CARBON_LIBRARY Carbon)
    set(EXTRA_LIBS
        ${CARBON_LIBRARY}

Make sure to add ${CARBON_LIBRARY} in the TARGET_LINK_LIBRARIES call for the executable.

Then create a file to hold the Object-C code, in this case changetitlebarcolor.mm

@zethon
zethon / spanish-phrases.txt
Last active July 9, 2024 11:23
Spanish Phrases
* En medio de todo eso... - In the middle of it all...
* Ni modo que me vaya a dormir - There is no way I am going to sleep.
* toma siesta - take a nap
* solicitud - request
* si alguna vez.. - if ever...
(e.g. si alguna vez te veo, te besara - if i ever see you, i will kiss you)
* No escuchaba nada de lo que le deciamos - He didn't listen to anything we told him.
* Podria correr el riesgo - I'll take that risk
(lit. I could run the risk)
* Ahora mismo - right now, this second
// Alternate answer to: https://stackoverflow.com/questions/63643025/lua-5-2-sandboxing-in-different-objects-with-c-api
#include <string>
#include <cassert>
#include <iostream>
#include <lua/lua.hpp>
#include <fmt/format.h>
@zethon
zethon / swedish-words.txt
Last active October 1, 2020 11:57
Swedish Words
igen - again
arr - is
jag har ett träd på mitt hus - I have a tree on my house
@zethon
zethon / file.cpp
Created December 19, 2020 02:47
C++ Cumulative Moving Average Class
template<typename NumberT>
class CumulativeMovingAverage
{
NumberT _total = 0;
std::size_t _count = 0;
public:
float value() const
{
// TODO: pretty sure only one cast is need, but not 100% sure
@zethon
zethon / iterator.cpp
Created June 22, 2021 13:26
Writing a Custom Iterator for a Container with Ephemeral Objects
#include <iostream>
#include <string>
#include <vector>
#include <memory>
class Database
{
std::vector<int> _data;
public: