Skip to content

Instantly share code, notes, and snippets.

@komiga
komiga / 33283-p253-prob13.patch
Created September 28, 2012 17:17
Solution correction for Gutenberg #33283 p253 prob13
--- 33283-t.tex 2012-09-28 13:08:13.725523000 -0400
+++ 33283-t-b.tex 2012-09-28 13:16:38.927198000 -0400
@@ -10173 +10173 @@
-\Item{(13)} $1.4340(0.000014t - 0.000828)$,\quad $-0.00117$,\quad $-0.00107$,\quad $-0.00097$.
+\Item{(13)} $1.4340(0.000014t - 0.001024)$,\quad $-0.00117$,\quad $-0.00107$,\quad $-0.00097$.
@komiga
komiga / gist:3965457
Created October 27, 2012 17:36
pli.format
// Unknown-purpose PLI format
// Overview
// 1. PLI format
// a. Layout
// b. Layer
// *****************************
// 1. PLI format
@komiga
komiga / data.cpp
Last active December 16, 2023 01:55
#include <cassert>
#include <new>
#include <iostream>
namespace {
template<typename... P>
struct sizeof_max_impl;
template<>
@komiga
komiga / clang-3.x-implicit-conv-bork.cpp
Last active December 15, 2015 07:59
Broke the Clangmaster. Again.
#include <cstddef>
using E = int;
using U = E[];
struct H {
E b[1]{E{1}};
U const& ref{reinterpret_cast<U const&>(b)};
operator U const&() const {
@komiga
komiga / clang-3.2-union-bork.cpp
Last active December 15, 2015 10:38
Clangmaster falls again.
struct P {};
using C = P[];
struct T {
C const& ref;
};
union U {
T t;
@komiga
komiga / timelapse.sh
Last active December 16, 2015 17:10
avconv-based timelapse script.
#!/bin/bash
# Usage:
# timelapse.sh root rate quality
#
# Join with something like:
# avconv -f image2 -r 15 -i "%05d.jpg" -r 24 -s 1680x1050 -vcodec mpeg4 -pix_fmt yuv420p -q 8 output.mp4
# Root path
@komiga
komiga / gist:5558646
Created May 11, 2013 02:11
Go home libstdc++ <chrono>, you're drunk.
#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC
/// steady_clock
struct steady_clock
{
typedef chrono::nanoseconds duration;
typedef duration::rep rep;
typedef duration::period period;
typedef chrono::time_point<steady_clock, duration> time_point;
static constexpr bool is_steady = true;
@komiga
komiga / utf8-constexpr.cpp
Last active October 17, 2020 23:25
constexpr UTF-8 decoder.
#include <cstdint>
#include <type_traits>
#include <stdexcept>
#include <iostream>
using Unit = uint8_t;
using Point = uint32_t;
namespace utf8 {
@komiga
komiga / format_constexpr.cpp
Last active March 4, 2024 21:49
constexpr format string parsing. I am fully prepared to suffer the consequences.
#include <cstddef>
#include <stdexcept>
#include <utility>
#include <string>
#include <iomanip>
#include <sstream>
#include <iostream>
using String=std::string;
@komiga
komiga / fnv1a.js
Created August 8, 2013 03:42
FNV-1a for JavaScript.
// 32-bit FNV-1a
// Will produce creepy output if input data is not ASCII
function fnv1a(str) {
var OFFSET_BASIS = 0x811c9dc5;
//var PRIME = 0x01000193;
var h = OFFSET_BASIS;
for (var i = 0; i < str.length; ++i) {