Skip to content

Instantly share code, notes, and snippets.

View koraa's full-sized avatar

Karolin Varner koraa

View GitHub Profile
@koraa
koraa / unix-benchmark.txt
Created February 16, 2020 09:01
huniq2 uniq optimization pass one
repetitions implemetation seconds memory/kb
5 0original 2.88 29484
5 1anyhow 2.91 29544
5 2iolock 2.97 29544
5 3noalloc 2.75 29520
5 4singlehash 2.51 29628
5 5ahash 2.06 29608
5 6fxhash 1.84 29536
5 7copyelision 1.51 29736
5 8cleanup 1.87 29468
fn main() {
let mut r = vec![1,2,3];
let mut it = r.iter();
println!("{:?}", it.next());
println!("{:?}", it.next_back());
println!("{:?}", it.next());
println!("{:?}", it.next());
}
// OUTPUT:
/// Recursively flatten an iterator and return
/// Args:
/// seq – The sequence to flatten
/// predicate – A function that is applied to each element in seq
/// to determine whether that element should also be flattened.
/// `(val) => val instanceof Array` would only flatten arrays, while
/// `(val) => val[Symbol.iterator] !== undefined` would flatten any
/// iterable, but should never be used because it will cause an infinite
/// loop flattening strings (strings are sequences of single char strings
/// which are sequences of itself...).
@koraa
koraa / minmax_crashreport
Created November 9, 2015 10:23
VS Min/Max crash
Stacktrace:
> inexor.exe!_VCrtDbgReportW(int nRptType, void * returnAddress, const wchar_t * szFile, int nLine, const wchar_t * szModule, const wchar_t * szFormat, char * arglist) Line 481 C++
inexor.exe!_CrtDbgReportW(int report_type, const wchar_t * file_name, int line_number, const wchar_t * module_name, const wchar_t * format, ...) Line 273 C++
[External Code]
inexor.exe!vec::min(const vec & o) Line 156 C++
inexor.exe!genclipplanes(const cube & c, const ivec & co, int size, clipplanes & p, bool collide) Line 1220 C++
inexor.exe!getclipplanes(const cube & c, const ivec & o, int size, bool collide, int offset) Line 22 C++
from _CrtDbgReportW on were somewhere inside error reporting code probably. however checking the values of the variables inside that code reveals an error inside algorithm:4178 which is:
@koraa
koraa / random-bench.cc
Last active December 13, 2022 08:16
C++ Random Engine Benchmark
// LICENSE: CC-0
// © 2015 by Karolin Varner
// invoke: $ echo boost::random::taus88 boost::random::minstd_rand0 boost::random::minstd_rand boost::random::mt11213b boost::random::mt19937 boost::random::mt19937 std::default_random_engine std::minstd_rand std::minstd_rand0 std::mt19937 std::mt19937_64 | tr ' ' '\n' |while read en; do clang -lboost_random -lboost_system -lstdc++ --std=gnu++11 -DENGINE="$en" -Wall -Wextra bench.cc -o bench; ./bench; done | sort -k2 | column -t
#include <boost/uuid/seed_rng.hpp>
#include <boost/random/taus88.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/linear_congruential.hpp>
#include <boost/random/uniform_int_distribution.hpp>
#include <boost/random/uniform_real_distribution.hpp>
@koraa
koraa / author-stat.sh
Created August 1, 2014 02:07
List the lines of code per author in the current head
#! /bin/bash
# List the amount of code per author in the current HEAD
git ls-files "$@" | xargs -l1 git blame -s -- | awk '
function get_author(commit) {
author = commit_map[commit]
if (author == "") {
cmd = "git show -s --pretty=format:%ae " commit
cmd | getline author
commit_map[commit] = author
@koraa
koraa / gist:6057756
Last active December 20, 2015 02:39
Typedef Maniacs
// Problem:
// * Name und typ sind auf head und bottom aufgeteilt
// * Es werden zwei typen declariert
//
struct a_ {
int a;
char b;
double c[17];
};
typedef struct a_ A;
@koraa
koraa / liferea-export-beautified-opml.xml
Created March 22, 2013 14:12
Liferea exported OPML and beautified with xmllint --format
<?xml version="1.0"?>
<opml version="1.0">
<head>
<title>Liferea Feed List Export</title>
</head>
<body>
<outline title="/" text="/" description="/" type="folder">
<outline title="Newz" text="Newz" description="Newz" type="folder">
<outline title="Science" text="Science" description="Science" type="folder">
<outline title="NYT &gt; Space &amp; Cosmos" text="NYT &gt; Space &amp; Cosmos" description="NYT &gt; Space &amp; Cosmos" type="rss" xmlUrl="https://www.nytimes.com/services/xml/rss/nyt/Space.xml" htmlUrl="http://www.nytimes.com/pages/science/space/index.html?partner=rss&amp;emc=rss"/>
@koraa
koraa / 1mul1.c
Created November 29, 2012 13:17
C Exercise generating an aligned/monospaces ASCII table of the 101
/**
* Run and compile:
*
* gcc -o 1m1 *.c --std=gnu99 -O3 && ./1m1 20 20
*
* Challenge:
* Print a table where each position (x|y) is defined like:
*
* {x*y | x=[1;9], y=[1,9]}
*