Skip to content

Instantly share code, notes, and snippets.

@serge-rgb
serge-rgb / clangCrash.cc
Last active February 1, 2020 22:54
clang-cl.exe crash
#include <stdlib.h>
#include <intrin.h>
int
main()
{
__m128i var = {};
// Create an unaligned _m128i pointer.
__m128i* elem = (__m128i*) ( (char*)malloc(sizeof(__m128i) + 1) + 1 );
filetype on
filetype plugin on
set nocompatible
" Setup notes:
" (git should be installed)
" git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
" or (windows): (needs curl script. see vundle site.)
" git clone https://github.com/gmarik/Vundle.vim.git %userprofile%/vimfiles/bundle/Vundle.vim
Not sure if I understood what you meant by "tracking positions", but
I'm guessing that you need clarification on how change of coordinates
works between screen coordinates and what I call "canvas space".
This is how things work as of 1.4.0 (previous versions had a 32 bit
canvas instead of 64, but fundamentally it works the same)
A milton canvas is a -2^64 X 2^64 image. In that sense, it's not
really "infinite", but 64 bits is enough so that no one will ever run
@serge-rgb
serge-rgb / moar_lambda.c
Last active April 15, 2016 01:09
moar_lambda.c
#include "sgl.h"
#include "lambda.h"
#include "test_lpp_lambda.h"
typedef int (*IntFunc) (int x, int y);
int main()
{
void* ptr = lambda(void, empty_function, () {} );
#include "sgl.h"
#include "lambda.h"
#include "test_lpp_lambda.h"
typedef float (*FloatFunc) (int x, int y);
int main()
{
// Declare my_func_1
It's tiny_jpeg as of 2015-10-22, with y flipped for OpenGL data. Refer to issue: https://github.com/serge-rgb/TinyJPEG/issues/3
In reply to this tweet https://twitter.com/ApoorvaJ/status/649276841505624064
Two things first
1) I have no idea how Papaya works. Haven't looked at the code. =)
2) A paint app is a simpler problem than an image editor. It's possible that I'm not seeing something
So, Milton has infinite undo/redo because every operation is defined declaratively.
All it does is apply "strokes". A stroke is either a brush stroke or an eraser stroke.
When displaying a drawing, it computes this:
@serge-rgb
serge-rgb / Milton SSE, first pass
Created July 24, 2015 23:11
Milton SSE first pass
I have spent a lot of time doing algorithmic optimizations on Milton's
rasterizer. I am sure there must be many more things that I can do, but right
it is at a state where it is almost Good Enough. With multi-threading enabled,
the renderer is fast enough for comfortable use on any reasonably modern CPU.
That said, I would like it to be as smooth as possible, so it is time to do
some SSE optimizations.
I determined the bottleneck by profiling with Very Sleepy; the rasterizer
spends most of its time calculating the closest point in a stroke to the pixel
I am a programmer, I don't manage people and I use time tracking to make sure I
am as effective as I can be.
Things I look for in a time tracker:
I like discretized time slots ala Pomodoro Technique, I want to click
"start" and focus on work until my tool tells me that a time unit has passed.
Then I can log what I did.
I want to measure the number of "time units". I usually go for a minimum of
@serge-rgb
serge-rgb / omp_task.cc
Created November 6, 2013 22:19
OpenMP Task based parallelism
#include<stdio.h>
#include<math.h>
static void do_something(int i) {
for (int j = 0; j < 3000; ++j)
{
sqrt(double(i*j));
}
}