MadMonkey

1

votes
0

answer
280

views

What does the Quill.js formats()-method do?

I'm trying to implement a custom style for Quill.js that would allow nested and (hopefully) overlapping regions in the text. I'm not yet sure how to do the overlapping, but the nesting seems to be possible. I've done the usual extending of a blot kind of thing (in typescript): let Inline = Quill.imp...
MadMonkey
1

votes
0

answer
184

views

Quilljs: TypeError when deriving custom Attributor

I'm trying to implement a potentially overlapping attribute as in this question: Overlapping Inline Annotations with Quill and this issue: https://github.com/quilljs/quill/issues/1216 Only difference is that I'm using TypeScript. This is an excerpt of my code: import Quill from 'quill'; import Parch...
MadMonkey
1

votes
1

answer
104

views

XmlSerializer & Activator.CreateInstance()

Okay, we all know that it is not possible to use the XmlSerializer for classes without a parameterless constuctor as the deserializer will create the object and set all properties. However, by using Activator.CreateInstance() one can instanciate classes without a parameterless constructor. For examp...
MadMonkey
1

votes
1

answer
853

views

effective bounds checking on ring buffer

as some might have noticed I'm trying to implement a ring buffer. I want to have a certain amount of safety measures in the data structure while not losing too much efficiency. My current solution implements two types of counters, an index, which is a direct offset into the buffers memory and a sequ...
MadMonkey
1

votes
6

answer
1.1k

views

Converting {integer} to f32 in Rust

I want to convert a value from {integer} to f32: struct Vector3 { pub x: f32, pub y: f32, pub z: f32, } for x in -5..5 { for y in -5..5 { for z in -5..5 { let foo: Vector3 = Vector3 { x: x, y: y, z: z }; // do stuff with foo } } } The compiler chokes on this with a type mismatch error (expecting f32...
MadMonkey
4

votes
1

answer
725

views

Implementing insert() on a container with move semantics when rvalue does not implement move

I'm trying to implement a container that provides insert methods with both copy and move semantics. The implementation is something like this: template class Buffer { // lots of stuff ommitted here ... // copy semantics Buffer::Iterator push(const T& item) { Buffer::Iterator head = push(); *head =...
MadMonkey
3

votes
2

answer
350

views

Setting size of custom C++ container as template parameter vs constructor

I've written a fixed-size container (a ring buffer, to be exact) in C++. Currently I'm setting the size of the container in the constructor and then allocate the actual buffer on the heap. However, I've been thinking about moving the size parameter out of the constructor and into the template. Going...
MadMonkey
8

votes
1

answer
10.1k

views

JAVA : How to create .PNG image from a byte[]?

I have seen some code source, but I do not understand... I use Java 7 Please, how to convert a RGB (Red,Green,Blue) Byte Array (or something similar) to a .PNG file format ? Example from an array that could represent 'a RGB pixel' : byte[] aByteArray={0xa,0x2,0xf}; Important Aspect : I try to genera...
MadMonkey
4

votes
1

answer
580

views

std::conditional in nested template class

I'm trying to implement a RingBuffer in the style of the STL. This means I'm also implementing an iterator for it that has to work as either const or non-const. This is just the iterator part: #include #include template class RingBuffer { public: class Iterator; // actual RingBuffer implementatio...
MadMonkey
5

votes
2

answer
156

views

CSS: conditional formatting based on class of adjacent elements

I have a few adjacent span tags that are styled to be display: inline-block; like so: span.mark { background-color: yellow; display: inline-block; vertical-align: center; border-width: 1px; border-color: red; border-style: solid; border-radius: 3px; } Some standalone test. Some continuous el...
MadMonkey
3

votes
3

answer
116

views

detecting invalid iterators for a ring buffer

I'm trying to implement a ring buffer (or circular buffer). As with most of these implementations it should be as fast and lightweight as possible but still provide enough safety to be robust enough for production use. This is a difficult balance to strike. In particular I'm faced with the following...
MadMonkey