Skip to content

Instantly share code, notes, and snippets.

@danixland
danixland / gravatar.html
Created November 13, 2020 13:42
custom shortcode template for hugo to display a gravatar image inside a <figure> container. email address can be passed inside the shortcode or can be set inside the [params] group as "gravatarEmail"
{{/*
* The gravatar shortcode:
* All arguments are optional, main ones are mail and size and have a fallback set in place.
* Args:
* mail: [string] The email address. Falls back to .Site.Params.gravatarEmail which should be set in your config file.
* size: [int] The size of the fetched image. Defaults to 200 if not set.
* class: [string] The class to give to the figure block.
* link: [string] The address to link the picture to.
* target: [string] Where to open the link. One of "_blank", "_self", "_parent", "_top".
* caption: [string] Caption text to show with the image. Supports Markdown.
@danixland
danixland / him.sh
Created July 12, 2018 08:31
Him: Help IMproved - modified version of the help script shipped with git.
#!/bin/sh
# usage: help - Lists all the available commands
# help <command> - Detailled explanation of how "command" works
if tty -s
then
HELPTEXT="Hi $USER, Run 'help' for help, 'help <command>' for specific help on a command, run 'exit' to exit. Available commands:"
else
HELPTEXT="Hi $USER, Run 'help' for help, 'help <command>' for specific help on a command. Available commands:"
@danixland
danixland / delete-bare-repo.sh
Last active July 12, 2018 08:28
script to delete a bare git repository after checking some conditions. Save it inside the git-shell-commands directory as "delete"
#! /bin/bash
# usage: delete <REPOSITORY> - PERMANENTLY delete a repository if existing.
# CAREFUL, this action cannot be undone. This command will ask for confirmation.
GITDIR="/var/git"
function is_bare() {
repodir=$1
if "$(git --git-dir="$repodir" rev-parse --is-bare-repository)" = true
@danixland
danixland / create-bare-repo.sh
Last active July 12, 2018 10:31
script to create a bare git repository and fill it up with some settings to allow git to send notification emails as well as deploy the code. Save it inside the git-shell-commands directory as "create"
#! /bin/bash
# usage: create <PROJECT> - create a git bare repository named PROJECT.git
# this command will setup the repo and send a mail for confirmation.
GITDIR="/var/git"
MULTIMAIL="/usr/doc/git-2.14.4/contrib/hooks/multimail/git_multimail.py"
GITUSER="git"
GITGRP="git"
@danixland
danixland / dualhead.sh
Created June 9, 2018 11:04
bash script to toggle a secondary monitor on or off
#! /bin/bash
# DUALHEAD.SH - automatic script that toggles the secondary screen on and off
# requires xrandr and optionally feh to set the background image
# for the desktop(s).
### LVDS1 is the main screen on my laptop
### HDMI1 is the secondary screen attached via hdmi and is hanging on the wall
### above the laptop
@danixland
danixland / create-mysql.bash
Last active April 8, 2016 20:55 — forked from omeinusch/create-mysql.bash
Simple bash script to create mysql db, user with generated password
#!/bin/bash
PASS=$(pwgen -s 40 1)
if [ -r /root/.my.cnf ]; then
mysql -uroot <<MYSQL_SCRIPT
CREATE DATABASE $1;
CREATE USER '$1'@'localhost' IDENTIFIED BY '$PASS';
GRANT ALL PRIVILEGES ON $1.* TO '$1'@'localhost';
FLUSH PRIVILEGES;
// opengraph metatags
function danixland_opengraph() {
global $post;
$output = '';
$image = get_template_directory_uri() . '/img/standard-logo.png';
if ( is_home() || is_front_page() ) {
$output = '<meta property="og:url" content="' . get_bloginfo('url') . '" />' . "\n";
$output .= '<meta property="og:type" content="website" />' . "\n";
$output .= '<meta property="og:title" content="' . wp_title('&bull;', false, 'right') . '" />' . "\n";
@danixland
danixland / gify.sh
Created January 24, 2016 22:16
script that helps you create an animated gif from images. It also can proportionally resize the images. Uses Imagemagik's mogrify and convert.
#! /bin/bash
# Author: Danilo 'danix' Macri
# Author URI: http://danixland.net
# Script URI: http://danixland.net/?p=3545
# License: GPL2
# License URI: https://www.gnu.org/licenses/gpl-2.0.html
#--------------------------------------------------------------------------------#
# #
// adds custom default gravatar for not logged in users
function sog_default_gravatar($avatar_defaults) {
$myavatar = get_bloginfo('stylesheet_directory') . '/images/mystery_danixland.jpg';
$avatar_defaults[$myavatar] = "danixland";
return $avatar_defaults;
}
add_filter( 'avatar_defaults', 'sog_default_gravatar' );
@danixland
danixland / snippet-kXMcOXR.sh
Last active January 24, 2016 21:32
just a snippet to remember how to remove extensions from filenames in bash
# we have a test file
FILE=test.avi
# and we want to output just its filename without the extension
echo ${FILE%.avi}
# this returns
# test
# ;)