Saturday, 2 March 2019

Disabling webp in Firefox

If you're one of the weird persons who dislike new features, this short article could be useful for you.

A few years ago Google invented webp, a new image compression for web. It was proclaimed as better than jpeg or png and supporting both lossy and lossless compression. The majority of browsers (including Firefox since version 65) support this new format. Of course, it is fine -- better compression, less traffic, faster page loading, less lose of money. But! If you'd like to save a picture from web (either jpeg or png), you can't do this, as you have been doing it earlier. Firefox suggests to save image in the webp format.

Here is a solution to avoid this issue and save the pictures in their original format (by the worth of increasing your Internet traffic).

  1. open the page about:config
  2. click the button I accept the risk
  3. in the search bar type network.http.accept.default
  4. double click on the found parameter
  5. remove the substring image/webp
  6. apply modification by pressing the button OK

That's so! After this you can continue surffing in your usual manner. All the pictures will be downloaded in their original format.

To revert to the original value do the right click on this parameter and apply the command Reset. So your Firefox accepts webp again.


After updating the Firefox instance on my computer I've found that the suggestion of this article doesn't work. In this case (FF 65.0.2) the following modification should be applied (I tested it earlier with FF 65.0.1 but it hasn't worked):

  1. open the page about:config
  2. click the button I accept the risk
  3. in the search bar type image.http.accept
  4. double click on the found parameter
  5. remove the substring image/webp
  6. apply modification by pressing the button OK

Another related pages

  1. Firefox 65 supports Google's WebP Image format
  2. How to avoid saving images in webp format in Google Chrome 
  3. Related discussion on Russian Mozilla forum

Friday, 29 July 2016

Color Diff

Few months ago I have found I feel lack of the highlighting capability of the diff output. To cover this lack I began to look for solutions. A lot of resources refer to the colordiff, the tool written in Perl. But I wasn't satisfied with it. Question on StackOverflow and this article have inspired me to develop the Bash function having the same (or almost the same) functionality as colordiff and having mechanism as described in the early mentioned article.

Some of you can say I have re-invented the wheel because a) there is colordiff, b) diff has the special options to format output. But I'd like to have simple solution with full support of many output formats as much as possible and the simple usage as the command itself. It uses sed to format (colorize) diff output. It has the following features:

  • The wrapper and can be called as the replacement instead the standard tool;
  • Analyzes command line options and generates the special sed commands colorizing output;
  • Covers all known formatting options (--context, --unified, --ed, --rcs, --side-by-side, --show-c-function);
  • It supports CDIFF_COLORS and CDIFF_WHEN, the special environment variables having impact on the function behavior (they works similar to GREP_COLORS for grep).

There is help page below. Just follow this link, download the script and try.

$ diff
Usage: diff [OPTION]... FILES

Wrapper for diff to colorize output of diff for better readability.
Try "diff --help" for more information.


Diff options

All options will be passed to "diff".

Coloring options

--color[=WHEN], --colour[=WHEN]

Controls the colorizing method. WHEN is "always" (the default value if not
specified explicitly), "never" or "auto". To make affect globally, set one
of these values to CDIFF_WHEN environment variable.


This environment variable is used to specify colors to highlight the
separate parts of the diff output. Its value is a colon-separated list of
capabilities. Names and responsibility of each capability correspond to
the configuration parameters "color.diff.<slot>" used in "git config".
Values are integers in decimal representation and can be concatenated with
semicolons. Further these values are assembled into ANSI escape codes.

Metainformation (names of compared files)

Hunk header (line numbers of changed lines)

Removed lines

Added lines

Modified lines

Colorizing method does effect on all runs; assumes the same values as for
the "--color" option. The default value is "auto" and can be superseded by
the "--color" option.

Tuesday, 18 February 2014

jsmin.js keeping important comments unchanged

More than dozen years ago Douglas Crockford, the JavaScript guru, has presented his JavaScript Minifier. This tool obfuscates the JavaScript code, removing extra whitespaces and comments. Later, Franck Marcia has adapted the C-written program to JavaScript. See his implementation at the page JS Minifier.

