Skip to content

Instantly share code, notes, and snippets.

@technic
technic / info.hpp
Created February 5, 2022 20:36
AppInfo hacks
#pragma once
#include <filesystem>
#include <fstream>
#include <giomm/desktopappinfo.h>
#include <glibmm/keyfile.h>
#include <fmt/core.h>
#include <spdlog/spdlog.h>
#include "util/string.hpp"
#include "util/format.hpp"
#include <variant>
#include <type_traits>
#include <iostream>
#include <string>
template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
template<typename T>
struct wrapper {
@technic
technic / impossible-case-bug.idr
Created June 28, 2021 16:08
Demonstration of issue in idris2
module Main
import Data.Vect
||| View for splitting a vector in half, non-recursively
public export
data Split : Vect n a -> Type where
SplitNil : Split []
SplitOne : Split [x]
||| two non-empty parts
SplitPair : {n : Nat} -> {m : Nat} ->
@technic
technic / custom.ui
Created November 2, 2020 18:54
LyX export toolbar button
# -*- text -*-
# file default.ui
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.
# author John Levon
# Full author contact details are available in file CREDITS.
@technic
technic / doit_completion.ps1
Last active September 6, 2020 20:51
Draft of powershell Tab completion for pydoit
# doit completion
function WriteLog([string] $Message) {
$timestamp = Get-Date -Format HH:mm:ss
"[$timestamp] $Message" | Out-File -Append "${env:Home}\tablog.txt"
}
Register-ArgumentCompleter -CommandName doit -Native -ScriptBlock {
param(
[String] $wordToComplete,
@technic
technic / README.md
Created October 28, 2019 16:40
oh-my-posh workaround

The old winpty has a bug, when running terminal in VS Code: after executing MinGW command escape sequencies are broken.

We can disable those by modifying theme file in a following way

    if ($env:ConEmuANSI -eq "ON") {
        $prompt += Set-CursorForRightBlockWrite -textLength ($timestamp.Length + 1)
        $prompt += Write-Prompt $timeStamp -ForegroundColor $sl.Colors.PromptForegroundColor    
 }
@technic
technic / main.cpp
Created September 14, 2019 20:15
TypeList
#include <iostream>
#include <limits>
#include <type_traits>
/**
* @brief Keep list of types provided by variadic template arguments.
* Provide constexpr function to get index of specific type in the list.
*/
template <typename... Ts> class TypeList {
@technic
technic / ipywidgets_sugar.py
Created September 12, 2019 12:54
ipywidgets decorator with continuous_update = False
from ipywidgets import interact
def interact_delayed(**kwargs):
def decorator(f):
obj = interact(f, **kwargs)
for child in obj.widget.children:
if hasattr(child, 'continuous_update'):
child.continuous_update = False
return obj
return decorator
@technic
technic / slides.html.jinja2
Last active September 8, 2019 14:24
Jupyter slides template with code toggle button
{%- extends 'slides_reveal.tpl' -%}
{% block input_group -%}
<div class="input_wrapper">
{{ super() }}
</div>
{% endblock input_group %}
@technic
technic / watch.py
Created September 5, 2019 14:56
Watch jupyter notebook changes and LiveReload slides
#!/usr/bin/env python
import sys
import os
import time
import logging
import argparse
import subprocess
import threading
import webbrowser