New book, more fun!

Python Third Edition

The Brain Problem by Robert C. Martin

The idea that our meager internet, which indirectly interconnects only a trifling few ‘HUNDREDS of MILLIONS’ of pitifully weak serial processors, could emulate the information of a single brain is absurd. Read the whole article here.

Link to Blogger content

MSFT oriented, for the moment obsolete: bitcruncher.blogspot.com.

PFE? A typical friday night

My BunsenLabs Linux setup notes for Dell Inspiron 6000

BunsenLabs Deuterium, fresh install

BunsenLabs does not use a traditional desktop like KDE, GNOME or even Xfce. Instead it’s an optimized mix of components from various open source projects including most notably the lightweight Openbox window manager, tint2 panel, the Conky system monitor, and Thunar file manager.

The guide is based on Deuterium which serves as my main coding OS. It offers a speedy, uncluttered Debian experience which (in my opinion) is only equaled by distros as for example ArchLabs Linux or CrunchBang++.

Here is a rundown of how I configured BunsenLabs to best serve my needs.

1 Status of this document

v1.0

  • 07/11/17 Initial setup.

Changes since the last version:

v1.1

  • 08/02/17 Reworked the layout.
  • 08/03/17 Added Firefox, Gimp, Viewnior, Krita.
  • 08/04/17 Added nftables, screenfetch, iftop, ttyload.
  • 08/05/17 Added LibreOffice, Claws Mail, mutt.
  • 08/07/17 Added PostgreSQL, pgAdmin.
  • 08/08/17 Added mpd, ncmpcpp, curl, youtube-dl.
  • 08/10/17 Added GnuPG, Sublime Text 3, Jekyll.
  • 08/13/17 Added vim, Pathogen, gVim, Python, pip.
  • 08/15/17 Added Git, Node.js, Ruby on Rails, Tint2.
  • 08/17/17 Added terminator.
  • 08/20/17 Made multiple adjustments, removed typos.
  • 08/29/17 Added Geany-plugins, ranger, nicstat, lshw.
  • 09/02/17 Replaced Sublime Text 3 with Atom.
  • 09/20/17 Added Openbox.
  • 09/28/17 Updated list with Firefox add-ons.
  • 10/16/17 Added redshift, Openbox rounded corners patch.
  • 10/22/17 Added newsbeuter.

2 Before you begin

As a good practice, before installation I always first boot the system from Live USB or DVD and download/run lshw to check the hardware components.

In rare cases when using a WiFi connection to connect to the internet, the Pro 2200BG adapter is not recognized during setup. Just ignore any system update. Same for anything related to Bunsen repositories; after install WiFi works fine, and you can add the repos manually in /etc/apt/sources.list.

3 Bunsen install

Download the appropriate ISO (bl-Deuterium-i386_20170429.iso).

Do an install from Live USB. As soon its finished, and after reboot, you will see underneath screen asking you to update the system.

When the updating is done the script will run a set of options for attaching the Debian repositories, some 3rd party multimedia plugins, printer support, Java, and adding packages for developers.

Each of these options may be selected individually.

BunsenLabs Welcome

4 Productivity

BunsenLabs contains a bunch of apps you can install with a simple click in the Openbox menu.

Other apps are available from the repos & 3rd party sources. If so, instructions will show the appropriate commands (always run these as non-root user with sudo privileges).

Let’s start with the list.

4.1 Internet browsers

• 4.1.1 Google Chrome, Firefox or Opera

I made a choice for Firefox but you can install any browser next to it.

Note: Top 6 add-ons: [HTTPS Everywhere] [Ghostery] [DuckDuckGo] [Stylish] [NoScript] [User-Agent Switcher] (an updated .xml file is available here).

4.2 Office

• 4.2.1 LibreOffice

LibreOffice Writer is the only software that comes pre-installed. However, the remainder of the suite is just a mouse click away.

Note: I don’t like the splash screen when starting LibreOffice. To get rid of it:

  • $ geany /etc/libreoffice/sofficerc

Change Logo=1 to Logo=0 and exit.

• 4.2.2 Claws Mail

  • $ apt-get install claws-mail

