Skip to content

Instantly share code, notes, and snippets.

View jan-swiecki's full-sized avatar

Jan Święcki jan-swiecki

View GitHub Profile
#!/bin/bash
# This script doesn't work with apt-get update (even with -q). Kill -0 exits immediately.
print_empty_lines() {
for x in $(seq "$1"); do
tput el
echo
done
}
@jan-swiecki
jan-swiecki / yara_test.yar
Created March 16, 2023 18:36
yara_test.yar
rule Hello {
strings:
// A string to match -- default is ascii
$ascii_string = "hello"
condition:
// The condition to match
$ascii_string
}
@jan-swiecki
jan-swiecki / hist.awk
Last active February 23, 2023 08:15
hist.awk
#!/usr/bin/awk -f
# Original script: https://stackoverflow.com/a/39637429/1637178
# License: https://creativecommons.org/licenses/by-sa/3.0/
# This one works with integers
# Example:
# $ du -s some_folder/* | awk '{ print $1; }' > sizes
# $ ./hist.awk sizes
#
# Change bin_width, bar_scale_down and %5d accordingly
@jan-swiecki
jan-swiecki / lib_packet_parse.py
Last active January 2, 2023 08:29
python-raw-packet-tools
from __future__ import annotations
from argparse import ArgumentParser
from dataclasses import dataclass
from math import ceil, floor
from pathlib import Path
import re
from typing import Callable
RLEN = 50
@jan-swiecki
jan-swiecki / bash_args_parse_example.sh
Created April 13, 2022 11:26
bash_args_parse_example.sh
#!/bin/bash
usage () {
cat<<EOF
usage: ...
EOF
}
while [[ "$#" -gt 0 ]]; do
case $1 in
#!/bin/bash
set -eo pipefail
. ./uninstall.sh
echo "$script_line" >> ~/.bashrc
mkdir -p "$HOME/.local/var/venv/"
@jan-swiecki
jan-swiecki / docker-machine-install-docker-compose.sh
Created March 11, 2016 12:48
Installs docker-compose inside docker-machine
#!/bin/sh
# Installs docker-compose inside docker-machine
DOCKER_COMPOSE_VERSION=1.6.0
# Download docker-compose to the permanent storage
echo 'Downloading docker-compose to the permanent VM storage...'
sudo mkdir -p /var/lib/boot2docker/bin
sudo curl -sL https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` -o /var/lib/boot2docker/bin/docker-compose
#!/bin/bash
set -eou pipefail
VERSION="$2"
cd /tmp
set -x
# trap "rm $5" EXIT
rm SHA256SUM || true
function exponentialBackoff(i, dt) {
const f = j => j >= 0 ? Math.exp(j/3)*dt : 0
const ret = f(i)-f(i-1)
if(ret < dt) {
return dt
} else {
return ret
}
}