Skip to content

Instantly share code, notes, and snippets.

View criztovyl's full-sized avatar

Christoph Schulz criztovyl

View GitHub Profile
@criztovyl
criztovyl / gpl-init.sh
Last active July 1, 2016 14:01
Initializes files with GPL or adds it to existing files.
#!/bin/bash
# A small tool to init files with a GPL header.
# Copyright (C) 2015 Christoph "criztovyl" Schulz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@criztovyl
criztovyl / gpl-comment.sh
Last active July 1, 2016 13:13
Tries to display the description line of a GPLed file.
gpl-comment()
{
[[ "$1" =~ ^-{0,2}h(elp)?$ ]] && { echo -e "Tries to display the description line of a GPLed file.\nUsage: gpl-comment file"; return 0; }
echo $(head -n2 $1 | tail -n1 | sed 's/^\W \?//')
}
@criztovyl
criztovyl / devpath.sh
Last active June 27, 2016 17:21
Overwrite a command with it's development one.
devpath()
{
DEVPATH_DIR=$HOME/.local/share/devpath
DEVPATH_RE='.*devpath/.'
if [[ "$1" =~ ^-{0,2}h(elp)?$ ]] || [[ -z "$1" ]]; then
echo "Usage: devpath scriptName" >&2
echo "or : devpath -l|--list" >&2
return 0
elif [[ "$1" =~ ^-{0,2}l(ist)?$ ]]; then
@criztovyl
criztovyl / da_gallery_dl.rb
Last active April 13, 2016 16:30
Downloads a full devian art gallery.
@criztovyl
criztovyl / gist-init.sh
Last active March 13, 2016 10:58
Sets up Gists
#!/bin/bash
# A script for initializing gists
# Copyright (C) 2015 Christoph "criztovyl" Schulz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@criztovyl
criztovyl / dlextract.sh
Last active February 9, 2016 13:52
Downloads, extracts and removes a archive file.
# 2016 Christoph "criztovyl" Schulz
# No Copyright, too trivial.
dlextract() {
file=$1
command=$2
keep=$3
wget $file && $command `basename $_` && [ "$keep" ] || rm -f $_
}
dlunzip(){ dlextract "$1" "7z x" $2; }
dluntar(){ dlextract "$1" "tar -xaf" $2; }
@criztovyl
criztovyl / monthdiff.sh
Created January 26, 2016 22:05
Calculates differences between months, also across years.
#!/bin/bash
# Script for calculating month differences
# Copyright (C) 2016 Christoph "criztovyl" Schulz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@criztovyl
criztovyl / pimus.sh
Last active August 29, 2015 14:27
Opens remote cmus screen in current shell. Starts cmus if it's not running.
#!/bin/bash
pimus()
{
# Try to show cmus screen, start new cmus instance into cmus screen if not available
if ! screen -qr cmus; then
# Start new cmus into cmus screen
screen -mdS cmus cmus
# Wait for cmus socket (up to 5x5 seconds)
@criztovyl
criztovyl / ssj.sh
Last active August 29, 2015 14:25
Splits, sorts and joins a string by a separator
#!/bin/bash
# A Bash/Ruby script that splits, sorts and joins a string
# Copyright (C) 2015 Christoph "criztovyl" Schulz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@criztovyl
criztovyl / to_assoc.php
Last active August 29, 2015 14:24
Associates integer-indexed arrays
<?php
/*
Replace array indices with associative keys
Copyright (C) 2015 Christoph "criztovyl" Schulz
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.