Skip to content

Instantly share code, notes, and snippets.

#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <signal.h>
struct termios orig;
void term_cursor_setpos(int row, int col) {
@trnila
trnila / hard_spaces.sh
Created May 19, 2019 16:40
Fix hardspaces for czech language in LaTeX
#!/bin/sh
awk -i inplace -f - "$1" << 'AWK'
BEGIN {
skip = 0
IGNORECASE=1
}
/\\begin{(minted|lstlisting|tikzpicture)}/ {
skip = 1
}
@trnila
trnila / cfdns-edit
Created June 2, 2018 07:10
Update cloudflare DNS zone in your editor
#!/bin/sh
history_dir=~/.cloudflare/dns_history
auth_email=$(awk -F = '/email/ {print $2}' ~/.cloudflare/cloudflare.cfg)
auth_key=$(awk -F = '/token/ {print $2}' ~/.cloudflare/cloudflare.cfg )
zone_name=$1
zone_file="$history_dir/$zone_name"
if [ -z "$zone_name" ]; then
echo "Usage: $0 zone.tld"
@trnila
trnila / main.c++
Created April 13, 2018 05:58
c++ bind
#include <vector>
#include <functional>
void test(int a, int b) {
printf("%d %d\n", a, b);
}
void testStr(const char* a) {
printf("%s\n", a);
@trnila
trnila / test.cpp
Created January 29, 2018 17:58
mbed profile
void test() {
int tests = 1000;
Timer timer;
timer.reset();
timer.start();
int begin = timer.read_us();
wait(1);
#!/bin/sh
container=$1
pass=$2
if [ -z "$container" ] || [ -z "$pass" ]; then
echo "usage: $0 container newRootPassword"
exit
fi
mysql_image=$(docker inspect $container --format "{{ .Config.Image }}")
@trnila
trnila / check_pass.py
Created April 25, 2017 19:07
Check your passwords in chromium for strength
import sqlite3
import string
import passwordmeter
from termcolor import colored
import secrets
import pyperclip
import os
import tempfile
import shutil
@trnila
trnila / parser.py
Created April 17, 2017 21:53
Pyparsing c prototype to golang
from pyparsing import *
class Function:
def __init__(self, tokens):
self.type = tokens[0]
self.name = tokens[1]
self.args = tokens[2] if len(tokens) > 2 else ""
def __repr__(self):
from enum import Enum
import logging
class ParseException(Exception):
pass
class Tokens(Enum):
START_PROPS = 1
@trnila
trnila / update.sh
Last active February 17, 2017 10:28
Create or update AAAA dns record on cloudflare
#!/bin/bash
user=user@example.org
pass=insert_apikey
zone_id=insert_zone_id
domain=$(hostname --fqdn)
addr=$(ip a | grep 'inet6 2001' | awk '{print $2}' | cut -d '/' -f 1)
if [ "$domain" == "arch" ]; then
echo "not updating"