Skip to content

Instantly share code, notes, and snippets.

@JohnCoconut
JohnCoconut / cmake_cheet_sheet.md
Last active April 1, 2020 09:27
cmake cheat sheet

add compile options

if (MSVC)
    # warning level 4 and all warnings as errors
    add_compile_options(/W4 /WX)
else()
    # lots of warnings and all warnings as errors
    add_compile_options(-Wall -Wextra -pedantic -Werror)
endif()
@JohnCoconut
JohnCoconut / sourcetrail-install.md
Created November 19, 2019 03:16
SourceTrail install instruction

on Fedora 31

 sudo dnf install boost-devel boost-static

build error

[388/391] Linking CXX executable app/sourcetrail_indexer
@JohnCoconut
JohnCoconut / asio_async_wait.cpp
Last active January 21, 2019 14:52
Async wait from asio steady timer
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <iostream>
namespace asio = boost::asio;
void bind_handler(const boost::system::error_code& ec, asio::steady_timer& t, int count, int instance_tag)
{
if (!ec) {
if (count > 0) {
---
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: false
AlignConsecutiveAssignments: false
AlignEscapedNewlinesLeft: false
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
// Create a unique pointer
auto p1 = std::make_unique<int>(42);
// Error to copy
auto p2 = p1;
// Ok to move
auto p2 = std::move(p1);
// After being moved, p1 is guaranted be equal to nullptr
assert(p1 == nullptr);
// It's a runtime error to access p1
int x = *p1;
Chapter Sections Algorithms Progress
1. Core Searches 1.1 Breath First Search
1.2 Depth First Search
1.3 Undirected Depth First Search
2. Other Core Algorithms 2.1 Topological Sort
2.2 Transitive Closure
2.3 Lengauer-Tarjan Dominator Tree
module gtkdemo.SpinnerDemo;
import std.random : randomSample;
import std.conv : to;
import gio.Application : GioApplication = Application;
import gtk.Application;
import gtk.ApplicationWindow;
import gtk.TreeView;
import gtk.ListStore;
#!/usr/bin/env python3
import random
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GObject
class TreeView(Gtk.TreeView):
def __init__(self):
# model
@JohnCoconut
JohnCoconut / CellRendererSpinner.py
Created May 10, 2018 07:16
Gtk.CellRenderSpinner in python
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GObject
class Window(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title='CellRendererSpinner')
self.model = Gtk.ListStore.new([bool, int])
@JohnCoconut
JohnCoconut / replcxx.md
Last active March 6, 2018 10:23
preview for replcxx

Read Evaluate Print Loop ++

demo

Build Status

A small, portable GNU readline replacement for Linux, Windows and MacOS which is capable of handling UTF-8 characters. Unlike GNU readline, which is GPL, this library uses a BSD license and can be used in any kind of program.