Claws Mail has an excellent FAQ which covers virtually all your questions.

Note: If you want to send and receive mail via a terminal, Mutt (-patched) is a must.

Mutt client

  • $ apt-get install mutt # the mail user agent
  • $ apt-get install mutt-patched # adds sidebar, nntp support, multiple-fcc patches

For a copy of my dots, see this repo. For everything else, Mutt Wiki.

4.3 Graphics

• 4.3.1 Gimp

Obligatory. Just a click away.

• 4.3.2 Viewnior

I don’t like the Mirage picture viewer.

Note: I am not using this, but if you are looking for a professional open source painting program with full support for graphics tablets, check out Krita.

4.4 Multimedia apps

• 4.4.1 Mpd

  • $ apt-get install mpd

To configure mpd (Music Player Daemon), download this script.

• 4.4.2 Ncmpcpp

Probably the best free ncurses mpd client available.

ncmpcpp

  • $ apt-get install ncmpcpp

• 4.4.3 YouTube-dl

5 Relational Databases

• 5.1.1 PostgreSQL

  • $ apt-get install postgresql-9.4 postgresql-client-9.4

Next, read this How to install and use PostgreSQL 9.4 on Debian 8 article.

• 5.1.2 pgAdmin

pgAdmin is a graphical administration tool for PostgreSQL.

  • $ apt-get install pgadmin3

There are forums which discuss a version 4 install on Jessie but I prefer stable, not the latest bleeding edge.

6 Development

My favs for simple coding and web site development.

6.1 Text Editors

• 6.1.1 Vim

  • $ apt-get install vim

That’s done. Now, we will version our configuration to share across machines while keeping track of any changes made.

To do this, create a .vim repository with a vimrc file:

  • $ cd ~
  • $ mkdir .vim
  • $ cd .vim
  • $ touch vimrc
  • $ git init .

And symlink the vimrc file. This way we can (ab)use it while still getting all the advantages of versioning with Git.

  • $ cd ~
  • $ ln -s ~/.vim/vimrc ~/.vimrc

Next step is theming and changing the layout:

  • $ mkdir ~/.vim/colors

Copy my theme git files to the colors folder. Edit .vimrc and add this line:

  • colorscheme Tomorrow-Night

Some syntax highlighting based on file names would be appreciated:

  • filetype on
  • filetype plugin on

And text formatting:

  • filetype indent on

Set default font to Menlo regular with a size 17:

  • set guifont=Menlo\ Regular:h17

While we are busy also add these lines:

  • set lines=35 columns=150
  • set colorcolumn=90
  • set number
  • syntax on

Note: Now that your vim starts to look better, let’s improve how it functions. Either visit this repo for further customization (learn while doing), or copy my dotfile (see end of sub 6.1.1.2).

*6.1.1.1 Pathogen*

Pathogen is a vim package manager that makes your life easier when working with vim: it’s how you can have your fuzzy finders, file trees, and coding tools without drowning in Vimscript.

I prefer Pathogen to some of the alternate vim package managers because it’s arguably the most popular (every plugin these days supporting it) and it’s zero -config: just drop a vim plugin into the ~/.vim/bundle folder, and it’s installed. From there you can configure the ~/.vimrc file to your taste.

Add this line to the top of your .vimrc:

  • execute pathogen#infect()

Note: See Romain Lafourcade’s gist ‘How to use Tim Pope’s Pathogen’.

*6.1.1.2 Vim plugins*

vim

All plugins are on Git which makes updating to the latest version very easy, i.e. pulling master.

For every plugin you need to run:

  • $ cd ~/.vim
  • $ git submodule add git@source/pluginname.git bundle/pluginname

For example, adding the vim-ruby plugin:

  • $ git submodule add git@github.com:vim-ruby/vim-ruby.git bundle/vim -ruby
Name Link
Command-T https://github.com/wincent/command-t/
NerdCommenter https://github.com/scrooloose/nerdcommenter
NerdTree https://github.com/scrooloose/nerdtree
Lightline https://github.com/itchyny/lightline.vim
Supertab https://github.com/ervandew/supertab
Fugitive https://github.com/tpope/vim-fugitive
Git Gutter https://github.com/airblade/vim-gitgutter
Bundler https://github.com/tpope/vim-bundler
Endwise https://github.com/tpope/vim-endwise
Ruby https://github.com/vim-ruby
Rails https://github.com/tpope/vim-rails/
Dispatch https://github.com/tpope/vim-dispatch
Multiple Cursors https://github.com/terryma/vim-multiple-cursors/

