Skip to content

Instantly share code, notes, and snippets.

@trnila
trnila / main.c
Created February 29, 2016 22:51
fork
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
int main() {
int mypipe[2];
pipe(mypipe);
@trnila
trnila / Makefile
Last active July 26, 2016 00:45
Openwrt BUP package
# https://groups.google.com/d/msg/bup-list/HIeue2eiIKc/slcMnIywtoMJ
include $(TOPDIR)/rules.mk
PKG_NAME:=bup
PKG_VERSION:=0.28.1
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/bup/bup/archive/
@trnila
trnila / cmd_not_found.sh
Created February 2, 2017 16:52
Install package that is not found in Archlinux with packer
#!/bin/bash
query=$1
options=$(packer -Ss "$query" | awk -f <(cat - <<-'EOD'
function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
/^[^ ]/ {
printf("\"%s\" ", $1);
desc=1;
}
/^ / {
@trnila
trnila / update.sh
Last active February 17, 2017 10:28
Create or update AAAA dns record on cloudflare
#!/bin/bash
[email protected]
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"
from enum import Enum
import logging
class ParseException(Exception):
pass
class Tokens(Enum):
START_PROPS = 1
@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):
@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
#!/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 / 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);
@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);