The Lone C++ Coder's Blog from The Lone C++ Coder's Blog
Turns out I made some unnecessary “work” for myself when I tried to add support for command history to inf-mongo. As Mickey over at Mastering Emacs points out in a blog post, comint mode already comes with M-n and M-p mapped to comint-next-input and comint-previous-input. And of course they work in inf-mongo right out of the box. I still prefer using M-up and M-down, plus I learned a bit about sparse key maps and general interaction with comint-mode.Extending inf-mongo to support scrolling through command history
The Lone C++ Coder's Blog from The Lone C++ Coder's Blog
I’m spending a lot of time in the MongoDB shell at the moment, so of course I went to see if someone had built an Emacs mode to support the MongoDB shell. Google very quickly pointed me at endofunky’s inf-mongo mode, which implements a basic shell interaction mode with MongoDB using comint. We have a winner, well, almost. The mode does exactly what it says on the tin, but I wanted a little more, namely being able to scroll through my command history. Other repl modes like Cider have this functionality already, so it couldn’t be too hard to implement, could it?
Long Man of Wilmington Walk
Christof Meerwald from cmeerw.org blog
Went for a walk from Berwick via the Long Man of Wilmington, Friston Forest, East Dean and the Seven Sisters to Seaford, see GPS data and some pictures: here and here.
Testing java slf4j over log4j logging in JUnit using SLF4J Test
Testing logging on failure paths has two problems:
- It is hard to get the log message text
- The logger outputs to the test log
Code to test
public class Sut {
public String perform() {
getLog().debug("In perform");
return "Hello world";
}
}
My clunky PowerMock Solution
My approach was problematic as it required the use of PowerMock which is as powerful as nitroglycerin.
Test Code
@RunWith(PowerMockRunner.class)
@PrepareForTest({LoggerFactory.class})
public class SutTest {
@Test
public void testPerform() {
mockStatic(LoggerFactory.class);
Logger mockLog = mock(Logger.class);
when(LoggerFactory.getLogger(any(Class.class))).thenReturn(mockLog);
assertEquals("Hello world", new Sut().perform());
verify(mockLog, times(1)).debug(startsWith("In perform"));
}
}
Elegant SLF4j Test Solution
The slf4j-test project by RobElliot266 provides a logger which stores messages and so can be asserted against.
POM Setup
Add the following to your dependencies
<dependency>
<groupId>uk.org.lidalia</groupId>
<artifactId>slf4j-test</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>
To ensure that this logger is used during tests only and that it takes precedence over the production logger in the test class path ensure the test logger is the first logger mentioned in the dependencies block and has a test scope.
As an additional measure you can explicitly exclude the production logger from the test class path:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<classpathDependencyExcludes>
<classpathDependencyExcludes>org.slf4j:slf4j-jdk14</classpathDependencyExcludes>
</classpathDependencyExcludes>
</configuration>
</plugin>
Test Code
public class SutTest {
@Test
public void testPerform() {
assertEquals("Hello world", new Sut().perform());
assertEquals("Testing", logger.getLoggingEvents().get(0).getMessage());
}
}
Much thanks to RobElliot266 for an neat solution to a problem that has been bugging me for a while.
ACCU C++ Countdown Pub Quiz
Jon Jagger from less code, more software
The ACCU conference is one of the highlights of my year. I ran a brand new session, a C++ Pub Quiz with an emphasis on fun and interaction, based loosely on the popular UK TV game show Countdown.In the TV version, contestants play individually and have 30 seconds to find the longest word using only a small set of letters. In this version, contestants play in teams, and have ~7 minutes to write the smallest valid C++ program containing a small set of tokens.
For example, if the tokens were:
catch -> [ ; -- foobar operatorThen a winning program (53 character program) might be:
class c { c operator->(){ foobar: try{ } catch(c x[]){ x--; } } };
We used cyber-dojo with some custom C++17 start-points which automatically told you your program's size and score. The rules were as follows:
- The judges decision was final
- Only non-whitespace characters were counted
- Programs had to compile
- Warnings were allowed
- Extra tokens were allowed
- Each token has to be a single whole token. For example the . token had to be the member access token; you could not use ... ellipsis or 4.2 floating point literal
The winners and the tokens were as follows (can you find smaller programs?)
Round 1: snakes, 75 character program,
dynamic_cast
snafu
+=
return
switch
final
Round 2: wolves,koalas tied, 54 character program,
catch
;
foobar
operator
--
[
Round 3: frogs, 62 character program,
else
~
default
->
using
foobar
0x4b
Round 4: tigers, 44 character program,
string
include
for
auto
template
42
Round 5: pandas, tigers tied, 82 character program,
virtual
typename
x
reinterpret_cast
static_cast
30ul
Round 6: wolves, 64 character program,
constexpr
override
goto
wibble
.
this
The raccoons and lions won the conundrum rounds.
The result was very close.
In 3rd place snakes with 481 points.
In 2nd place alligators with 488 points.
In 1st place tigers with 495 points.
A big thank you to my co-presenter Rob Chatley, to all the contestants for being such good sports, and to Bloomberg for sponsoring the Quiz.
A Magical new World — Thoughts of a first time ACCU attendee.
Samathy from Stories by Samathy on Medium
I went to my first ACCU Conference last week. It was great.
I’d heard about ACCU from Russel Winder several months ago. He recommended I check out the conference (for which hes on the programme board) since I’m a fan and user of the C and C++ languages.
I arrived in Bristol on Tuesday excited for what the week held.
This post contains a section about the talks and a section about my experience at the bottom.
Be aware that some of the photos might not look as good on here as they should, I think Medium has compressed them a bit. All my photos should be online shortly.
The Talks
We started the conference proper with a fantastically explosive keynote delivered by Russ Miles who jumped on stage to deliver a programming parody of Highway to Hell accompanied by his own guitar playing.
His keynote was all about modern development and how most of a programmer’s tools currently just shout information at the programmer, rather than actually helping.
Later on the Wednesday I headed into a talk from Kevlin Henny that totally re-jigged how I think about concurrency. Thinking outside the Synchronisation Quadrant was wonderfully entertaining, with Kevlin excitedly bouncing across the floor.
A fantastically engaging speaker.
Wednesday’s talks continued with several other good talks and a number of great lightning talks too.
Finalising with the welcome reception where delegates gathered in the hotel for drinks, food and conversation.
It was here that I really got the chance to socialise with a good few people, including Anna-Jayne and Beth, who I’d been excited about meeting since I found out they were going to be there!
Thursday began with an interesting keynote about the Chapel parallel programming language. The talk has encouraged me to try the language out and I’ll certainly be having a good play with that soon.
Thursday’s stand out talks included Documentation for Developers workshop by Peter Hilton. I really enjoyed the workshoppy style that Peter used to deliver the talk. He got the audience working in groups, talking to each other and essentially complaining about documentation. He finished with suggesting a method of writing docs called Readme Driven Development as well as other suggestions.
The other talk on Thursday which I really loved was “The C++ Type System is your Friendâ€. Hubert Matthews was a great speaker with clear experience in explaining a complex topic in an easier to understand fashion.
I can’t say I understood everything, but I certainly liked listening to Hubert speak.
Thursday evening I headed out for dinner with Anna-Jayne and Beth before heading back to my accommodation to write up a last minute talk for Friday.
My talk was covering Intel Software Guard Extensions — Russel announced that there was an open slot on Friday for a 15 minute topic and I took the chance to speak then.
Friday began with a curious but thought provoking talk from Fran Buontempo called AI: Actual Intelligence.
I’m not entirely sure what the take away from the talk was intended to be, but nonetheless it was interesting!
Friday morning was full of 15 minute talks. A format I think is wonderful.
I really loved that amongst the 90 min talks throughout the rest of the week, there was time for these quick fire shorter talks too that were still serious technical talks (unlike the 5min lightning talks).
The talks I went to see were:
- The missing piece of the continuous integration puzzle — what to do with all those test failures? — Greg Law
- Named Parameters — Odin Holmes — Using Template magic to impliment named params in C++. I loved this talk and fully intend to investigate the idea!
- Passwords. Are. Not. Hard! — Dom Davis — A hilarious rant about how nonsensical password handling is.
At Friday lunch time I took part in a bit of an unplanned workshop on sketch noting with Michel Grootjans. It was essentially an hour of trying to make our notes prettier!
It was a lot of fun.
Friday was the conference dinner — a rock themed night of fun and frivolities.
This was by far the high point of the conference for me.
It offered a great evening of meeting people and having a lot of fun.
I loved how everyone loosened up and spoke to anyone else there.
I met a whole bunch of people, and got on super well with a few people who I would like to consider friends now.
ACCU made it easy to get to know people too by forcing everyone who isn't a speaker to move tables between each meal course. Its a great idea!
Saturday’s talks started with a really fun talk from Arjan van Leeuwen about string handling in C++1x. Covering the differences between char arrays and std::strings and how best to use them. As well as tantalising us with a C++17 feature called std::string_view (immutable views of a string).
Later I watched a talk from Anthony Williams and another from Odin, both of which went wildly over my head, but all the same I gained a few things from both of them.
Finishing off the conference was a brilliant keynote from renowned speaker and member of the ISO C++ standards committee Herb Sutter.
Herb introduced a new feature of C++ that he may be proposing to the standards committee.
He described a feature allowing one to create meta-classes.
Essentially, one could describe a template of a class with certain interfaces, data and operators. Then, one could implement an instance of that class defining all the functionality of the class.
Its essentially a way to more cleanly describe something akin to inheritance with virtual functions.
I highly suggest you try to catch the talk, since it was so interesting that even an hour or so after the talk there was still quite a crowd of people gathered around Herb asking him questions.
The Conference Environment
As a first time ACCU attendee — this wouldn't be a useful blog post without a few words about the environment at the conference.
As most of my readers know, I’m a young transwomen, so a safe and welcome environment is something that I very much appreciate and makes a huge difference to my experience of an event.
Its something thats super hard to achieve in a world like software development where the workforce are predominantly male.
I’m glad to say that ACCU did a great job of creating a safe and welcoming space. Despite being predominantly male as expected, everyone I encountered was not only friendly and helpful, but ever so willing to go out of their way to make me feel welcome and comfortable.
Everyone I met simply accepted me for me and didnt treat me any other way than friendly.
I would suggest that offering diversity tickets to ACCU would help make me feel even better there, since I’d feel better with a more diverse set of delegates.
I was especially comforted by Russel mentioning the code of conduct, without fail, every day of the conference. As well as one of the lightning talks being, delivered by a man, taking the form of a spoke word-ish piece praising the welcoming nature of ACCU and calling for the maintenance of the welcoming nature to all people in the community, not just people like himself.
I’d like to especially mention Julie and the Archer-Yates team for checking up on my happiness throughout the conference, they really helped me feel safe there.
I think there still could be work to do about making the conference a good place for younger adults — I was rather overwhelmed by the fact that everyone seemed older than me and clearly had a better idea of how to conduct themselves in the conference setting.
However, I think the only real way of solving this problem would be to make the conference easier to access to younger people (i,e cheaper tickets for students, its still super expensive) which wouldn't always be possible. Additionally, the inclusion of some simpler, easier to understand talks would have been great. Lots of the talks were very complicated and easily got to a level that was way over my head.
Thanks to everyone who helped me feel welcome at ACCU — including but not limited to Richard, Antonello, Anna-Jayne, Beth, Jackie, Fran, Russel and Odin.
In conclusion
ACCU was a fantastic experience for me. I would highly recommend it to anyone interested in improving their C and C++ programming skills as well as general programming skills.
I’ll certainly be heading back next year if I can, and am happily a registered ACCU member now!
Baldock – Royston Walk
Christof Meerwald from cmeerw.org blog
Went for a nice walk in Hertfordshire from Baldock to Royston (visiting 5 churches on the way), see GPS data and some pictures: here and here.
The challenges of preserving digital content
The Lone C++ Coder's Blog from The Lone C++ Coder's Blog
A problem archivists have been bringing up for a while now is that with the majority of content going digital and the pace of change in storage mechanisms and formats, it’s becoming harder to preserve content even when it is not what would be considered old by the standards of other historic documents created by humanity. Case in point - the efforts required to preserve even recent movies as described in this article on IEEE Spectrum.Installing a Java 8 JDK on OS X using Homebrew
The Lone C++ Coder's Blog from The Lone C++ Coder's Blog
Update II - 2019-05-07: It looks like due to the recent licensing changes, the Java 8 JDK that brew used is not directly accessible anymore and likely behind some kind of paywall. The installation method described below will still work as it uses the non-versioned java cask, which installs the latest version of OpenJDK. _Update: The title of this post isn’t quite correct as using the homebrew cask mentioned in this blog post will install the current major version of the Oracle JDK.Beaconsfield – Gerrards Cross Walk
Christof Meerwald from cmeerw.org blog
Went for a nice spring walk from Beaconsfield to Gerrards Cross via Common Wood, Penn Wood and Hodgemore Wood, see some pictures and GPS data.