Note: My memo for activating Command-T, NerdTree and Git Gutter in .vimrc. Feeling lazy? Download my latest config.

• 6.1.2 gVim

gVim Editor

  • $ apt-get install gvim

• 6.1.3 Sublime Text 3 Atom

  • $ wget http://bit.ly/2vTirOt # //c758482.r82.cf2.rackcdn.com/sublime-text_build-3083_i386.deb
  • $ dpkg -i sublime-text_build-3083_i386.deb

Note: Sublime is non-free. If you are willing to pay some money, you’ll get one slick source code editor.

Update: I switched from Sublime to Atom. GitHub does not offer an i386 build but luckily Andras Retzler created one following this procedure.

Atom

Must have community themes and packages:

Name Link
Atom-Beautify https://atom.io/themes/atom-beautify
Todo-Show https://atom.io/packages/todo-show
Expose https://atom.io/packages/expose
Emmet https://atom.io/themes/emmet
Pigments https://github.com/abe33/atom-pigments
File-icons https://atom.io/themes/file-icons
Color-picker https://atom.io/themes/color-picker
Language-Markdown https://atom.io/packages/language-markdown
Language-PowerShell https://atom.io/packages/language-powershell
Autocomplete-Python https://atom.io/packages/autocomplete-python

6.2 Programming

• 6.2.1 Python

Jessie ships with both Python 2 and Python 3 pre-installed. Let’s update and upgrade the system:

  • $ apt-get update
  • $ apt-get -y upgrade

Once the process is complete, we check the Python 3 version by typing:

  • $ python3 -V
    • Python 3.4.2

Guess I’ll add pip, Always handy to have a package installer aboard:

  • $ apt-get install -y python3-pip

We need a few more packages and development tools to ensure that we have a robust setup:

  • $ apt-get install build-essential libssl-dev libffi-dev python-dev

Setting up isolated project spaces (virtual environments):

  • $ cd ~
  • $ apt-get install -y python3-venv
  • $ mkdir py3venv
  • $ cd py3venv

Creating a project directory:

  • $ python3.4 -m venv ‘projectname’

Enable the project environment:

  • $ source ‘projectname’/bin/activate

A fresh Jessie installation uses Python version 2.7 as system default:

  • $ python -V
    • Python 2.7.9

I will use the update-alternatives command to set 3.4 as the new standard:

  • $ update-alternatives –install /usr/bin/python python /usr/bin/python2.7 ‘1’ # lowest number
  • $ update-alternatives –install /usr/bin/python python /usr/bin/python3.4 ‘2’ # higher number which will prevail

Checking if it worked:

  • $ python -V
    • Python 3.4.2

Listing all Python alternatives:

  • $ update-alternatives –list python
    • /usr/bin/python2.7
    • /usr/bin/python3.4

From now on, typing:

  • $ update-alternatives –config python

… makes it possible to switch versions by entering a selection number.

Update: As version 3.6 is now mainstream, we will download from the Python website and build from source:

Don’t forget to update your alternatives & create a virtual environment.

• 6.2.2 Ruby on Rails

Change dir to your home:

  • $ cd ~

Get the installation script:

Running the script in ~ (get some coffee):

  • $ bash nodesource_setup.sh

After running the setup script, install the Node.js package.

  • $ apt-get install nodejs

This nodejs binary package contains both nodejs and npm. In order for some of the npm packages to work:

  • $ apt-get install build-essential

Use gpg to contact a key server and request the RVM project’s key:

RVM key

Note: 409B6B1796C275462A1703113804BB82D39DC0E3.

Download the RVM installation script:

  • $ curl -sSL https://get.rvm.io -o rvm.sh

Pipe the script to bash to install Rails and the associated latest release of Ruby:

Piping RVM

