Blogs

Puppet Check ERBs for Dynamic Scoping

If you ever need to upgrade a code base to Puppet 3.0 and strip all dynamic scoping from your templates:

for file in $( find . -name "*.erb" | sort); do 
    echo "------------ [ $file ]"; 
    if grep -q "<%[^>]*$" $file; then 
        content=$(sed '/<%/,/%>/!d' $file); 
    else
        content=$(grep "<%" $file); 
    fi;
    echo "$content" | egrep "(.each|if |%=)" | egrep -v "scope.lookupvar|@|scope\["; 
done

HowTo: Implement Consistent Hashing with Different memcached Bindings

A short HowTo on memcached consistent hashing. Of course also works with memcached protocol compatible software as CouchBase, MySQL...

Papers

Papers to read to learn about what consistent hashing is about:

Consistent Hashing with nginx

 upstream somestream {
      consistent_hash $request_uri;
      server 10.0.0.1:11211;
      server 10.0.0.2:11211;
      ...
    }

Consistent Hashing with PHP

Note: the order of setOption() and addServers() is important. When using OPT_LIBKETAMA_COMPATIBLE
the hashing is compatible with all other runtimes using libmemcached.

$memcached = new Memcached();
$memcached->setOption(Memcached::OPT_DISTRIBUTION, Memcached::DISTRIBUTION_CONSISTENT);
$memcached->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
$memcached->addServers($servers);

Consistent Hashing in Perl

As in PHP the order of setOptions() and addServers() matters. After all both languages use the same library in the background, so behaviour is the same.

$m = new Memcached('mymemcache');
$m->setOptions(array(
   ...
   Memcached::OPT_LIBKETAMA_COMPATIBLE => true,
   Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_CONSISTENT,
   ...
));
$m->addServers(...);

Liferea 1.10 and Firefox 34 as External Browser

Today I learned that newest Firefox release 34 drops some Mozilla legacy command line options that Liferea used for a long time to open links in a Firefox tab or window.

When you upgrade to Firefox 34 opening links might suddenly stop to work, because Liferea uses the wrong launch command.

Workarounds

Here are 2 simple workaround alternatives. For both you need to open the "Browser" tab in the preferences dialog (via menu /Tools/Preferences):

  1. Either simply choose "GNOME Default Browser".
  2. Or choose "Manual" and set command to
    firefox %s

Screenshot of the browser settings tab:

Liferea 1.10.14 Released

There is a new maintenance release for the 1.10 line. It tries to fix startup crashes reported by several users and fixes a bug with launching links in the external browser. Please upgrade!

ChangeLog

    * Fixes Github #134: Broken default news feed.
      (reported by pvdl)
    * Fixes Github #133: Subscribe into TheOldReader categories
    * Fixes Github #122: Crashes at launch, "segmentation fault"
      (reported by geoffm)
    * Fixes some memory leaks
      (patch by Rich Coe)
    * Fixes Github #145: Incorrect method triggered for 'Launch External'
      (patch by mozbugbox)
    * Fixes Github #48: Window stays hidden on next start after Ctrl+W
      (reported by Jeff Fortin)
    * Expose LifereaHtmlView to GObject Introspection
      (patch by mozbugbox)
    * Improves Google Reader API error handling
    * Now using HTTPS only when accessing TheOldReader
    * Added LifereaNodeSourceActivatable interface to allow plugins
      implementing new node source types.
    * Downgrade enclosure drop warning from Glib warning to debug trace.

Download

You can download the release on Github:
https://github.com/lwindolf/liferea/releases/tag/v1.10.14

Puppet: List Changed Files

If you want to know which files where changed by puppet in the last days:

cd /var/lib/puppet
for i in $(find clientbucket/ -name paths); do
	echo "$(stat -c %y $i | sed 's/\..*//')       $(cat $i)";
done | sort -n

will give you an output like

[...]
2015-02-10 12:36:25       /etc/resolv.conf
2015-02-17 10:52:09       /etc/bash.bashrc
2015-02-20 14:48:18       /etc/snmp/snmpd.conf
2015-02-20 14:50:53       /etc/snmp/snmpd.conf
[...]

Liferea Trick #9: Skimming Trough the Headlines

I'm not sure about how many users are aware of the feature, but I'm certain it is worth to know about as it saves a lot of clicking and pointing with the mouse. If you are a keyboard user it's worth knowing about the hotkey to skim through headlines.

Remember the Hot Key

As this hotkey is configurable check the preference dialog ff you are not sure about the setting. The default setting is <Ctrl>-Space...

How it Works...

By using this hot key you can navigate the article pane and the item list view at the same time. As long as the article pane allow vertical scrolling it scrolls down. Once you reach bottom Liferea jumps to the next unread article.

Using the headline skimming hotkey is like a "Next Unread And Scroll Down" menu option...


Recent Liferea Tricks

Fixed Issue with "Open in External Browser" Option

