Thursday, May 9, 2013

HOWTO: get hardware sensors info (temperature, fan speed, voltage etc.) in Linux

(Tested in Debian Wheezy).
  1. Install the lm-sensors package:
    # apt-get install lm-sensors
  2. Run the interactive hardware monitoring chip detection script:
    # sensors-detect
    Usually, it asks a lot of questions, and you can automatically answer 'yes' on them (but be careful: on some systems a full scan can cause some problems, e. g., a false chip detection or even a system hang):
    # yes | sensors-detect
  3. After choosing to add the needed module names automatically to the /etc/modules config file, it's good to check it for duplicate entries (and possibly other garbage).
  4. Reboot (or try to load the newly added kernel modules manually).
  5. Finally, just execute the following command to print the sensors information:
    $ sensors

Sunday, April 14, 2013

HOWTO: radical lossless JPEG image optimization (in Linux)

(The sample commands are tested under Debian Wheezy).

First of all, don't forget to install the JPEG manipulating programs package:
# apt-get install libjpeg-progs
And it's the optimization itself:
$ jpegtran -copy none -progressive input.jpg > output.jpg
Notes:
  1. yes, it produces a progressive JPEG output image; if you don't like it (or it's unsupported in the target environment), use -optimize switch instead of -progressive (but the output image size will be bigger);
  2. there's also a non-recommended option (an -arithmetic switch) to enable arithmetic coding; it allows a more efficient compression than traditional Huffman coding does, but (unfortunately) it's not widely supported in JPEG decoders due to some historical patent restrictions;
  3. -copy none option removes all extra markers (comments, tags, thumbnails and other metadata) from the output; if you need to save them, use -copy comments (or even -copy all) option instead;
  4. you can add a -grayscale option, and it will omit color data from the output image without re-encoding (very useful for grayscale / black & white / monochrome images);
  5. more reading:

Thursday, April 11, 2013

HOWTO: convert audio CD image (FLAC + CUE) to MP3 tracks in Linux

Imagine you've archived your favourite audio CD into FLAC/CUE pair format (or maybe you've purchased some album in that digital downloadable lossless audio format, who knows), and now you want to convert it to the standard MP3 files for playing that album in your good old digital music player.

Let the files be processed in Debian GNU/Linux environment (sample commands tested in Debian 7.0 "Wheezy", and should also work for all Debian-based distros, e. g. Ubuntu, Mint etc.; Bash shell is assumed to be installed & used by default).

First of all, you should install all the necessary tools: FLAC (for decoding FLAC to WAV), LAME (to convert WAV to MP3), cuetools (to parse the CUE sheet) and shntool (to cut the big WAV file into smaller tracks according to the CUE sheet breakpoints).
# apt-get install flac lame cuetools shntool
Then the conversion process itself begins.
$ flac -d MyMusic.flac
$ cuebreakpoints MyMusic.cue | shnsplit MyMusic.wav
$ rm MyMusic.wav
$ for file in split-track*.wav; do lame -V0 $file; done
$ rm split-track*.wav
The output files are by default MP3 VBR V0, 44.1 KHz, Joint Stereo; it should be decent for most situations.
After conversion, you can process split-track*.mp3 files with your favourite media tagger application.
Enjoy.

Sunday, April 7, 2013

Default Sudo lecture

Here is a standard Sudo lecture, which can be seen at the user's first sudo run time (the following is an unmodified quote extracted from the sudo-$VERSION/plugins/sudoers/check.c source file found in the original sudo 1.8.6p7 source tarball):
#define DEFAULT_LECTURE "\n" \
    "We trust you have received the usual lecture from the local System\n" \
    "Administrator. It usually boils down to these three things:\n\n" \
    "    #1) Respect the privacy of others.\n" \
    "    #2) Think before you type.\n" \
    "    #3) With great power comes great responsibility.\n\n"
References:
  1. Sudo Main Page

Sunday, March 10, 2013

HOWTO: losslessly convert FLV to MP4 in Linux (Debian)

