Kategorie: Linux

Customizing Bootstrap 4 without changing the core files

A simple instruction to customize the Bootstrap 4.0 using SASS and Autoprefixer.

But why? You can either…

  1. download the compiled version of Bootstrap or
  2. use the source of Bootstrap 4 and compile a custom version or
  3. use the CDN server

When you choose number 2, then it’s necessary to use SASS for compiling the style sheet and Autoprefixer for CSS vendor prefixing. And this is how to get a customized version of Bootstrap:

First make sure, you’ve installed Node.js and SASS.

Then create an empty folder my_directory with the following folders and some empty text files:

+- node_modules [folder]
+- custom.scss
+- package.json

The node_modules folder is required for some node.js modules. custom.css will hold all your customized stylesheets and package.json is used for some node.js package settings. You will see this later.

Now it’s time to load the current version of Bootstrap. Download the source of Bootstrap 4 and extract the zip to the folder /node_modules/bootstrap/.

Point your terminal to my_directory and install some node.js modules with the following command:

npm install postcss-cli autoprefixer npm-run-all

Now you can open the custom.scss file and add some costumized styles. This file can look like this:

// Custom.scss

$mixable: #ca0027;

$colors: (
 "mixable": $mixable,
$theme-colors: (
 "primary": $mixable

// Required
@import "node_modules/bootstrap/scss/bootstrap";

In this simple example, we just set a new color and use this color as primary color. A more detailed description on how to customize your theme can be found in the Bootstrap docs.

Let’s say we have made all of our customizations, so let’s open the empty file package.json. Add the following lines, which are required to combine your custom stylesheet and the Bootstrap source:

  "scripts": {
    "style":"sass custom.scss | postcss --use autoprefixer -o custom.css",
    "style-min":"sass custom.scss --style compressed | postcss --use autoprefixer -o custom.min.css",
    "all":"npm-run-all --parallel style style-min"

This file contains three scripts, which can be executed like this:

To create the output file custom.css:

npm run style

To create a compressed output file custom.min.css:

npm run style-min

And to create both files at once:

npm run all

That’s it. Keep in mind, that this will just compile the stylesheet. To compile the javascript, you should refer to the Bootstrap docs and the build tools there.

BASH: Nach jedem xten Zeichen ein Zeichen in einen String einfügen

Mit sed "s/.\{x\}/& /g" kann man in eine Zeichenkette alle x Zeichen ein Leerzeichen automatisiert einfügen. Aber auch andere Zeichen sind möglich. So kann man bspw. alle zwei Zeichen einen Doppelpunkt in einen String einfügen:

#~> echo "AA11CC22EE" | sed "s/.\{2\}/&:/g"

Sollte das letzte Zeichen stören, kann man dies wie folgt entfernen:
#~> a = $(echo "AA11CC22EE" | sed "s/.\{2\}/&:/g")
#~> echo ${a%?}


When cmake complains about a missing MHD library, install the microhttpd library development files.


 yum install libmicrohttpd-devel

Or download the up-to-date release from https://www.gnu.org/software/libmicrohttpd/ and compile and install it with:

tar -xzf libmicrohttpd-latest.tar.gz
cd libmicrohttpd-*
./configure && make install

VI oder VIM beenden

Um den bei vielen Linux und Unix Installationen und Tools (wie bspw. git) standardmäßig genutzten VI Editor zu beenden muss man mit der „ESC“-Taste in den Kommandomodus wechseln (am besten mehrfach drücken um ggf. schon eingegeben Kommandos abzubrechen) . Und dort dann „:q“ eingeben und Enter drücken.
Dies beendet VIM wenn vorher nichts geändert wurde. Wurde etwas am Text der geöffneten Datei geändert und man will dies speichern so nutzt man den Befehl „:wq“. Will man die Änderungen verwerfen und VI verlassen, so hilft „:q!“.

NVIDIA CUDA on Ubuntu: unsupported GNU version! gcc versions later than 5 are not supported!

After installing CUDA on Ubuntu, compiling CUDA applications with nvcc results in an error similar to this:

In file included from /usr/local/cuda-8.0/bin/../targets/x86_64-linux/include/cuda_runtime.h:78:0,
from <command-line>:0:
/usr/local/cuda-8.0/bin/../targets/x86_64-linux/include/host_config.h:119:2: error: #error — unsupported GNU version! gcc versions later than 5 are not supported!
#error — unsupported GNU version! gcc versions later than 5 are not supported!

Ubuntu comes with a more up-to-date GCC then CUDA can handle. To solve this issue we install GCC 4.9:

sudo apt install gcc-4.9 g++-4.9

Now GCC 4.9 and the up-to-date GCC are installed on the system. To be able to use the up-to-date GCC without CUDA, one can setup and use the „update-alternatives“ system for GCC. In this case we replace the default GCC 6 compiler:

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 50 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9

Now we can list the available compilers with

update-alternatives --list gcc

and set the GCC 4.9 as default with

update-alternatives --set gcc /usr/bin/gcc-4.9