Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ned14's full-sized avatar
💭
Happy happy happy!

Niall Douglas ned14

💭
Happy happy happy!
View GitHub Profile
A test file
@ned14
ned14 / CallgrindParser.cxx
Created April 24, 2013 14:49
My failing callgrind parser
/* CallgrindParser
Copyright (C) 2013 BlackBerry.
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
@ned14
ned14 / gist:6420324
Created September 3, 2013 06:28
Example Boost2Git output showing files with incorrect EOLs
-- reading ruleset...
-- done reading ruleset.
-- Opening SVN repository at /home/ned/ryppl/boost-trunk
-- preparing repositories and import processes...
-- done preparing repositories and import processes.
-- Using git executable: /home/ned/ryppl/Boost2Git/build/git/git
-- importing revision 1000
-- importing revision 2000
-- importing revision 3000
-- importing revision 4000
@ned14
ned14 / gist:6467645
Created September 6, 2013 18:10
Where my EOL fix patch to Boost2Git chokes on UTF-16
File of length 16384 contains zeros!
??<???x?m?l? ?v?e?r?s?i?o?n?=?'?1?.?0?'? ?e?n?c?o?d?i?n?g?=?'?U?T?F?-?1?6?'???>???<?!?D?O?C?T?Y?P?E? ?h?t?m?l? ?P?U?B?L?I?C? ?'?-?/?/?W?3?C?/?/?D?T?D? ?X?H?T?M?L? ?1?.?1? ?p?l?u?s? ?M?a?t?h?M?L? ?2?.?0?/?/?E?N?'??? ? ?'?h?t?t?p?:?/?/?w?w?w?.?w?3?.?o?r?g?/?T?R?/?M?a?t?h?M?L?2?/?d?t?d?/?x?h?t?m?l?-?m?a?t?h?1?1?-?f?.?d?t?d?'??? ? ?[?<?!?E?N?T?I?T?Y? ?m?a?t?h?m?l? ?'?h?t?t?p?:?/?/?w?w?w?.?w?3?.?o?r?g?/?1?9?9?8?/?M?a?t?h?/?M?a?t?h?M?L?'?>?]?>???<?h?t?m?l? ?x?m?l?n?s?=?'?h?t?t?p?:?/?/?w?w?w?.?w?3?.?o?r?g?/?1?9?9?9?/?x?h?t?m?l?'?>???<?h?e?a?d?>???<?!?-?-? ?M?a?t?h?M?L? ?c?r?e?a?t?e?d? ?w?i?t?h? ?M?a?t?h?C?a?s?t? ?E?q?u?a?t?i?o?n? ?E?d?i?t?o?r? ?v?e?r?s?i?o?n? ?0?.?8?3? ?-?-?>???<?/?h?e?a?d?>???<?b?o?d?y?>???<?m?a?t?h? ?x?m?l?n?s?=?"?h?t?t?p?:?/?/?w?w?w?.?w?3?.?o?r?g?/?1?9?9?8?/?M?a?t?h?/?M?a?t?h?M?L?"? ?d?i?s?p?l?a?y?=?"?b?l?o?c?k?"?>??? ? ?<?m?r?o?w?>??? ? ? ? ?<?m?i?>?l?<?/?m?i?>??? ? ? ? ?<?m?i?>?g?<?/?m?i?>??? ? ? ? ?<?m?i?>?a?<?/?m?i?>??? ? ? ? ?<?m?i?>?m?<?/?m?i?>??? ? ? ?
@ned14
ned14 / clang-precommit-hook-checker
Created May 30, 2014 15:29
Things a clang AST precommit hook checker should check for:
1. Warn in presence of conversion constructor not marked as explicit unless annotated.
2. Warn if move constructors or move assignment is not noexcept where all the things it calls are noexcept (I really wish this was the default in the language actually, auto-propagating noexcept).
3. Warn if you have a copy or move constructor without matching copy and move assignment, unless annotated.
4. Warn if a type satisfies the requirements of use in unordered_map but provides no hash, unless annotated.
5. Warn where pair<> is used where optional<> is better.
@ned14
ned14 / gist:9817276cc3769fe6f621
Last active August 29, 2015 14:13
Test generic hamming coding routines (SECDEC). These can fix 1 bit errors and detect two bit errors.
/* hamming_test.cpp
Test generic hamming coding routines (SECDEC). These can fix 1 bit errors and detect two bit errors.
(C) 2015 Niall Douglas http://www.nedprod.com
On my 3.9Ghz Ivy Bridge Intel 3770K:
For no intrinsics:
Calculating 4Kb: 12.06Mb/sec
Fixing 4Kb: 14.98Mb/sec
@ned14
ned14 / hamming_test.cpp
Last active April 6, 2020 20:28
More generalised C++ hamming code testing
/* hamming_test.cpp
Test generic hamming coding routines (SECDEC). These can fix 1 bit errors and detect two bit errors.
(C) 2015 Niall Douglas http://www.nedprod.com
g++ -std=c++11 -o hamming_test -O3 -fverbose-asm -Wa,-adhln hamming_test.cpp -march=ivybridge > hamming_test.S
On my 3.9Ghz Ivy Bridge Intel 3770K:
For no intrinsics:
Calculating 4Kb: 12.06Mb/sec
// Set a dispatcher as current for this thread
afio::current_dispatcher_guard h(afio::make_dispatcher().get());
// Config a write gather
std::vector<asio::const_buffer> buffers;
buffers.push_back(asio::const_buffer("He", 2));
buffers.push_back(asio::const_buffer("ll", 2));
buffers.push_back(asio::const_buffer("o ", 2));
buffers.push_back(asio::const_buffer("Wo", 2));
// Set a dispatcher as current for this thread
afio::current_dispatcher_guard h(afio::make_dispatcher().get());
// Config a write gather
std::vector<asio::const_buffer> buffers;
buffers.push_back(asio::const_buffer("He", 2));
buffers.push_back(asio::const_buffer("ll", 2));
buffers.push_back(asio::const_buffer("o ", 2));
buffers.push_back(asio::const_buffer("Wo", 2));
#include <vector>
#include <future>
#include <filesystem>
using std::future;
namespace filesystem = std::experimental::filesystem;
class data_store
{
public:
//! Disposition flags