Well, let's imagine we have a FLV file (possibly unseekable or with other minor problems) containing MPEG-4 AVC video & AAC audio.
We'll convert it to MP4 without any reencoding using the free tools available in current Debian GNU/Linux (7.0 "Wheezy") repositories.

  • Method #1: using avconv (it's a part of Libav project, a fork of FFmpeg).

    Install libav-tools:
    # apt-get install libav-tools
    Convert a FLV file to MP4, preserving audio & video:
    $ avconv -i input.flv -codec copy output.mp4
    To extract audio only:
    $ avconv -i input.flv -codec copy -vn output_a.mp4
    To extract video only:
    $ avconv -i input.flv -codec copy -an output_v.mp4
    Note: you can also use M4A (audio) / M4V (video) file extensions for output, if you like those Apple formats.

  • Method #2: using MEncoder (a part of MPlayer project).

    Install MEncoder:
    # apt-get install mencoder
    Convert a FLV file to MP4:
    $ mencoder input.flv -ovc copy -oac copy -of lavf -o output.mp4
    Note: according to the warning from MEncoder itself, output file can be corrupt:
    ** MUXER_LAVF *****************************************************************
    REMEMBER: MEncoder's libavformat muxing is presently broken and can generate
    INCORRECT files in the presence of B-frames. Moreover, due to bugs MPlayer
    will play these INCORRECT files as if nothing were wrong!
    *******************************************************************************

The Simpsons: Cisco

  • From the "Half-Decent Proposal" [S13E10] episode:

  • HOWTO: make MS VS 2005 work with WPF etc.

    WPF ("Windows Presentation Fundation", just another MS Windows GUI API from .NET 3.0 "WinFX", this time XML-based) is fully supported in Microsoft Visual Studio 2008 and newer.
    If you use VS 2005, you'll not find an option to create a WPF project from the New Project dialog (WPF was released as part of .NET Framework 3.0, while VS 2005 is for .NET 2.0).

    Here are the required steps to get an ability to build WPF projects with VS 2005.
    1. Download .NET Framework 3.5 SP1 (if you don't have an up-to-date .NET 3.x version installed yet).
    2. Download a small add-on for VS 2005:
      Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF), November 2006 CTP
      Mirror: CNET | Download.com
      Note: MS has released that package as a CTP ("Community Technology Preview", MS' term for some kind of beta / preview SW releases); it's unsupported, so upgrade to VS 2008 or later is recommended.
    3. Install the downloaded MSI package.
      If the installer exits with an error (regarding the bad / already installed / newer .NET version), you should start it manually (i. e., from MS Windows Command Prompt, you know: <Win>+<R>, cmd, <Enter>) with a specific option:
      > cd P:\ath\To\Installer\Folder
      > msiexec /i vsextwfx.msi WRC_INSTALLED_OVERRIDE=1
      It allows to ignore that error and continue the installation process.
    4. After that, a new option titled Windows Application (WPF) should appear as part of (new!) .NET Framework 3.0 subcategory for C# language in the New Project dialog of the Studio.
      Enjoy!

    See also:
    1. Visual Studio 2005 extensions for .NET Framework 3.0 (WF)
    2. Wikipedia: WCF / WPF / WF | .NET Framework

    Tuesday, February 5, 2013

    JDownloader download manager

    JDownloader is a very nice download manager:
    • it's a freeware (open source, though with some closed source parts);
    • it's written in Java, and therefore is cross-platform (runs well on MS Windows, Linux and Mac OS X);
    • it allows automated downloads from a lot of popular fileshares, video hostings etc. (the use of premium accounts is also possible).

    Qualcomm Atheros device driver downloads site

    Atheros has been acquired by Qualcomm, so currently the drivers for Atheros AR81xx and Lx network devices can be downloaded from Qualcomm Atheros corporate customer portal:
    (these URLs seem to be interchangeable).

    Friday, January 25, 2013

    HOWTO: make Jigdo use local APT cache

    If you like to build Debian install CD images with Jigdo (i. e., with jigdo-lite), you may consider using packages from your local APT cache to save some network traffic.
    To make it easily selectable from the Jigdo interface, make sure to add the following line to the ~/.jigdo-lite config file:
    scanMenu='/var/cache/apt/archives/ /media/cdrom/'
    BTW: /var/cache/apt/archives is a local APT cache directory (containing already downloaded DEB packages); /media/cdrom is a standard CD mount point, so you can reuse the files from the mounted CD image you've previously generated with Jigdo.

    References:
    1. More About Scan Sources - Debian Jigdo mini-HOWTO