Skip to content

Instantly share code, notes, and snippets.

View etam's full-sized avatar

Adam Mizerski etam

View GitHub Profile
@etam
etam / fix_perms
Last active August 2, 2016 10:32
#!/bin/bash
(($# == 0)) \
&& set "."
find "$@" -type d -exec chmod 755 {} +
find "$@" -type f -exec chmod 644 {} +
@etam
etam / mksum
Last active August 2, 2016 10:32
#!/bin/bash
if (( $# != 3 )); then
echo "usage: $(basename "$0") type hash filename"
exit 1
fi
type="$1"
hash="$2"
filename="$3"
@etam
etam / my_ip
Last active August 2, 2016 10:34
#!/bin/bash
A="$(ip addr show dev eth0)"
A="${A##*inet }"
echo "${A%%/*}"
#!/bin/bash
numeric_or_default() {
local -i val="$1"
local -i default="$2"
if [[ "$1" == "$val" ]]; then
echo "$val"
else
echo "$default"
fi
/*
primes = filterPrime [2..]
where filterPrime (p:xs) =
p : filterPrime [x | x <- xs, x `mod` p /= 0]
main = print $ take 10 primes
*/
#include <iostream>
@etam
etam / Makefile
Last active May 8, 2017 09:40
Makefile for a single c++ binary
CC := gcc
CXX := g++
CPPFLAGS :=
CXXFLAGS := -std=c++14 -O2 -Wall -Wextra
LDFLAGS :=
LDLIBS := -lstdc++
OBJS := main.o
EXE := main
all: $(EXE)
@etam
etam / Makefile
Last active May 8, 2017 09:41
Makefile for a single binary with mixed C and C++ sources
CC := gcc
CXX := g++
CPPFLAGS :=
CFLAGS := -std=c11 -O2 -Wall -Wextra
CXXFLAGS := -std=c++14 -O2 -Wall -Wextra
LDFLAGS :=
LDLIBS := -lstdc++
COBJS :=
CXXOBJS := main.o
OBJS := $(COBJS) $(CXXOBJS)
@etam
etam / _docker_wrapper
Last active December 23, 2017 16:47
wrapper for running commands in docker containers
#!/bin/bash
# usage: _docker_wrapper [--root] image command
user="--user=${UID}"
if [[ "$1" == "--root" ]]; then
user="--user=root"
shift
fi
@etam
etam / openpgp.md
Created November 1, 2020 13:47
keyoxide proof
@etam
etam / yagna.json
Last active March 29, 2021 13:50
Lnav yagna format
{
"$schema": "https://lnav.org/schemas/format-v1.schema.json",
"yagna_log" : {
"title" : "Yagna Log Format",
"regex" : {
"basic" : {
"pattern" : "^\\[(?<timestamp>\\d{4}-\\d{2}-\\d{2}(T| )\\d{2}:\\d{2}:\\d{2}(Z|,\\d{3})) (?<level>\\w+) +(?<component>[\\w:.]+)\\] (?<body>.*)$"
}
},
"level" : {