Skip to content

Instantly share code, notes, and snippets.

@boatilus
boatilus / markdown-comparison.md
Created April 11, 2019 00:39
JavaScript Markdown Parser Size Comparison

| markdown-it | 104kb | | showdown | 79kb | | marked | 23kb |

Keybase proof

I hereby claim:

  • I am boatilus on github.
  • I am ovao (https://keybase.io/ovao) on keybase.
  • I have a public key ASBNTfSbut9LBqYJHEu67Mfov5UEGCfJV_f9qiFZ4R7Fxgo

To claim this, I am signing this object:

@boatilus
boatilus / sso_string.cpp
Created October 19, 2016 02:35
Basic SSO string
#include <cassert>
#include <cstddef>
#include <string>
template <int8_t len>
class string {
private:
char arr[len + 1];
public:
#include <tuple>
#include <type_traits>
#include <cassert>
template <class T, class... TArgs> decltype(void(T{std::declval<TArgs>()...}), std::true_type{}) test_is_braces_constructible(int);
template <class, class...> std::false_type test_is_braces_constructible(...);
template <class T, class... TArgs> using is_braces_constructible = decltype(test_is_braces_constructible<T, TArgs...>(0));
struct any_type {
template<class T>
@boatilus
boatilus / ltoa.c
Created April 25, 2014 22:29
Public domain ltoa implementation
/*
** LTOA.C
**
** Converts a long integer to a string.
**
** Copyright 1988-90 by Robert B. Stout dba MicroFirm
**
** Released to public domain, 1991
**
** Parameters: 1 - number to be converted
@boatilus
boatilus / gist:7016354
Last active December 25, 2015 17:49
Dynamically-resizing vector implementation around JavaScript typed arrays
define [], ->
return class Vector
constructor: (@type, @wordLength, initialSize) ->
@buffer = new ArrayBuffer ((initialSize or 10) * wordLength) / 8
@view = new window[type + wordLength + 'Array'] @buffer
type: ''
buffer: null
view: null
@boatilus
boatilus / gist:4186981
Created December 2, 2012 04:36
Statically-checked std::array set()
namespace stdx {
template <size_t position, typename T, size_t size>
void set(std::array<T, size>& arr, const T& value) noexcept {
static_assert(position < size, "index out of bounds");
arr[position] = value;
}
}