Skip to content

Instantly share code, notes, and snippets.

@bboozzoo
bboozzoo / dnstest.py
Created September 19, 2016 18:44
DNS test in Python
#!/usr/bin/python3
import argparse
import socket
import logging
import time
def parse_arguments():
parser = argparse.ArgumentParser(description='DNS test')
parser.add_argument('-w', '--wait', default=0.5,
@bboozzoo
bboozzoo / dnstest.c
Last active September 20, 2016 14:35
/* gcc -D_GNU_SOURCE -o dnstest dnstest.c */
#include <stdio.h>
#include <unistd.h>
#include <netdb.h>
#include <string.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>
// Copyright 2016 Maciej Borzecki <maciek.borzecki@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@bboozzoo
bboozzoo / Makefile
Last active October 12, 2017 11:11
makefile for go projects
GO ?= go
GOFMT ?= gofmt
V ?=
LOCALPKG = $(shell go list .)
PKGS = $(shell go list ./... | grep -v vendor)
PKGFILES = $(shell find . \( -path ./vendor -o -path ./Godeps \) -prune -o -type f -name '*.go' -print)
PKGFILES_notest = $(shell echo $(PKGFILES) | tr ' ' '\n' | grep -v _test.go)
GOCYCLO ?= 15
CPUS=$(shell lscpu -p | wc -l)
@bboozzoo
bboozzoo / dir-locals.el
Created April 16, 2017 09:43
dir-locals for linux kernel development
;; rename to .dir-locals.el
((c-mode . ((c-file-style . "linux-tabs-only")
(indent-tabs-mode . t)
(show-trailing-whitespace . t)
(c-basic-offset . 8)
(tab-width . 8)
))
)
#!/usr/bin/env python2
from __future__ import print_function
import subprocess
import os
import signal
import time
MENDER_QEMU_PATH = os.path.join(os.path.dirname(__file__), "mender-qemu")
@bboozzoo
bboozzoo / prepare-commit-msg
Last active September 6, 2017 14:30
git hook for adding Mender changelog entry to commit messages
#!/bin/sh
add_changelog() {
tmpfile=$(mktemp /tmp/prepare-commit-msg.XXXXXXX)
cat "$1" | awk '
function print_changelog() {
printf "\n"
printf "# changelog information, use Changelog: <None|Title|Commit>\n"
printf "# or provide a message\n"
package main
import (
"fmt"
)
func main() {
foo := []int{1,2,3,4}
fmt.Println(foo[3]) // --> 4
fmt.Println(foo[4:]) // --> [] why?
@bboozzoo
bboozzoo / run-qemu
Last active January 28, 2020 19:45
helper for running qemu
#!/bin/bash
if [ -n "$V" ]; then
set -x
fi
PORT_BASE=59401
make_port_number() {
echo $((PORT_BASE + RANDOM % 100))
@bboozzoo
bboozzoo / order_test.go
Last active December 7, 2017 17:33
before/after ordering test
package main
import (
"errors"
"fmt"
"testing"
)
type App struct {
Name string