Skip to content

Instantly share code, notes, and snippets.

@carasuca
carasuca / WormBox.cpp
Created December 24, 2017 00:01
Micro VM sandbox + CLI
typedef unsigned char byte;
byte memory[byte(-1)+1]; // global 8-bit memory pool
struct { char name[32]; void(*fn)(byte&); }
const instructions[byte(-1)+1] =
{
{ "NOP", [](byte&) {} },
@carasuca
carasuca / ImRotateDemo.cpp
Last active August 14, 2023 04:51
Rotating text and icon demo for dear imgui
#include "imgui_internal.h"
int rotation_start_index;
void ImRotateStart()
{
rotation_start_index = ImGui::GetWindowDrawList()->VtxBuffer.Size;
}
ImVec2 ImRotationCenter()
{
@carasuca
carasuca / DemoFIFO.cpp
Created February 9, 2017 07:35
FIFO versions for review. Find the bugs.
#include <vector>
#include <future>
#include <atomic>
static const size_t
buffer_size = 1024*1024,
backlog_bits = 4,
backlog = 2<<backlog_bits; // backlog powers of 2 support overflow
@carasuca
carasuca / TestIntFloat
Created July 19, 2015 19:34
Test int vs float performance with simplest operations.
#include "stdafx.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <array>
#include <vector>
#include <iostream>
#include <sstream>
#include <time.h>
std::ostringstream oss;
@carasuca
carasuca / miska_merger.cpp
Created June 10, 2014 18:00
Find matching lines in file pairs
#include <map>
#include <array>
#include <fstream>
#include <algorithm>
using namespace std;
typedef array<char, 32> buf_t;
typedef map<buf_t, buf_t> cmap_t;
@carasuca
carasuca / Resources.h
Created February 22, 2014 14:30
Plugin publishing - dynamic linking and loading
// to publish supported plugin strings
// use a single dllexport
// then just LoadLibrary and GetProcAddress in your framework
// defined in the framework.h
#define PLUGIN_PARAMS(...) PLUGIN_API const wchar_t* const * plugin_params(size_t& count) \
{ \
static const wchar_t* const params[] = \
{ __VA_ARGS__}; \
count = sizeof(params)/sizeof(wchar_t*); \
@carasuca
carasuca / MetadataJSON.cpp
Created April 18, 2013 13:51
Here's some alternative look at JSON-like metadata.
#include "stdafx.h"
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <iostream>
#include <memory>
using namespace std;
@carasuca
carasuca / A.py
Created January 15, 2013 12:07 — forked from malleor/A.py
from frames import script
@script
def A(a=3, b=5):
''' A returns bollox. '''
print 'Hello, framework.'
try:
args = {'a': 5}