During the installation process, you’ll be prompted for your password. Enter as requested and RVM gets all tools it needs to build and compile Ruby, download the latest version of Ruby, the Ruby on Rails framework, and its dependencies.

When the installation is complete, source the RVM scripts:

  • $ source ~/.rvm/scripts/rvm

A final check that Ruby is correctly installed:

  • $ which ruby

Note: Robby Russell wrote a script that transforms your Jessie laptop in a Rails development machine. Use at your own risk.

6.3 Version Control System

• 6.3.1 Git

  • $ apt-get install git-core
  • $ git config –global user.name ‘username’
  • $ git config –global user.email ‘username@example.com’
  • $ git config –list # verify settings

6.4 Static Site Generator

• 6.4.1 Jekyll

For installation and setting up a GitHub Pages site locally with Jekyll click here.

7 Security

7.1 Firewall

• 7.1.1 Nftables

  • $ apt-get install -t jessie-backports nftables
  • $ cd /usr/share/doc/nftables/examples/syntax/
  • $ cp workstation /etc/nftables.conf
  • $ sed -i ‘s/flush/#flush/’ /etc/nftables.conf
  • $ systemctl start nftables
  • $ systemctl enable nftables
  • $ nft list ruleset # check if rules have been applied after boot
  • $ systemctl status nftables.service # check if .service has been started

Note: You now have a “whitelisted” firewall that only accepts connections you created yourself. Problems? Follow this thread on the BunsenLabs forums.

Use this basic firewall in addition to restrictive rules on your router!

7.2 Mail encryption

• 7.2.1 GnuPG/GPG

Full setup notes for creating your private and public key on NixCraft. Mutt and GnuPG? See Justin R. Miller’s tutorial.

8 System information

8.1 Bash Scripts

• 8.1.1 Screenfetch

Displays system information and ASCII version of the Linux distro logo.

  • $ apt-get install screenfetch

Note: Instead Screenfetch you can install Neofetch.

8.2 System Monitors

• 8.2.1 iftop

Tool that produces a frequently updated list of network connections.

iftop

  • $ apt-get install iftop

• 8.2.2 ttyload

Tracks load averages over time on a UNIX(ish) machine.

ttyload

  • $ apt-get install ttyload

9 Theming your Openbox desktop

Some eye candy because not everything is just about functionality, right?

9.1 Terminal Colors

• 9.1.1 Terminator

Copy the config from here and replace the default file in ~/.config/terminator.

terminator

Note: If you want to design your own scheme, visit terminal.sexy.

9.2 System Panel/Taskbar

• 9.2.1 Tint2

Tint2 features:

  • Comes with Openbox.
  • Panel with taskbar, systray, clock and battery status.
  • Customize color/transparency on font, icon, border and background.
  • Pager like capability: send task from one workspace to another, switching workspaces.
  • Multi-monitor: one panel per monitor, show tasks from current monitor.
  • Customize mouse events.
  • Window manager’s menu.

Download oomox-colors.tint2rc and drop it in ~/.config/tint2.

9.3 Window Manager

• 9.3.1 Openbox

If you want the same look everywhere, snag this oomox-colors.tar.gz package. The theme’s icons can be found here.

Time to teach Openbox a few tricks as well. Set the number of desktops to four and disable all window decorations in ~/.config/openbox/rc.xml:

<desktops>
  <number>4</number>
  <firstdesk>1</firstdesk>
  <names>
    <name>1</name>
    <name>2</name>
    <name>3</name>
    <name>4</name>
  </names>
  <popupTime>875</popupTime>
</desktops>

<application name="*">
    <decor>no</decor>
  </application>

Note: You can also disable just a single app, e.g. x-terminal-emulator.

Update: Head_on_a_Stick has built some experimental packages which theme Openbox with rounded corners. For a how-to, see this thread.

9.4 Internet Browser

• 9.4.1 Firefox

Firefox Web Browser

Download this homepage for Firefox here.

10 Extras

Packages I use on a daily basis but for whatever dark reason always forget when creating a new setup:

YOU ARE DONE

Spin up a Docker dev/test environment on bare metal in 60 minutes or less

Joyent’s public and private cloud, free for use as open source.

Triton