Pull Request #145: "Incorrect method triggered for 'Launch External'" by mozbugbox fixes an often reported issue with launching links in external browser. Due to a copy an paste mistake the same callback was called for link menu options 'Open in External Browser' and 'Open in Browser'.

A screenshot of the menu options:

The difference between both option is that 'Open in External Browser' always launches the link in your favourite web browser while the other option does load links in Liferea if you specified so in the preferences. As 'Open in External Browser' incorrectly triggered the same callback as 'Open in Browser' the bug appeared depending on the preference settings.

Will be fixed with release 1.10.14 and 1.11.3

Help Needed: High Contrast Icon

Today Obsidien created ticket #148 about support for the GNOME high contrast icon theme.

Icons in this theme look like this:


(screenshot taken from GNOME Wiki)

As I'm not an artist in any way I want to ask you readers for your help! So if you are a graphics artist and have some spare time why not gift an high contrast icon for Liferea! If you are interested leave a note in the ticket.

Liferea 1.11.3 Released

There is a new release for the unstable line: Liferea 1.11.3. This release fixes several issues and introduces an improvement of the rendering of the 3 pane "Wide View" mode to save screen space on 16x9 screens. This is intended to improve usability in full screen mode on desktops and tablets. This release also introduces folder (categories) support for TheOldReader subscriptions.

Here is a screenshot of the changed "Wide View" mode

Give 1.11.3 a try and send feedback to the mailing list [email protected]!

ChangeLog

    * Fixes Github #134: Broken default news feed.
      (reported by pvdl)
    * Fixes Github #133: Subscribe into TheOldReader categories
    * Fixes Github #122: Crashes at launch, "segmentation fault"
      (reported by geoffm)
    * Fixes some memory leaks
      (patch by Rich Coe)
    * Fixes Github #145: Incorrect method triggered for 'Launch External'
      (patch by mozbugbox)
    * Fixes Github #48: Window stays hidden on next start after Ctrl+W
      (reported by Jeff Fortin)
    * Expose LifereaHtmlView to GObject Introspection
      (patch by mozbugbox)
    * Improves Google Reader API error handling
    * Now using HTTPS only when accessing TheOldReader
    * Added LifereaNodeSourceActivatable interface to allow plugins
      implementing new node source types.
    * Downgrade enclosure drop warning from Glib warning to debug trace.

Download

You can download the release on Github:
https://github.com/lwindolf/liferea/releases/tag/v1.11.3

Static Code Analysis of any Autotools Project with OCLint

The following is a HowTo describing the setup of OCLint for any C/C++ project using autotools.

1. OCLint Setup

First step is downloading OCLint, as there are no package so far, it's just extracting the tarball somewhere in $HOME. Check out the latest release link on http://archives.oclint.org/releases/.

cd
wget "http://archives.oclint.org/releases/0.8/oclint-0.8.1-x86_64-linux-3.13.0-35-generic.tar.gz"
tar zxvf oclint-0.8.1-x86_64-linux-3.13.0-35-generic.tar.gz 

This should leave you with a copy of OCLint in ~/oclint-0.8.1

2. Bear Setup

As project usually consist of a lot of source files in different subdirectories it is hard for a linter to know where to look for files. While "cmake" has support for dumping a list of source files it processes during a run "make" doesn't. This is where the "Bear" wrapper comes to play: instead of

make

you run

bear make

so "bear" can track all files being compiled. It will dump a JSON file "compile_commands.json" which OCLint can use to do analysis of all files.

To setup Bear do the following

cd
git clone https://github.com/rizsotto/Bear.git
cd Bear
cmake .
make

3. Analyzing Code

Now we have all the tools we need. Let's download some autotools project like Liferea. Before doing code analysis it should be downloaded and build at least once:

git clone https://github.com/lwindolf/liferea.git
cd liferea
sh autogen.sh
make

Now we collect all code file compilation instructions with bear:

make clean
bear make

And if this succeed we can start a complete analysis with

~/oclint-0.8.1/bin/oclint-json-compilation-database

which will run OCLint with the input from "compile_commands.json" produced by "bear". Don't call "oclint" directly as you'd need to pass all compile flags manually.

If all went well you could see code analysis lines like those:

[...]
conf.c:263:9: useless parentheses P3 
conf.c:274:9: useless parentheses P3 
conf.c:284:9: useless parentheses P3 
conf.c:46:1: high cyclomatic complexity P2 Cyclomatic Complexity Number 33 exceeds limit of 10
conf.c:157:1: high cyclomatic complexity P2 Cyclomatic Complexity Number 12 exceeds limit of 10
conf.c:229:1: high cyclomatic complexity P2 Cyclomatic Complexity Number 30 exceeds limit of 10
conf.c:78:1: long method P3 Method with 55 lines exceeds limit of 50
conf.c:50:2: short variable name P3 Variable name with 2 characters is shorter than the threshold of 3
conf.c:52:2: short variable name P3 Variable name with 1 characters is shorter than the threshold of 3
[...]
Syndicate content