Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am komiga on github.
* I am komiga (https://keybase.io/komiga) on keybase.
* I have a public key ASAbrlZ43jkqesSVChP6z9Lt5WTCVFhaGMvWuFl4wEvFJQo
To claim this, I am signing this object:
@komiga
komiga / spreadsheet-proportional-workload-distribution.c
Last active May 23, 2017 00:27
Excel/Google Sheets: Proportional distribution of unassigned workload to personnel based on their weekly availability (that is, ensures booked workload is distributed fairly and that the final assigned workload adds up exactly to the booked workload).
=arrayformula(
trunc(WorkEng * (AvailEngRange / AvailEng))
+ sort(
arrayformula(if(
row(offset(Z:Z, 0,0, rows(PersonnelNameRange),1))
<= (WorkEng - sum(trunc(WorkEng * (AvailEngRange / AvailEng))))
, 1, 0)),
sort(
arrayformula(
row(offset(Z:Z, 0,0, rows(PersonnelNameRange),1))
@komiga
komiga / opengl-ffp-in-opengl-3.3.cpp
Last active March 23, 2017 00:43
A simplified look at what FFP OpenGL could do when implemented in terms of core OpenGL 3.3.
// A simplified look at what FFP OpenGL could do when implemented in terms of
// core OpenGL 3.3.
struct Position {
float x, y;
};
struct Color {
float r, g, b;
@komiga
komiga / data_member_addressing.c
Last active December 1, 2015 00:23
Example of memory addressing in C
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
struct S {
// This is complicated by padding, but:
// NB: sizeof(int32_t) = 4 bytes (32 bits)
// base_address + 0
@komiga
komiga / match_adaptor.cpp
Created November 3, 2014 17:50
tinch_pp match_adaptor to avoid bind() blah blah blah
#include <cassert>
#include <type_traits>
#include <memory>
#include <iostream>
template<class> struct is_smart_pointer : std::false_type {};
template<class T> struct is_smart_pointer<std::shared_ptr<T>> : std::true_type {};
template<class T> struct is_smart_pointer<std::unique_ptr<T>> : std::true_type {};
@komiga
komiga / erl_list.patch
Created November 3, 2014 07:36
erl_list bind patch
diff --git a/tinch_pp/erl_list.h b/tinch_pp/erl_list.h
index 35bcc73..e440657 100644
--- a/tinch_pp/erl_list.h
+++ b/tinch_pp/erl_list.h
@@ -30,6 +30,8 @@
#include <cassert>
#include <functional>
+using namespace std::placeholders;
+
@komiga
komiga / list_matcher_adaptation.cpp
Created November 3, 2014 05:38
assign_match mumbo jumbo for tinch_pp
#include <type_traits>
#include <memory>
template<class>
struct is_smart_pointer : std::false_type {};
template<class T>
struct is_smart_pointer<std::shared_ptr<T>> : std::true_type {};
@komiga
komiga / binpack.py
Created February 6, 2014 15:23
Rotating binpacker in Python.
import sys
import math
EDGE_NONE = 0
EDGE_TOP = 1
EDGE_BOTTOM = 2
EDGE_LEFT = 3
EDGE_RIGHT = 4
#include <bitset>
#include <vector>
#include <chrono>
#include <iostream>
using namespace std::chrono;
using hrc = std::chrono::high_resolution_clock;
template<class T>
@komiga
komiga / bad-seek.cpp
Last active December 25, 2015 21:58
Bad seek behavior with libc++ (svn, rev 192988). There's a patch down there.
#include <cassert>
#include <streambuf>
#include <iostream>
// Dummy stream buffer for testing.
// basic_streambuf defines seekoff() and seekpos() (virtuals) to
// return pos_type(off_type(-1)), which indicates a seek failure, so
// we don't really have to define them, but I've done so for the sake
// of pedantry.