You can directly delete iterators while looping through associative containers like set and map:


    for(auto itue = usersByEmail_.begin(), itue_end = usersBySecret_.end(); itue != itue_end; ) 
    {
        if ((*itue)->bDeleted())
        { 
            // NOTE We could do more cleanup work here if needed.
            itue = usersByEmail_.erase(itue);

        } else ++itue;
    }

With sequential containers like vector, you should use the erase-remove idiom. Here’s an example for my multi-indexed sets of pointers that uses a lambda to keep the code tight. runsByRank_ is of my sorted_vector type:


    runsByRank_.erase(
        remove_if(
            runsByRank_.begin(), runsByRank_.end(),    
            []( StockRun*& psr )
            { 
                // NOTE We could do more cleanup work here if needed.
                return psr->bDeleted(); 
            }
        ),
        runsByRank_.end()
    );

I’ll try to get my quick-http skeleton app updated with these best practices soon. As of now it does not include any delayed-deletion pattern.

A friend of mine asked for help to do a complicated data pivot on a few thousand rows of data.  We discussed it and agreed that we probably needed to walk each row and do an algorithmic summation on the fly.

My first instinct was to fire up Windows and dust off the old VBA cobwebs in my mind.  Fortunately that didn’t last long, and I reached for a far more comfortable friend, SQL.  The final SQL wasn’t terribly simple, but wasn’t terribly complicated either.  And it was a total linux solution, always the more pleasant solution.  And totally gui, too, for all you folks who get hives when you have to bang at a terminal.  🙂

  • Open excel sheet in LibreOffice
  • Copy columns of interest into a new sheet
  • Save As -> Text CSV
  • Create a sqlitebrowser database
  • Import the CSV file as a new table

BAM, easy, powerful, free, cheap, fast, win, win, win!

I ended up using this sql, the key is sqlite’s group_concat(), which just jams a whole query into one field, ha, boom.

SELECT a.email
 , group_concat(d.Dates) AS Dates
 , group_concat(d.Values) ASValues
FROM (select * from TestData ORDER BY email,Dates) AS a
inner JOIN TestData AS d ON d.email = a.email
GROUP BY a.email;

Then I copied the tabular result of the query, and pasted into the LibreOffice sheet, which asked me how to import.  Delimited by tab and comma, and then always recheck “select text delimiter” and use a comma.  And the cells fill right up.

All is full of light.

BAH THEY DONE FUCKED UP

  • StartCom sold out and let WoSign buy them up
  • WoSign backdated certs to get them grandfathered for some dumb reason
  • Mozilla and Google and Apple caught them and dropped support for them
  • alternativeto.net/software/startssl pointed me to Let’s Encrypt – LOOKS GOOD
  • there is also https://www.sslforfree.com/ which is a layer around Let’s Encrypt (no need? we’ll see…)

The king is dead, long live the king!

  • Whoa… it uses a BOT… from EFF.  Yay!
  • Whoa… certs are only good for 90 days!  Time to automate renewal!

Let’s take this to the wiki

 

Ubuntu has a few cross compile toolchains available, for example:

sudo apt install gcc-arm-linux-gnueabi # for arm chips
sudo apt install gcc-arm-linux-gnueabihf # for arm chips with floating point registers

Crosstool-NG is a great help in getting the tougher cross compile toolchains built. I was targeting a specific ARM 926EJ-S chipset, and the vendor had their own toolchain.

Trying to cross compile on newer versions of ubuntu was a headache though. I would get “FATAL: kernel tool old” errors from the executable on the target system, and the autotools configure option to limit kernel version (–enable-kernel=…) did not fix it.

In the end, I was able to build zlib and openssl and libwebsockets statically, with a Crosstool-NG toolchain on an older ubuntu, but had to deal with this glibc bug by explicitly specifying the system lib folder, or getaddrinfo, gethostbyname, and all other NSS based functions just plain old failed (lost some hair to that fine feature – cmon RMS and Drepper, get along better so your code doesn’t stink…):

LD_LIBRARY_PATH=/lib ./my_static_app

Details as usual on the wiki. Onwards.

Update: add these awesome ones!

https://pocoproject.org/
https://macchina.io/docs/
http://vinniefalco.github.io/beast/beast/intro/example.html

Goal: find the fastest possible C++ https library that can score an A on the SSLLabs test. Ties broken by ease of use, then by support for websockets.

Initial results (see wiki for latest…):

LIBRARY ab

MB/sec

ab

pages/sec

SSL LABS
SCORE
EASE WS? COMMENTS
apache A 3 N need to write a module, apache remains in charge of message loop (unacceptable)
libwebsockets 7 Y
proxygen 7 only easy to build on ubuntu so hasn’t been stood up on my gentoo server yet; huge kitchen sink of helpers
Simple-Web-Server  B 10 Y websockets in a seperate compatible project; may be able to leverage asio to improve score (capped by RC4); no forward secrecy
websocketpp  uses asio, specifies a “modern” mode that only allows TSL1.2
mongoose 3 messy ton of hand-crafted portability C code scared me off
onion looks like a strong C lib
libmicrohttpd GNU c lib, not sure it supports modern algos, check score…