Skip to content

Instantly share code, notes, and snippets.

@khardix
khardix / tree.cc
Created June 14, 2015 09:27
Storage tree with multiple possible views
#include <memory>
#include <list>
#include <string>
#include <stdexcept>
#include <iostream>
class Node : public std::enable_shared_from_this<Node>
{
private:
const Node *m_parent; ///< Read-only reference to parent node, modified only on node insert or release
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
ROMAN_NUMBERS = {
1000: 'M', 900: 'CM', 500: 'D', 400: 'CD',
100: 'C', 90: 'XC', 50: 'L', 40: 'XL',
10: 'X', 9: 'IX', 5: 'V', 4: 'IV',
1: 'I'
}
@khardix
khardix / games.zsh
Last active December 1, 2015 10:57
Existing game launcher script overview script
#!/bin/zsh
# Scan this directory for game launchers and present window to pick from them.
# Dependencies: awk zenity
# Game launcher format:
# Game launcher is executable text file (i.e. shell script), which contains
# one or more lines describing the game being launched. The basic format is:
#
# #GAME: Game title
@khardix
khardix / Makefile
Created January 19, 2016 12:26
C++ way to get the file descriptor number from file stream. *NIX only.
.Phony: all run clean
all: validate
run: validate
./validate
validate: validate.cpp fileno.o
clean:
ACTION!="add|change", GOTO="yubico_end"
# Yubico Yubikey Neo
ATTRS{idVendor}=="1050", ATTRS{idProduct}=="0010|0110|0111|0116|0407", \
ENV{ID_SECURITY_TOKEN}="1", RUN+="/bin/bash -c '/usr/bin/killall -9 scdaemon; sleep 1; /usr/bin/gpg2 --card-status'"
LABEL="yubico_end"
@khardix
khardix / HelloWorld.scala
Created April 18, 2016 19:08
Basic scala/swing HelloWorld application with gradle
package cz.khardix.scala
import swing._
object HelloWorld extends SimpleSwingApplication {
def top = new MainFrame {
title = "Hello World!"
contents = new Button {
text = "Click Me!"
@khardix
khardix / .latexmkrc
Last active October 4, 2016 12:34
Template for TIN
#!/usr/bin/env perl
# Configuration file for latexmk, automation script for LaTeX builds
# Use xelatex by default
$pdf_mode = 1; $postscript_mode = $dvi_mode = 0;
$pdflatex = "lualatex %O %S";
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
int main(void) {
const size_t ARRAY_LEN = 256;
int data[ARRAY_LEN]; memset(data, 0, ARRAY_LEN*sizeof(int));
#!/bin/sh
LD_PRELOAD="./divos-hack/divos-hack.so" LD_LIBRARY_PATH="." ./EoCApp
@khardix
khardix / async.py
Created October 5, 2017 07:28
AsyncIO experimentation
import asyncio
import random
async def square(stream):
async for num in stream:
yield num ** 2
async def add_two(stream):