Still later, Billy Hoffman has patched the script and added the support of important comments. Important comments are specially formed comments (in practice, denoted with /*!) that are not removed by minifier. What he has done we can find out from his article JSMin, Important Comments, and Copyright Violations. The main goal to support important comments was to retain copyrights and licensing information intact.

Important comments are very useful also to keep some sensitive data within (for example, resources used by the script). Unfortunately, they are not supported completely because TAB and asterisk characters are changed (TABs are converted to SPACEs, and asterisks are eaten by the minifier). To fix this issue I have made some changes to the latest version of jsmin.js.

You can find the updated version of the jsmin.js at the GitHub. Also you can apply the following patch for the existing on your computer copy of the original script:
> jsmin.js - 2014-02-04
> Author: Ildar Shaimordanov
> This version was patched to keep important comments (denoted with /*!) 
> unchanged. The previous version of jsmin.js ate asterisk symbols and 
> modified some characters as well (for example TAB was replaced by SPACE). 
> Sometimes, comments should stay unchanged (for example, a function could 
> keep its resources within comments). So this version does it. 
<     if(c >= ' ' || c == '\n' || c == '\r') {
<       return c;
<     }
<     return ' ';
>     return c;
>   function peekIC() {
>     theLookahead = getcIC();
>     return theLookahead;
>   }
<                   if(peek() == '/') {
<                     getc();
>                   if(peekIC() == '/') {
>                     getcIC();
>                   d += c;

Wednesday, 4 December 2013

Cygwin Here

This short article explains how to open a specific folder in Cygwin.

Friday, 17 May 2013

Modulo adjustment

If you open MDN pages, describing Math.ceil, Math.floor, and Math.round, you will find the good example of the adjustment and rounding based on the decimal logarithm. For exdample, Math.ceil10(55, 2) returns 100 where 2 expresses an exponent for 10^2.

Besides of logarithmic adjustment we can use modulo based adjustment. It is almost the same as above but uses an arbitrary number for adjustment.

Tuesday, 2 October 2012

Continuing long lines in a batch script

Unintentionally I found for myself that a batch script has a nice feature to break long lines without loosing of possibility of reading them.

Imagine, you have some weird combination of commands as below that is not put completely in one line of a screen.

some-command-with-many-arguments | another-lomg-command-with-its-own-arguments | etc | etc | etc

If the line of a code cannot be shown within one line on a screen it will be i) either turned and the rest of line will be shown below on one or more lines or ii) continued out of edges of the screen with a horizontal scrolling bar. Both of them are not convenient because we not able to observe the code entirely.

Fortunately, modern batch scripts (in XP, Vista, Win7) have blocks implemented by brace:

) | (
) | etc | etc | etc

I known this feature (because I used brace in the if-else and for statements) but did not realised right now.

So, this gives us good possibility to break the long line into a several lines without loosing of functionality. This is better than nothing and is better than undocumented feature using the DOS-like escaping character ^ at the very ending of the line because you have to look after that this character is in the lastest character of the line. See the same example with the esacaping character:

some-command-with-many-arguments | ^
another-long-command-with-its-own-arguments | ^
etc | etc | etc

Unix shell scripts are featured to continue long commands using by backslashes since the begining of the Unix wolrd.

some-command-with-many-arguments \
| another-long-command-with-its-own-arguments \
| etc | etc | etc

Saturday, 29 September 2012

How to concatenate multiple lines in console (bash, cmd)

If for some reasons you need to have concatenated lines try one of the recipes below.

Monday, 25 June 2012

Merge and sort many logfiles having multiline entries

logmerge is the small and powerful script to merge two or more log files so that multiline entries appear in the correct chronological order without breaks of entries. Optional arguments control an adding of descriptive fields at the beginning of each line in the resulting combined logfile. Reading of .gz/.bz2 files is available.

Tuesday, 15 May 2012

Regular Expression Analyzer

Neat online tool. Regular expressions are described in the human-friendly style.

Regular Expression Analyzer

Sunday, 25 March 2012

Universal way to identify your external IP and more

There are many such kind of resources in Internet but this is the best. It allows the numerous structured data and it has nice name. Meet
Command line interface
Using curl
or wget
wget -qO -
var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');'GET', '', false);
var ip = xmlhttp.responseText;
var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');'GET', '', false);
var ip = xmlhttp.responseXml.getElementsByTagName('ip_addr')[0].text;
Having JSON library you can read and parse JSON data:
var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');'GET', '', false);
var data = JSON.parse(xmlhttp.responseText);
var ip = data.ip_addr;
Dim xmlhttp, ip
Set xmlhttp = CreateObject("Microsoft.XMLHTTP") "GET", "", False
ip = xmlhttp.responseText