Skip to content

Instantly share code, notes, and snippets.

@JohnCoconut
JohnCoconut / gtk_tree_view.c
Last active February 24, 2018 17:10
GtkTreeView warnings
#include <gtk/gtk.h>
static void activate_main (GtkApplication *app, gpointer user_data);
static void setup_tree_view (GtkWidget *treeview);
static void populate_tree_store (GtkTreeStore *store);
int
main (int argc,
char **argv)
{
@JohnCoconut
JohnCoconut / bank.cpp
Created December 6, 2017 13:57
advent of code 2017 day 6 part 1
#include <algorithm>
#include <fstream>
#include <iostream>
#include <iterator>
#include <string>
#include <unordered_set>
#include <vector>
namespace std {
template <> struct hash<std::vector<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.

@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])
#!/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
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;
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
// 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;
---
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: false
AlignConsecutiveAssignments: false
AlignEscapedNewlinesLeft: false
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
@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) {