Skip to content

Instantly share code, notes, and snippets.

View r-lyeh-archived's full-sized avatar

r-lyeh-archived

View GitHub Profile
// [ref] https://www.niksula.hut.fi/~hkankaan/Homepages/changeable%20colors.html
// This is my example picture. Now I want to make that red ball to be brown, green to be yellow and blue to be white. Notice that this picture also has antialiased lines.
//slide(x,y) means an array slide(from color,to color)
//these three lines make channel 0 (red channel) brown
//(172 red, 108 green and 48 blue equals brown)
slide(0,0) = 172
slide(0,1) = 108
slide(0,2) = 48
@r-lyeh-archived
r-lyeh-archived / optevent.hpp
Created February 23, 2016 18:13
optimistic event dispatcher v2
#if 0
// [src] http://nercury.github.io/c++/interesting/2016/02/22/weak_ptr-and-event-cleanup.html
// optimistic event dispatcher v2
// usage:
{
OptimisticDispatcher<function<void (uint32_t, string)>> event;
auto subscriber = event.add([] (auto number, auto text) {
cout << "Number was " << number << " and text was " << text << endl;
});
@r-lyeh-archived
r-lyeh-archived / curve.hpp
Last active October 26, 2023 06:33
wip imgui curve
// [src] https://github.com/ocornut/imgui/issues/123
// [src] https://github.com/ocornut/imgui/issues/55
// v1.22 - flip button; cosmetic fixes
// v1.21 - oops :)
// v1.20 - add iq's interpolation code
// v1.10 - easing and colors
// v1.00 - jari komppa's original
#pragma once
// [src] https://github.com/ocornut/imgui/issues/351
// [src] https://github.com/ocornut/imgui/issues/123
// v1.0
#define IMGUI_DOCK_ENABLE_SERIALIZATION 0
// header
// #pragma once
namespace Lumix { namespace FS { class OsFile; } }
#pragma once
#include <stdint.h>
#if defined(__GNUC__)
# define clz(x) __builtin_clz(x)
# define ctz(x) __builtin_ctz(x)
#elif defined(_MSC_VER)
# include <intrin.h>
uint32_t __inline ctz( uint32_t value ) {
cd folder
gdb --args appname [your-args-here]
  • set breakpoints with b function or b file:line or b class:function
  • display stack with bt
  • change stack frame with f N
  • display threads with t number
  • change thread with t N
@r-lyeh-archived
r-lyeh-archived / mstream.cc
Created November 2, 2015 10:23
memory stream
struct membuf: std::streambuf {
membuf(char* base, std::ptrdiff_t n) {
this->setg(base, base, base + n);
}
};
membuf sbuf(base, n);
std::istream in(&sbuf);
@r-lyeh-archived
r-lyeh-archived / makegit.bat
Created October 13, 2015 10:59
generate git info for C++ inclusion
:: generate git info for C++ inclusion
:: - rlyeh, public domain
git rev-list --count --first-parent HEAD > git.hpp
set /p REVISION=<git.hpp
git rev-parse --abbrev-ref HEAD > git.hpp
set /p BRANCH=<git.hpp
echo #pragma once > git.hpp
@r-lyeh-archived
r-lyeh-archived / defer.hpp
Created October 2, 2015 19:40
defer c++11
// src: http://www.gingerbill.org/article/defer-in-cpp.html
// This code requires C++11 features such as move semantics
#pragma once
#include <functional>
namespace Impl
{
template <typename Func>
struct Defer
@r-lyeh-archived
r-lyeh-archived / httpapi.hpp
Created September 27, 2015 11:23
http api
#pragma once
#include <json11/json11.hpp>
#include <flow/flow.hpp>
// @toadd https://placeimg.com/
// @toadd http://www.pexels.com/
#include <deque>
#include <string>