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
@ned14
ned14 / pegasus_mail_to_mbox.py
Created December 30, 2016 02:13
Converts old, corrupted Pegasus Mail mail stores into portable mboxo or maildir stores suitable for import into almost any other mail client
#!/usr/bin/python3
# Converts Pegasus Mail v4.x .PMM files into Unix mbox files using lots
# of heuristics to repair any corruption in the Pegasus mail store
# (the "Unix mbox" feature of Pegasus produces malformed Unix mbox files)
# (C) 2016 Niall Douglas http://www.nedprod.com/
# File created: Dec 2016
#
# Best used with python 3.6, anything older has a less able email and
# mailbox python modules
@ned14
ned14 / mailinabox.sh
Last active April 30, 2016 21:43
mailinabox on lxc
cd /root
aptitude install curl git
git clone https://github.com/ned14/mailinabox.git
cd mailinabox
DISABLE_FIREWALL=1 setup/start.sh
(Use usual@nedprod.com for the email and mail.nedprod.com for the server)
cd /home/user-data/ssl/nedprod.com
nano private_key.pem
(Use nedprod.com cert private key)
chmod og-rwx private_key.pem
@ned14
ned14 / v2_gen2.cpp
Created February 4, 2016 15:09
Improved enum bitfield thanks to feedback from Boost dev list
#include <stdio.h>
#include <type_traits>
#define BOOST_CXX14_CONSTEXPR constexpr
template<class Enum> struct bitfield : public Enum
{
using enum_type = typename Enum::enum_type;
using underlying_type = std::underlying_type_t<enum_type>;
private:
@ned14
ned14 / v2.cpp
Created February 3, 2016 08:30
AFIO v2 style of C++ bitfields
#include <stdio.h>
#define BOOST_CXX14_CONSTEXPR constexpr
//! Constexpr bitwise flags support
template<class Derived, class T = unsigned> class bitwise_flags
{
T _value;
public:
//! The underlying type
@ned14
ned14 / v1.cpp
Created February 3, 2016 08:29
AFIO v1 style of C++ bitfields
#include <stdio.h>
#define BOOST_AFIO_DECLARE_CLASS_ENUM_AS_BITFIELD(type) \
inline constexpr type operator&(type a, type b) \
{ \
return static_cast<type>(static_cast<size_t>(a) & static_cast<size_t>(b)); \
} \
inline constexpr type operator&=(type a, type b) \
{ \
return static_cast<type>(static_cast<size_t>(a) & static_cast<size_t>(b)); \
@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 / 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 / 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:
A test file
/*
Linux ext4:
743004324000
778425979000 (+4.76%)
Win8.1 NTFS:
17565970224000
17890031536128 (+1.8%)
*/