Skip to content

Instantly share code, notes, and snippets.

View plesiv's full-sized avatar

Zoran Plesivcak plesiv

View GitHub Profile
@plesiv
plesiv / keybase.md
Last active February 21, 2020 16:48

Keybase proof

I hereby claim:

  • I am plesiv on github.
  • I am plesiv (https://keybase.io/plesiv) on keybase.
  • I have a public key ASCafFXVuY8ql4bpuvmReKoh6B7jcK9uu7VLICWoG8TMkgo

To claim this, I am signing this object:

@plesiv
plesiv / filename-normalization.sh
Last active November 10, 2015 22:42
Shell functions for filename normalization
# normalize string given as an argument
n() { sed -e 's/^[ -]\+//' -e 's/[ -]\+$//' -e 's/[ ()-]\+/-/g' -e "s/'//g" | tr '[:upper:]' '[:lower:]' $1; }
# normalize name of the single file (renames file)
m() { mv "$1" "$(echo $1 | n)"; }
# normalize names of all files in the current directory
f() { for i in *; do m "$i"; done; }
@plesiv
plesiv / docker-bulk.sh
Last active November 27, 2015 14:56
Rudimentary functions for batch actions on docker containers / images (load, save, kill, remove)
# save all tagged Docker images in the current directory
svimgs() { local image_ids=$(docker images | tail -n+2 | awk '{print $1 ":" $2}'); for id in $image_ids; do cdir=$(dirname $id); mkdir -p $cdir; docker save -o $id $id; done }
# load in Docker all images from the current directory
ldimgs() { local image_files=$(find -type f); for file in $image_files; do docker load --input $file; done }
# remove all images from Docker
rmimgs() { docker rmi -f $(docker images | tail -n+2 | awk '{print $3}' | sort -u); }
# clean <none> images
cleanimgs() { docker rmi -f $(docker images | grep '<none>' | awk '{print $3}' | sort -u); }
# kill all containers
mkdir /mnt/gentoo
mount /dev/sda4 /mnt/gentoo
mount /dev/sda2 /mnt/gentoo/boot/
mount -t proc proc /mnt/gentoo/proc/
mount --rbind /sys /mnt/gentoo/sys
mount --make-rslave /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev
mount --make-rslave /mnt/gentoo/dev/
@plesiv
plesiv / train-usaco-solutions.cc
Last active August 29, 2015 14:17
Solutions to problems from http://train.usaco.org in C++
/*
ID: dnkihot1
LANG: C++
TASK: combo
*/
#include <iostream>
#include <fstream>
#include <set>
using namespace std;
@plesiv
plesiv / gdbserver_remote_debugging_network.txt
Created December 22, 2014 20:12
Remote debugging of embedded system with GDB/GDBSERVER over the network
Debugging embedded system over ethernet with GDB (and gdbserver)
Prerequisite: host and target should be connected over network.
I - on target
* needed:
- compiled program that needs to be debugged (doesn't need
debugging symbols in it),
- gdbserver executable
@plesiv
plesiv / Makefile_minimal.txt
Created December 22, 2014 20:11
Minimal Makefile - compiles all files in specified directories
# Configuration
BIN_NAME := app_bin.elf
SRC_PATH := src
INC_PATH := include
LIB_PATH := lib
BUILD_PATH := build
CC := gcc
CFLAGS := -Wall -O0 -g3
LDFLAGS :=
@plesiv
plesiv / gnome-mounted_on_desktop_no_autoopen.sh
Created December 22, 2014 20:11
Gnome - mounted volumes: on desktop, prevented auto-open
#!/usr/bin/env sh
# source: http://askubuntu.com/questions/194705/how-do-i-get-a-usb-drive-shortcut-on-desktop
# Show volumes on desktop
gsettings set org.gnome.nautilus.desktop volumes-visible true
# Don't auto-open mounted volumes
gsettings set org.gnome.desktop.media-handling automount-open false
@plesiv
plesiv / uramdisk_create_install_kernel_modules.sh
Created December 22, 2014 20:10
Creates uramdisk.tar.gz from ramdisk.tar.gz - AND/OR - Installs Linux Kernel modules on ramdisk
#!/usr/bin/env bash
#
# Installs Kernel modules on ramdisk and/or creates uramdisk from ramdisk.
#
# Tested on Ubuntu.
# Invoking with arguments:
# -m > install kernel modules on ramdisk
# -u > create uramdisk from ramdisk
# -mu / no arguments > do both
@plesiv
plesiv / password_generate.py
Created December 22, 2014 20:09
Very simple (configurable) random password generator
#!/usr/bin/env python
"""
Configurable password generator
Usage instructions:
1. Configure generator by modifying values below
2. Execute script
"""
from random import shuffle