Skip to content

Instantly share code, notes, and snippets.

@khardix
khardix / mako.service
Created March 18, 2019 08:51
Mako dbus activation unit file draft
[Unit]
Description=Mako notification daemon
Documentation=man:mako(1) man:makoctl(1)
PartOf=graphical-session.target
[Service]
Type=dbus
BusName=org.freedesktop.Notifications
ExecStart=/usr/bin/mako
@khardix
khardix / http_lang.pm
Created April 7, 2018 18:19
nginx perl module for processing Accept-Language HTTP header
package http_lang;
use nginx;
sub quality {
my $lang = shift;
if ($lang =~ /;q=(\d\.\d+)$/) {
return $1;
}
@khardix
khardix / download.py
Created October 6, 2017 11:26
Python AsyncIO/aiohttp downloader with progressbars
#!/usr/bin/env python3.6
import asyncio
from contextlib import closing
import aiohttp
import tqdm
async def download(session, url, progress_queue):
@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):
#!/bin/sh
LD_PRELOAD="./divos-hack/divos-hack.so" LD_LIBRARY_PATH="." ./EoCApp
#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));
@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";
@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!"
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 / 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: