Month: August 2014

How To: Fix the sound volume issues in VLC Media Player

How To: Fix the sound volume issues in VLC Media Player

Yeah, another quick post on how to work out the dynamic audio compression settings in VLC. By default, you get these awkward moments when you go to sleep, put on a boring movie and set the volume just right so that it’s kind of soft, yet any dialogue is still just a bit more than perceptible and then slowly your reality is mixing with the movie and you’re out. So there’s this party and then these two guys are out, talking, and then a phone rings and all of a sudden 800 Watts of pure RMS explosions and gunfire shake the whole house, waking the dead and they start screaming, you jump out the bed and now you’re f*cking screaming and there goes a classic dafuq moment.

If you don’t know what I’m talking about, this post is not for you. And if you do know what I’m talking about but won’t admit it because you get startled like a schoolgirl whenever a truck just rolls by in mid-scene even when you’re genuinely doing nothing else but watching a movie, read on – your secret’s safe with me (just leave a comment with your name and the name of the non-horror movie that made you wet your pants most recently and I’ll make sure not to mention it randomly in an unrelated upcoming post).

Step 1

So, first of all, if you liked what you saw in my How To: Make Linux Look Sexy In Only 3 Fast Steps post, you already know that VLC’s default skin looks absurd and that Maverick07x’s MinimalX skin on deviantart.com is a must-have. Here’s what it looks like:

MinimalX Skin for VLC

The reasoning behind the previous paragraph’s off-topic-ness is that even without dynamic audio compression to prevent unpleasantries, a good looking skin can help lower blood pressure faster and make you look less like a startled gazelle on her period.

Step 2 

Go to preferences / Advanced Preferences (Ctrl + P), in the lower left corner select All to show all settings and then, in the left sidebar under Audio, click Filters. You want to check the Dynamic range compressor but I also suggest checking Volume normalizer and Parametric Equalizer – they might come in handy at some point. Note that omitting this step causes VLC to reset your settings every time you close it.

VLC Advanced Preferences

Step 3

It’s about time we enable the Compressor and configure it properly. Right click, go to Interface, Effects and Filters (Ctrl + E) and there you have it on the second tab under Audio Effects. The values you’re about to see have been tested, they give good results so no questions asked.

VLC Audio Compressor

If you want to know what they mean and how sh*t works, you need to looks somewhere else. I too did this research once, I don’t take credit for these settings and out of about 5 different (yet so similar, in terms of setting values) sources, only one of them explained them properly. It was an interesting read at that time but didn’t find it interesting enough to remember any of it – this is one of those type of things I just like to get done quick and move on. If you have too much time on your hands and feel like getting them dirty, you can experiment with different values – who knows, maybe you can achieve even greater results.

On a slightly different note, I hate Windows users (myself included every once in a while) for having KMPlayer available for them just like that. I dare say it’s the best media player there is – everything works out the box, has its own internal codecs, it’s highly customizable, has tons of handy little keyboard shortcuts and an impressive f*ckload of options in the settings panel that can intimidate even the most versatile tech savvies. It also looks great just with its default skin, but with LangLe’s KMetro from deviantart.com it’s just porn for the retina.

KMPlayer KMetro Skin

Oh, did I mention that these settings described here barely manage to come close to what KMP just does by default? Oh well, at least it’s available on Android, maybe there’s still hope…

Advertisements
Hardware Acceleration in Chrome

Hardware Acceleration in Chrome

All work and no play makes Jack a dull boy

Well, as if anybody expected that to only apply to Jack, you can bet your ass it also applies to Mike. That’s right – every now and then Mike needs to take the edge off on some Youtube sh*t (sometimes even for endless hours lost in oblivion) or some damned annoyingly addictive browser game.

But then again, how in f*ck’s name would Mike feel any better about doing so if everything hangs and seems laggy / choppy? He wouldn’t, that’s how. And right about now, he blames it all on Chrome’s hardware acceleration default settings under Linux. Just to make sure, he goes to chrome://gpu/ and witnesses this horrific scene:

chrome-gpu-off

But Mike’s a crazy mothaf*cka – he then just goes straight to chrome://flags/ and enables the override on software rendering, thus enabling GPU acceleration on his apparently unsupported system configuration.

chrome-flags

He now restarts his Chrome, everything works fine and the Gods of Internets smile approvingly. But just before diving into a multiverse of fun, he takes a few short moments wallowing in self-pity, consumed by doubts about nVidia and random homicidal thoughts about Aquaman while checking the chrome://gpu/ page one last time.

chrome-gpu-on

Just to remove any trace of doubt – that green text right there – it makes St. Patrick proud and Chrome run smooth. Mission complete.

How to make a Git server: The quick and dirty way

How to make a Git server: The quick and dirty way

Just as I was organizing my thoughts for the second part of my Getting started with Git series, I realized that it will all pretty much revolve around working with remotes – so here’s a quick guide to install and configure a git server. While this method is not the recommended way of doing things, it will get them done quite fast but don’t expect any sophisticated security or easy repository management.

This guide will get you up and running your Git server in no time, so that you can get right into creating new repositories that you and anyone else who has access to the server can clone locally, pull from and push to.

Step 1

SSH into your server and install git:

sudo apt-get install git

Step 2

Create a directory to hold your repositories and make sure it has the right user permissions:

sudo mkdir /srv/git

Step 3

Create and initialize your first repository by making a new directory and initializing a new bare git repository there:

mkdir /srv/git/my-repository.git
cd /srv/git/my-repository.git
git init --bare

Step 4

Clone your repository locally and make your first commit and push:

cd /var/www/public_html
git clone ssh://you@server-address/srv/git/my-repository.git
cd my-repository

At this point, it’s time to add some files to this empty directory, or start making them one by one if you feel that hardcore. If you run a git status command, you’ll see that your file(s) are all there but not currently being tracked, so we should add them to the staging area:

git status
git add .

Time to make our first commit and add a meaningful message to it, like “Initial commit”. But no, really, these sort of messages are only permitted on first commits, for all the rest of them you should try to be as descriptive as possible and always to the point… oh hell, I’ll just write a separate post for that later on.

git commit -m "Initial commit"

We can now safely push this commit to the remote repository and also set our master branch to track the remote master branch for changes by using the -u option just this one time only. If you haven’t done this already, it’s about damn time you set up passwordless SSH login, it can and most probably will save lives.

git push -u

Updating your local copy with the potential changes from the remote before pushing your own is usually considered good practice, especially if you’re not the only one working on the repository. A little git pull every now and then never hurt anyone – well, except for the times you get conflicts.

That’s when sh*t gets ugly and even though the rational thing is to just calm down work them out one by one, it really pays off to storm out of your cubicle, bloodshot eyes, swinging a DIY nunchuck made of keyboards / mice / extension cords / what have you, spitting death threats at your co-workers…

This will get you a reputation and / or a night in jail so be ready for both. For more tips on moronic behavior, follow my guide on How To: Make A Rep In Jail In The First 12 Hours. Just kidding… am I?… kidding… or am I?…

Getting started with Git (Part I)

Getting started with Git (Part I)

What is Git?

Git is yet another one of those type of things I now cannot perceive life without. To just dive right into it and give it sort of a more academic definition, Git is a distributed version control system created by Linus Torvalds – yes, the same awesome guy who made Linux, that should reassure anyone.

While most other version control systems (i.e. SVN, CSV, SCSS, RCS, etc.) use a central repository model that holds the master copy of the code, Git stores all the repositories locally for all the clients using them. But seriously, the idea of its entire architecture and the way it works is so much better explained in so many other places and I think that learning about those things first is very important, regardless of your background in any other version control systems.

Where do I learn more?

For instance, I came here from SVN and CSV and mostly learned about it all from git’s official website Documentation page(s) and of course, Kevin Skoglund’s Git Essential Training video course on Lynda.com, both which I warmly recommend, as these posts are nothing but stripped down versions of some notes I took and are only here to help me out in a hypothetical situation in which I’m stranded on a deserted island, I build a computer out of sticks and stones and can’t remember how to clone my remote repositories so I can work myself to death.

Prerequisites

So much for minimal writing… (I know (I know)). Git is a big deal, ok? It needed a bit of introduction – but no more, this first part will help you install and configure Git on a local machine so you can start working with remote git repositories. Some people might be happy enough with using local repositories, but personally I administer and / or have access to enough servers to go all remote, as it is easier, safer, more useful and frankly – the way to go. This guide assumes that:

  • You have SSH access to a Git server (well, this is quite improper – something remote to hold your repositories then)
  • Your dog is jealous of your terminal, as that’s your best friend (bonus points if you don’t have a dog at all (extra bonus points if you got rid of it because of the terminal))
  • You DO know a thing or two about version control
  • You DID RTFM
  • You ARE gay for Kevin Skoglund (no homo)
  • You’re running Linux or Windows (MAC OS is UNIX-based, so Linux stuff might / should apply)

Installation

  • Linux:
    sudo apt-get install git-core
  • Windows: go to git-scm.com and follow the download / setup instructions
    Note: Windows users should totally get and configure a ssh agent to manage their keys. Punching in the password on every pull / push can induce paranoia and intense thoughts of violence against the machines and self mutilation.

Configuration

We have three separate levels of configuration (System level, User level and Project level) but we want to go for the User level one – more information on these can be found in the manual. So, open up a terminal / console and let’s start configuring:

git config --global user.name "Mike Johnson"
git config --global user.email "mike.johnson@howto8165.net"
git config --global core.editor "nano"
git config --global color.ui auto

To fix the ever-existing problem with new line handling (LF normalization), we need to also add these:

  • Linux:
    git config --global core.autocrlf input
  • Windows:
    git config --global core.autocrlf true

Git auto-completion

Windows should have it already. That thing, in pretty much any UNIX environment when you press Tab in a terminal to auto-complete your sh*t or suggest more of it? Yeah, for some reason, you don’t get that by default (in Linux at least). So it kind of needs to be installed:

cd ~
curl -OL https://github.com/git/git/raw/master/contrib/completion/git-completion.bash
mv ~/git-completion.bash ~/.git-completion.bash
nano ~/.bash_profile

and put these in there:

if [ -f ~/.git-completion.bash ]; then
    source ~/.git-completion.bash
fi

Terminal colors

When working with branches or remotes, it is useful to have the terminal display the name of the currently checked out branch in the prompt. So, basically just edit or create a .bash_profile file in your user’s home folder and add this line:

export PS1='$(__git_ps1 "\e[1;32m[%s]\e[0m") \w $ '

This will have the effect of displaying the current working directory followed by a space, a dollar sign and another space on any directory that doesn’t contain a git repository. On directories that do contain repositories, it adds the bold green name of the branch before all of the above, in square brackets.

For the sake of making it all just a bit more customizable, in terms of colors at least, you can add this list of variables to your file and use them implicitly.

txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White

bldblk='\e[1;30m' # Black - Bold
bldred='\e[1;31m' # Red
bldgrn='\e[1;32m' # Green
bldylw='\e[1;33m' # Yellow
bldblu='\e[1;34m' # Blue
bldpur='\e[1;35m' # Purple
bldcyn='\e[1;36m' # Cyan
bldwht='\e[1;37m' # White

unkblk='\e[4;30m' # Black - Underline
undred='\e[4;31m' # Red
undgrn='\e[4;32m' # Green
undylw='\e[4;33m' # Yellow
undblu='\e[4;34m' # Blue
undpur='\e[4;35m' # Purple
undcyn='\e[4;36m' # Cyan
undwht='\e[4;37m' # White

bakblk='\e[40m' # Black - Background
bakred='\e[41m' # Red
badgrn='\e[42m' # Green
bakylw='\e[43m' # Yellow
bakblu='\e[44m' # Blue
bakpur='\e[45m' # Purple
bakcyn='\e[46m' # Cyan
bakwht='\e[47m' # White

txtrst='\e[0m' # Text Reset

That should be it for now… Just as a reminder, in case you missed my fascinating post on SSH auto-login – check it. It can save lives when working with Git. As much as I would like to stall, however, the next part of this guide will be a long thorough list of pretty much all the git commands you’ll be probably using all the time. It saddens me greatly to have to go through the miles of notes I have taken and attempt to cover even more stuff in detail, being descriptive and coming up with all sorts of scenarios…

Oh, and after that, there’ll be part III (God only knows how many parts this series will have in the end) in which I’ll be describing a highly effective workflow technique that has helped me a lot. Yeah, that would conclude this series and I’ll finally be able to easily sleep at night knowing that my volatile thoughts are well stored and safe – I like this blog, it’s like my own personal pensive. Only thing left after that is to write a guide on how to properly install and configure Git on a server / a Git server 🙂

All right, great, we’re done with the basic stuff. Make sure you check out the next post in the series for even more basic stuff, or if you think you’re ready for more, with all due respect bl*w me, do you have any idea how long it takes to make a post like that? That’s irrelevant, as opposed to Getting started with Git (Part II).

Terminal transparency in Gnome – How to get it back

Terminal transparency in Gnome – How to get it back

You don’t. Apparently, background transparency has been removed in gnome-terminal 3.8 and hasn’t come back yet – it’s been many, many months and the only workaround that I know about is straight overkill. However, I have a (arguably) better one: get rid of gnome-terminal and switch to an alternative, like xfce4-terminal.

xfce4-terminal

  1. Install xfce4-terminal
    sudo apt-get install xfce4-terminal
  2. Remove gnome-terminal
    sudo apt-get remove gnome-terminal
  3. Configure xfce4-terminal transparency

At this point, xfce4-terminal should be the default terminal, but just in case it isn’t, run this line and make it so manually:

sudo update-alternatives --config x-terminal-emulator

Desktop launchers

Note however that desktop launchers running in terminal (i.e. SSH shortcutswill fallback to xterm and look horrible, so you need to make sure that the actual command is passed to the xfce4-terminal as a command argument, like this for instance:

xfce4-terminal --command="ssh user@server.com"

These launcher icons can be made either by using gnome’s GUI tool:

gnome-destkop-item-edit --create-new ~/Desktop

or, by making a .desktop file with contents like this:

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon[en_US]=terminal2
Exec=xfce4-terminal --command="ssh user@server.com"
Comment[en_US]=SSH: Server.com
Name[en_US]=SSH: Server.com
Name=SSH: server.com
Comment=SSH: server.com
Icon=terminal2

Note: .desktop files need to be executable so you need to chmod +x them.

Default working directory

Sadly enough, there’s a bug concerning xfce4-terminal’s --default-working-directory option, as described here. But then again, luckily there’s a nice workaround involving disabling the old CTRL + ALT + T keyboard shortcut and making a new one, mapped to a custom command. So, in Gnome, open Keyboards -> Shortcuts -> Custom Shortcuts. Create a new custom shortcut with the following command:

xfce4-terminal --working-directory=/var/www/public_html

When you enable your new awesome custom shortcut, you can override the old one by setting it to CTRL + ALT + T.

How to install LAMP manually in 60 seconds

How to install LAMP manually in 60 seconds

It usually takes me a few good minutes to get the LAMP stack (Linux Apache MySQL PHP) installed and many more to get it configured to fit my needs. Well, I’ve finally managed to get it all together into a little something that can be done in under a minute. Assuming you’re doing this on a reasonably fresh Linux installation, these following lines will get you through with no problems and you’ll be the proud user of Apache 2.4 + PHP 5.6 + MySQL 5.6 in no time:

First, install a mother-load of packages (basically Apache, PHP, MySQL, phpMyAdmin and MySQL Workbench):

sudo apt-get install apache2 mysql-server mysql-workbench php5 curl php5-curl mcrypt php5-mcrypt php5-imagick php5-gd php5-xdebug phpmyadmin

Then, a few useful Apache modules:

sudo a2enmod rewrite headers expires deflate

Yeah… we might get a nasty looking message every time we restart the apache server, something like this:

apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. Set the ‘ServerName’ directive globally to suppress this message.

To get rid of that, we have to define the ServerName and include it in our configuration file.

httpd.conf

sudo nano /etc/apache2/httpd.conf

This file might be blank, but add the following line to it anyway:

ServerName localhost

Then add these references to the apache2.conf file

apache2.conf

Include httpd.conf
Include /etc/phpmyadmin/apache.conf

Cool, now as a security measure, it would seem that in newer Apache releases, the default document root points to /var/www/html instead of directly to /var/www. We might as well rename that html to public_html and update some configs.

000-default.conf

sudo nano /etc/apache2/sites-available/000-default.conf

And change the DocumentRoot to this:

DocumentRoot /var/www/public_html

Also, while we’re in here we should add a few lines to prevent mod_rewrite from having girl problems later in life:

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/public_html/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    allow from all
</Directory>

Also, there might be some trouble with PHP’s mcrypt extension, so let’s make sure it actually gets loaded:

php.ini

sudo nano /etc/php5/apache2/php.ini

Go down to Dynamic Extensions and add this line if it doesn’t exist:

extension=mcrypt.so

And… that should be it – restart the web server and go to http://localhost/ to test the installation:

sudo service apache2 restart

Also, just for the thrill, you can make a phpinfo.php file in /var/www/public_html with just this:

<?php phpinfo(); ?>

to review all the modules and extensions that have been miraculously installed on your system.

Also, a quick tip on the nano editor if you haven’t moved on to vim already. Tab size should be 4 spaces – that’s it – period. If there’s already a .nanorc file in your home directory, add this line to it or create if first otherwise (dooh~)

set tabsize 4