Posts for: #How-To

Banana Pi installation

Banana Pi in 2024?

Recently I needed a quick and easy way to mount an external disk with an ntfs file system and share it to the network.

So whatcha gonna do? Connect it to a server, mount it, create a samba share for it - done.

So I thought of my long forgotten Banana Pi M1 as it would an absolutely perfect little machine for the job. I am planning to turn it off most of the time, boot it up by wake-on-lan and auto-mount and share the external disk, which automatically goes into standby when nothing is happening with it. The perfect scenario.

Read more

How to Minify Compress Uglify Javascript

As you might have seen on the “How to: Minify CSS” article, minification helps speeding up websites.

The minification and therefor compression or in our case ‘uglification’ of JavaScript serves just the same purpose.

This would transform your JavaScript code form this

<div class="wp-block-codemirror-blocks-code-block code-block"><pre>var isFunction = function isFunction( obj ) {

      // Support: Chrome <=57, Firefox <=52
      // In some browsers, typeof returns "function"; for HTML <object> elements
      // (i.e., `typeof document.createElement( "object" ) === "function"`).
      // We don't want to classify *any* DOM node as a function.
      return typeof obj === "function" &amp;&amp; typeof obj.nodeType !== "number";
  };


var isWindow = function isWindow( obj ) {
		return obj != null &amp;&amp; obj === obj.window;
	};




	var preservedScriptAttributes = {
		type: true,
		src: true,
		noModule: true
	};

	function DOMEval( code, doc, node ) {
		doc = doc || document;

		var i,
			script = doc.createElement( "script" );

		script.text = code;
		if ( node ) {
			for ( i in preservedScriptAttributes ) {
				if ( node[ i ] ) {
					script[ i ] = node[ i ];
				}
			}
		}
		doc.head.appendChild( script ).parentNode.removeChild( script );
	}


function toType( obj ) {
	if ( obj == null ) {
		return obj + "";
	}

	// Support: Android <=2.3 only (functionish RegExp)
	return typeof obj === "object" || typeof obj === "function" ?
		class2type[ toString.call( obj ) ] || "object" :
		typeof obj;
}

to this

Read more

A Simple Bash Style With Git Branch Detection

Files

This could go into .bashrc, .bash_profile or .zshrc - your respective shell config file.

Args

Some aliases for easier handling

# alias shortcuts
alias lla="ls -la"
alias ll="ls -l"
alias l="ls"

Then we need a function which parses the current git branch (git has to be installed)…

# Git branch in prompt.
parse_git_branch() 
{
    git branch 2> /dev/null |sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}

…and input the branch unto your PS1 (current theme) like so:

Read more

How to Minify Css

Why would you want to minify CSS and what does it mean?

Minification of cascading style sheets means converting this

/*!
 * Bootstrap v3.3.7 (http://getbootstrap.com)
 * Copyright 2011-2016 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 */
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
html {
  font-family: sans-serif;
  -webkit-text-size-adjust: 100%;
      -ms-text-size-adjust: 100%;
}
body {
  margin: 0;
}
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
menu,
nav,
section,
summary {
  display: block;
}
audio,
canvas,
progress,
video {
  display: inline-block;
  vertical-align: baseline;
}
audio:not([controls]) {
  display: none;
  height: 0;
}
[hidden],
template {
  display: none;
}
a {
  background-color: transparent;
}
a:active,
a:hover {
  outline: 0;
}
abbr[title] {
  border-bottom: 1px dotted;
}
b,
strong {
  font-weight: bold;
}
dfn {
  font-style: italic;
}
h1 {
  margin: .67em 0;
  font-size: 2em;
}
mark {
  color: #000;
  background: #ff0;
}
small {
  font-size: 80%;
}
sub,
sup {
  position: relative;
  font-size: 75%;
  line-height: 0;
  vertical-align: baseline;
}
sup {
  top: -.5em;
}
sub {
  bottom: -.25em;
}
img {
  border: 0;
}
svg:not(:root) {
  overflow: hidden;
}
figure {
  margin: 1em 40px;
}
hr {
  height: 0;
  -webkit-box-sizing: content-box;
     -moz-box-sizing: content-box;
          box-sizing: content-box;
}
pre {
  overflow: auto;
}
code,
kbd,
pre,
samp {
  font-family: monospace, monospace;
  font-size: 1em;
}
button,
input,
optgroup,
select,
textarea {
  margin: 0;
  font: inherit;
  color: inherit;
}
button {
  overflow: visible;
}
button,
select {
  text-transform: none;
}
button,
html input[type="button"],
input[type="reset"],
input[type="submit"] {
  -webkit-appearance: button;
  cursor: pointer;
}

to this

Read more

Linux Backup for Files and Databases Zipped Cronjob Scheduled

Backing up files in Linux is possible in multiple different ways but in my case…

…I am currently trying out different backup strategies with rsync and zip

rsync because of running servers, with a temporary directory

zip because I need acces to files in Windows (in the worst case at least)

And I need some database dumps in there as well!

Let’s go then

First of all I define the variables I need like folder names and backup dates for files and folders

Read more